Commit Graph

24 Commits

Author SHA1 Message Date
Lucien Cartier-Tilet 071c8b0728
Made mod `utils` public 2020-04-05 15:48:41 +02:00
Lucien Cartier-Tilet 5f30c6d636
Reorganized modules, made rules a separate struct
Rules are now a separate struct, and the `rules` member of
`settings::Settings` is now a `Vec<settings::rule::Rule`.

Several elements were made private, now can be accessed through
dedicated methods
2020-04-04 22:44:08 +02:00
Lucien Cartier-Tilet dbbb1616dd
Optimized rule rewriting 2020-04-04 18:54:46 +02:00
Lucien Cartier-Tilet 23e3acb182
Better category find and replace
I didn't have to do it in two `replace` calls

Now I have to check if the rule has a or several corresponding
categories in the initial and final regex, find whether they have the
same amount of elements, and if so create rules that allow elements from
each category to be mapped 1:1
2020-04-04 18:28:27 +02:00
Lucien Cartier-Tilet 6fb1c287e0
Rules are now kept sorted
Changed the rules from a HashMap to a Vec
2020-04-04 17:08:26 +02:00
Lucien Cartier-Tilet ef8c02fc97
Good progress with applying rules, room for improvement
Rules are applied, however some bugs remain:
- The HashMap for rules should be replaced by a Vec so they can be
  stored in order and not randomly
- For some reasons, the `%` is not removed from some rules in the
  private function `update_rules` in the `Settings` struct.
- Make it so replacements between square brackets work correctly
2020-04-04 15:46:29 +02:00
Lucien Cartier-Tilet bae1d86544
Switched from Vectors to HashMaps, need to update docs 2020-03-29 18:10:45 +02:00
Lucien Cartier-Tilet 6be0f7e8f6
Switched rules to Regexes, added Regex wrapper for serde 2020-03-29 03:10:19 +02:00
Lucien Cartier-Tilet d13836e433
Removed comments, made Settings members public, doc 2020-03-29 03:09:48 +02:00
Lucien Cartier-Tilet f3e672e29c
Organized imports 2020-03-29 03:07:26 +02:00
Lucien Cartier-Tilet c418323b5c
Removed unused `use`s 2020-03-29 03:06:46 +02:00
Lucien Cartier-Tilet c6baa46aca
Removed `import_input`
This should be left to the client crate, `settings::utils::read_file`
is already here for that
2020-03-28 22:38:28 +01:00
Lucien Cartier-Tilet 18eb16e777
Rewritten some parts as macros, updated extension handling
Encoding and decoding of `settings::Settings` now handled in macros to
avoid code repetition. I also wish rewrite them both in a combined
macro that would either encode or decode the struct depending on how
it was called.

Replaced some log warnings with errors

Now if type extension is not valid, the code will still attempt to
decode it, first as JSON data, then as Yaml data. If both fail, then
an error is returned. For this, I added the Display trait to the
`settings::Settings` struct which allows the FromStr trait, and due
to conflicting implementation, I removed the From trait and
implemented manually the `from` method with the same signature -- the
struct just lacks the trait that comes with it.
2020-03-28 22:03:21 +01:00
Lucien Cartier-Tilet d200367ee0
Updated logger options, changed filetype behavior
Replaced lots of warns by errors

Filetype detection won’t return an error on unknown extension anymore,
but will return an `Other` value so it can be handled by other
functions not as an error already. See upcoming commits.
2020-03-28 21:59:23 +01:00
Lucien Cartier-Tilet e9a161f526
Updated `import_input` signature, documentation 2020-03-28 21:58:27 +01:00
Lucien Cartier-Tilet a7ef031090
Final doc before I go to sleep 2020-03-27 23:31:24 +01:00
Lucien Cartier-Tilet 9f5c040893
Added documentation 2020-03-27 23:27:00 +01:00
Lucien Cartier-Tilet 7d0a371311
Changed ruleset variable type to i32 2020-03-27 23:26:16 +01:00
Lucien Cartier-Tilet e00f489f55
Added From trait to Settings 2020-03-27 23:25:16 +01:00
Lucien Cartier-Tilet 8642067eb3
Updated settings::utils::write_file’s signature for more flexibility
`write_file` now accepts as its second argument any type that
implements the `ToString` trait so that not only Strings will be
accepted but any type that can be turned into one.
2020-03-27 19:09:34 +01:00
Lucien Cartier-Tilet 488ceba1bb
Added some doc and tests 2020-03-27 19:08:47 +01:00
Lucien Cartier-Tilet 2e0c16e97c
Added functions to import and export settings and refactoring 2020-03-27 18:25:20 +01:00
Lucien Cartier-Tilet ff95cb05eb
Added some basic code
Added basic settings representation and a way to load them from either
a YAML or Json file.
2020-03-26 20:10:07 +01:00
Lucien Cartier-Tilet 47100b3476
initial commit 2020-03-26 17:04:23 +01:00