normalizy 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -28
- data/README.md +22 -16
- data/lib/normalizy/filters/money.rb +2 -2
- data/lib/normalizy/filters/percent.rb +2 -2
- data/lib/normalizy/version.rb +1 -1
- metadata +27 -94
- data/spec/normalizy/config/add_spec.rb +0 -21
- data/spec/normalizy/config/alias_spec.rb +0 -29
- data/spec/normalizy/config/default_filters_spec.rb +0 -19
- data/spec/normalizy/config/initialize_spec.rb +0 -16
- data/spec/normalizy/config/normalizy_aliases_spec.rb +0 -9
- data/spec/normalizy/extensions/filters/date_spec.rb +0 -23
- data/spec/normalizy/extensions/filters/money_spec.rb +0 -38
- data/spec/normalizy/extensions/filters/number_spec.rb +0 -9
- data/spec/normalizy/extensions/filters/percent_spec.rb +0 -30
- data/spec/normalizy/extensions/filters/slug_spec.rb +0 -14
- data/spec/normalizy/extensions/filters/strip_spec.rb +0 -21
- data/spec/normalizy/extensions/model_spec.rb +0 -107
- data/spec/normalizy/extensions/normalizy_rules_spec.rb +0 -198
- data/spec/normalizy/filters/date_spec.rb +0 -72
- data/spec/normalizy/filters/money_spec.rb +0 -282
- data/spec/normalizy/filters/number_spec.rb +0 -33
- data/spec/normalizy/filters/percent_spec.rb +0 -168
- data/spec/normalizy/filters/slug_spec.rb +0 -24
- data/spec/normalizy/filters/strip_spec.rb +0 -13
- data/spec/normalizy/normalizy/configure_spec.rb +0 -11
- data/spec/normalizy/rspec/matcher/description_spec.rb +0 -27
- data/spec/normalizy/rspec/matcher/failure_message_spec.rb +0 -48
- data/spec/normalizy/rspec/matcher/failure_message_when_negated_spec.rb +0 -30
- data/spec/normalizy/rspec/matcher/from_spec.rb +0 -19
- data/spec/normalizy/rspec/matcher/matches_spec.rb +0 -117
- data/spec/normalizy/rspec/matcher/to_spec.rb +0 -19
- data/spec/rails_helper.rb +0 -9
- data/spec/support/common.rb +0 -11
- data/spec/support/db/schema.rb +0 -83
- data/spec/support/filters/blacklist.rb +0 -11
- data/spec/support/filters/block.rb +0 -11
- data/spec/support/filters/info.rb +0 -11
- data/spec/support/models/alias.rb +0 -7
- data/spec/support/models/match.rb +0 -9
- data/spec/support/models/model.rb +0 -28
- data/spec/support/models/model_date.rb +0 -9
- data/spec/support/models/model_money.rb +0 -10
- data/spec/support/models/model_number.rb +0 -5
- data/spec/support/models/model_percent.rb +0 -10
- data/spec/support/models/model_slug.rb +0 -6
- data/spec/support/models/model_strip.rb +0 -8
- 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,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,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
|
data/spec/support/models/rule.rb
DELETED