normalizr 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03dfb54450a14ca113c1e45f01f0b7f14356e6f12f6cfa90dddb0d2f49f85635
4
- data.tar.gz: d72f8210ab5e58c404efb64e6854de2f48a342f2388cd4ca5d3931fd07b59f47
3
+ metadata.gz: d46a399a42b6686eb841774af8c65fe00a01440b8b987babae87b43c8f3ea557
4
+ data.tar.gz: cae7060a66923fe7a5f208d7e7b5649d3d49c1c02780361c88400eef3f451ae7
5
5
  SHA512:
6
- metadata.gz: 2627756373049880c2c048b738354282df325bcdf1e56d875cd702a8ecd5fc73b63fda8f300d0c2ce2738fc0777774e8a5f993a37bd598cfac5016fba76ae292
7
- data.tar.gz: 2a9ec23470882aefb1c8a2b85aa2ba280ba1d490cea311eb4986a6f30382a9e73916b008b92aaed4c9ee5b5a8231b4a0a5c2f0bd251c7f9373330c714a885b4a
6
+ metadata.gz: 89c5535023a0c3119f959f782c112eb70c1525ba7dc3e82eb45bad8d9702b393df73683af9a3ca5f1d1a085a4888f80a9c0142eb3def7f3c0c76ea9def169895
7
+ data.tar.gz: e6a67050e0f4d1761db25b0fd72cbaf4b4f241489016a3076cfcb5768cf8290cf9f69af2e774aa575d8ee25b07397eecd4ad843fc35e133293508732ab864bd6
@@ -1,15 +1,12 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.0.0
5
- - 2.1.8
6
- - 2.2.4
7
- - 2.3.0
4
+ - 2.5.7
5
+ - 2.6.5
6
+ - 2.7.0
8
7
  gemfile:
9
- - gemfiles/activerecord-3.2.x.gemfile
10
- - gemfiles/activerecord-4.0.x.gemfile
11
- - gemfiles/activerecord-4.1.x.gemfile
12
- - gemfiles/activerecord-4.2.x.gemfile
8
+ - gemfiles/activerecord-5.2.x.gemfile
9
+ - gemfiles/activerecord-6.0.x.gemfile
13
10
  addons:
14
11
  code_climate:
15
12
  repo_token: 1cac54041089115a5bf218169b62c76c8b87a5896f5aa973f89637a8553c0376
@@ -1,3 +1,7 @@
1
+ ### 0.4.0 / 2020-01-20
2
+
3
+ * Support Ruby 2.7 (@badlamer)
4
+
1
5
  ### 0.3.1 / 2018-03-22
2
6
 
3
7
  * Fix conditional normalization
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activerecord', '~> 3.2.0'
4
- gem 'mongoid', '~> 3.0'
3
+ gem 'activerecord', '~> 5.2.0'
4
+ gem 'mongoid', '~> 6.0'
5
5
  gem 'codeclimate-test-reporter', require: false
6
6
 
7
7
  gemspec path: '../'
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activerecord', '~> 4.0.0'
4
- gem 'mongoid', '~> 4.0'
3
+ gem 'activerecord', '~> 6.0.0'
4
+ gem 'mongoid', '~> 7.0'
5
5
  gem 'codeclimate-test-reporter', require: false
6
6
 
7
7
  gemspec path: '../'
@@ -15,8 +15,12 @@ module Normalizr
15
15
  @configuration ||= Configuration.new
16
16
  end
17
17
 
18
- def configure
19
- configuration.instance_eval &Proc.new
18
+ def configure(&block)
19
+ unless block_given?
20
+ raise ArgumentError, '.configure must be called with a block'
21
+ end
22
+
23
+ configuration.instance_eval(&block)
20
24
  end
21
25
 
22
26
  def find(name)
@@ -13,8 +13,8 @@ module Normalizr
13
13
  define_method :"#{method}=" do |value|
14
14
  condition_lambda = -> condition { Proc === condition ? instance_exec(&condition) : send(condition) }
15
15
 
16
- positive = options.positive_condition.all? &condition_lambda
17
- negative = options.negative_condition.none? &condition_lambda
16
+ positive = options.positive_condition.all?(&condition_lambda)
17
+ negative = options.negative_condition.none?(&condition_lambda)
18
18
 
