normalizy 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -28
  3. data/README.md +22 -16
  4. data/lib/normalizy/filters/money.rb +2 -2
  5. data/lib/normalizy/filters/percent.rb +2 -2
  6. data/lib/normalizy/version.rb +1 -1
  7. metadata +27 -94
  8. data/spec/normalizy/config/add_spec.rb +0 -21
  9. data/spec/normalizy/config/alias_spec.rb +0 -29
  10. data/spec/normalizy/config/default_filters_spec.rb +0 -19
  11. data/spec/normalizy/config/initialize_spec.rb +0 -16
  12. data/spec/normalizy/config/normalizy_aliases_spec.rb +0 -9
  13. data/spec/normalizy/extensions/filters/date_spec.rb +0 -23
  14. data/spec/normalizy/extensions/filters/money_spec.rb +0 -38
  15. data/spec/normalizy/extensions/filters/number_spec.rb +0 -9
  16. data/spec/normalizy/extensions/filters/percent_spec.rb +0 -30
  17. data/spec/normalizy/extensions/filters/slug_spec.rb +0 -14
  18. data/spec/normalizy/extensions/filters/strip_spec.rb +0 -21
  19. data/spec/normalizy/extensions/model_spec.rb +0 -107
  20. data/spec/normalizy/extensions/normalizy_rules_spec.rb +0 -198
  21. data/spec/normalizy/filters/date_spec.rb +0 -72
  22. data/spec/normalizy/filters/money_spec.rb +0 -282
  23. data/spec/normalizy/filters/number_spec.rb +0 -33
  24. data/spec/normalizy/filters/percent_spec.rb +0 -168
  25. data/spec/normalizy/filters/slug_spec.rb +0 -24
  26. data/spec/normalizy/filters/strip_spec.rb +0 -13
  27. data/spec/normalizy/normalizy/configure_spec.rb +0 -11
  28. data/spec/normalizy/rspec/matcher/description_spec.rb +0 -27
  29. data/spec/normalizy/rspec/matcher/failure_message_spec.rb +0 -48
  30. data/spec/normalizy/rspec/matcher/failure_message_when_negated_spec.rb +0 -30
  31. data/spec/normalizy/rspec/matcher/from_spec.rb +0 -19
  32. data/spec/normalizy/rspec/matcher/matches_spec.rb +0 -117
  33. data/spec/normalizy/rspec/matcher/to_spec.rb +0 -19
  34. data/spec/rails_helper.rb +0 -9
  35. data/spec/support/common.rb +0 -11
  36. data/spec/support/db/schema.rb +0 -83
  37. data/spec/support/filters/blacklist.rb +0 -11
  38. data/spec/support/filters/block.rb +0 -11
  39. data/spec/support/filters/info.rb +0 -11
  40. data/spec/support/models/alias.rb +0 -7
  41. data/spec/support/models/match.rb +0 -9
  42. data/spec/support/models/model.rb +0 -28
  43. data/spec/support/models/model_date.rb +0 -9
  44. data/spec/support/models/model_money.rb +0 -10
  45. data/spec/support/models/model_number.rb +0 -5
  46. data/spec/support/models/model_percent.rb +0 -10
  47. data/spec/support/models/model_slug.rb +0 -6
  48. data/spec/support/models/model_strip.rb +0 -8
  49. data/spec/support/models/rule.rb +0 -4
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Model < ActiveRecord::Base
4
- normalizy :default
5
-
6
- normalizy :block , with: ->(value) { value.upcase }
7
- normalizy :symbol , with: :squish
8
- normalizy :array_symbol , with: [:squish]
9
- normalizy :array_symbols , with: %i[downcase squish]
10
- normalizy :hash_no_args , with: { squish: { ignored: true } }
11
- normalizy :hash_with_args , with: { strip: { side: :left } }
12
- normalizy :module_one_arg , with: Normalizy::Filters::Blacklist
13
- normalizy :module_two_args , with: Normalizy::Filters::Info
14
- normalizy :module_and_block , with: :blacklist, &->(value) { value.upcase }
15
- normalizy :method_with_no_options_field, with: :method_with_no_options
16
- normalizy :method_with_options_field , with: { method_with_options: { key: :value } }
17
- normalizy :native , with: :split
18
- normalizy :multiple , with: :downcase
19
- normalizy :multiple , with: :titleize
20
-
21
- def method_with_options(input, options = {})
22
- [input, options].join ', '
23
- end
24
-
25
- def method_with_no_options(input)
26
- input
27
- end
28
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ModelDate < ActiveRecord::Base
4
- normalizy :date , with: :date
5
- normalizy :date_format, with: { date: { format: '%y/%m/%d' } }
6
- normalizy :date_time_begin, with: { date: { adjust: :begin } }
7
- normalizy :date_time_end, with: { date: { adjust: :end } }
8
- normalizy :date_time_zone, with: { date: { time_zone: 'Brasilia' } }
9
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ModelMoney < ActiveRecord::Base
4
- normalizy :text , with: :money
5
- normalizy :cents_type , with: { money: { type: :cents } }
6
- normalizy :cast_to_i , with: { money: { cast: :to_i } }
7
- normalizy :cast_to_d , with: { money: { cast: :to_d } }
8
- normalizy :cents_type_and_cast_to_f, with: { money: { cast: :to_f, type: :cents } }
9
- normalizy :cents_type_and_cast_to_i, with: { money: { cast: :to_i, type: :cents } }
10
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ModelNumber < ActiveRecord::Base
4
- normalizy :number, with: :number
5
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ModelPercent < ActiveRecord::Base
4
- normalizy :text , with: :percent
5
- normalizy :cents_type , with: { percent: { type: :cents } }
6
- normalizy :cast_to_i , with: { percent: { cast: :to_i } }
7
- normalizy :cast_to_d , with: { percent: { cast: :to_d } }
8
- normalizy :cents_type_and_cast_to_f, with: { percent: { cast: :to_f, type: :cents } }
9
- normalizy :cents_type_and_cast_to_i, with: { percent: { cast: :to_i, type: :cents } }
10
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ModelSlug < ActiveRecord::Base
4
- normalizy :permalink, with: :slug
5
- normalizy :title , with: { slug: { to: :slug } }
6
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ModelStrip < ActiveRecord::Base
4
- normalizy :strip , with: :strip
5
- normalizy :strip_side_both , with: { strip: { side: :both } }
6
- normalizy :strip_side_left , with: { strip: { side: :left } }
7
- normalizy :strip_side_right, with: { strip: { side: :right } }
8
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Rule < ActiveRecord::Base
4
- end