19
19
  if positive && negative
20
20
  value = Normalizr.normalize(value, *options.before)
@@ -14,8 +14,12 @@ module Normalizr
14
14
  self.default_normalizers = normalizers
15
15
  end
16
16
 
17
- def add(name)
18
- normalizers[name] = Proc.new
17
+ def add(name, &block)
18
+ unless block_given?
19
+ raise ArgumentError, '#add must be called with a block'
20
+ end
21
+
22
+ normalizers[name] = block
19
23
  end
20
24
  end
21
25
  end
@@ -1,3 +1,3 @@
1
1
  module Normalizr
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.required_ruby_version = '>= 2.0'
20
20
 
21
21
  spec.add_development_dependency 'pry'
22
- spec.add_development_dependency 'bundler', '~> 1.5'
22
+ spec.add_development_dependency 'bundler'
23
23
  spec.add_development_dependency 'rake'
24
24
  spec.add_development_dependency 'rspec', '~> 3.0'
25
25
  spec.add_development_dependency 'rspec-its'
@@ -5,17 +5,27 @@ describe Normalizr::Configuration do
5
5
  subject { configuration }
6
6
 
7
7
  describe '#default' do
8
- before { configuration.default(:blank) }
9
- its(:default_normalizers) { should == [:blank] }
8
+ it 'accpets default normalizers' do
9
+ subject.default(:blank)
10
+ expect(subject.default_normalizers).to eq([:blank])
11
+ end
10
12
  end
11
13
 
12
14
  describe '#normalizer_names' do
13
- before { allow(configuration).to receive(:normalizers) {{ blank: proc {}}}}
14
- its(:normalizer_names) { should == [:blank] }
15
+ it 'returns normalized names' do
16
+ allow(subject).to receive(:normalizers) {{ blank: proc {}}}
17
+ expect(subject.normalizer_names).to eq([:blank])
18
+ end
15
19
  end
16
20
 
17
21
  describe '#add' do
18
- before { configuration.add(:blank) {}}
19
- its(:normalizer_names) { should include(:blank) }
22
+ it 'requires block' do
23
+ expect { subject.add(:blank) }.to raise_error(ArgumentError)
24
+ end
25
+
26
+ it 'accepts block' do
27
+ subject.add(:blank) {}
28
+ expect(subject.normalizer_names).to include(:blank)
29
+ end
20
30
  end
21
31
  end
@@ -25,7 +25,7 @@ describe Book do
25
25
  before do
26
26
  @book = Book.create!(title: 'Original Title')
27
27
  @book2 = Book.find(@book.id)
28
- @book2.update_attributes(title: 'New Title')
28
+ @book2.update(title: 'New Title')
29
29
  end
30
30
 
31
31
  it "should reflect the change when the record is reloaded" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalizr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-22 00:00:00.000000000 Z
11
+ date: 2020-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.5'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -151,10 +151,8 @@ files:
151
151
  - LICENSE.txt
152
152
  - README.md
153
153
  - Rakefile
154
- - gemfiles/activerecord-3.2.x.gemfile
155
- - gemfiles/activerecord-4.0.x.gemfile
156
- - gemfiles/activerecord-4.1.x.gemfile
157
- - gemfiles/activerecord-4.2.x.gemfile
154
+ - gemfiles/activerecord-5.2.x.gemfile
155
+ - gemfiles/activerecord-6.0.x.gemfile
158
156
  - lib/normalizr.rb
159
157
  - lib/normalizr/concern.rb
160
158
  - lib/normalizr/configuration.rb
@@ -212,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
210
  - !ruby/object:Gem::Version
213
211
  version: '0'
214
212
  requirements: []
215
- rubyforge_project:
216
- rubygems_version: 2.7.6
213
+ rubygems_version: 3.0.3
217
214
  signing_key:
218
215
  specification_version: 4
219
216
  summary: Writer methods parameters normalization
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 4.1.0'
4
- gem 'mongoid', '~> 4.0'
5
- gem 'codeclimate-test-reporter', require: false
6
-
7
- gemspec path: '../'
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 4.2.0'
4
- gem 'mongoid', '~> 4.0'
5
- gem 'codeclimate-test-reporter', require: false
6
-
7
- gemspec path: '../'