attestor 2.2.0 → 2.2.1

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
  SHA1:
3
- metadata.gz: a3c49413757098c3a6f07dc1148d09e0e5c5abe5
4
- data.tar.gz: e28e906e513608a83ee9d43903a14d8c4887f23d
3
+ metadata.gz: 0b26004a47b4a2f4d72a9835df97dd5e7e27a9ce
4
+ data.tar.gz: adcec1adac536d8631635e7a56a73be453ea69b7
5
5
  SHA512:
6
- metadata.gz: 01204cc6953c5a0d06f65f0d568ea9259ab2e6a15d3e5945d353d67e4bfa14f40b1f822962939d3e7f6b1942a1fb7bb15354a72849cc4bc8a052e798ef43e791
7
- data.tar.gz: dd468cf1fd35facc245a6e142e745282ed856d9c2eacce6ddecbff27d82d1c3fb1395f0d426bfbb644baac368e5c3c2db31cf053a4d2fbf1adf2770e9697c8bb
6
+ metadata.gz: bcd51a252c80d81785a41a02fa1b68483e076b86e14f9c5ec253e1e158ce51c3915e7f45118318add1106b683faf155e9a3cf5b84b32e336c0138c94e6c65345
7
+ data.tar.gz: 640ac4003afe4e893f64f010f27162047804cbbda668a4e3d19e5b9d6c1cda1418e8b11620cd1741b7035f478f4a5743f5107866d30f7489be379e04c4410eeb
data/.travis.yml CHANGED
@@ -1,9 +1,20 @@
1
1
  ---
2
2
  language: ruby
3
+ sudo: false
4
+ cache: bundler
3
5
  bundler_args: --without metrics
4
6
  script: rake test:coverage:run
5
7
  rvm:
8
+ - '1.9.3'
6
9
  - '2.0'
10
+ - '2.1'
11
+ - '2.2'
7
12
  - ruby-head
13
+ - rbx-2 --1.9
8
14
  - rbx-2 --2.0
9
15
  - jruby-9.0.0.0.pre1
16
+ - jruby-head
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ ## v2.2.1 2015-05-31
2
+
3
+ ### Fixed
4
+
5
+ * Bug in calling `Attestor::Policy.new` with a block (gregory)
6
+
7
+ ### Internal
8
+
9
+ * Compatibility to rubies API 1.9.3+ (gregory)
10
+
11
+ [Compare v2.2.0...v2.2.1](https://github.com/nepalez/attestor/compare/v2.2.0...v2.2.1)
data/README.md CHANGED
@@ -40,9 +40,9 @@ Approach
40
40
  Instead of collecting errors inside the object, the module defines two instance methods:
41
41
 
42
42
  * `validate!` raises an exception (`Attestor::InvalidError`), that carries errors outside of the object.
43
- * `validate` - the safe version of `validate!`. It rescues an exception and returns special result object, that carries error info outside of the object.
43
+ * `validate` - the safe version of `validate!`. It rescues from the exception and returns a report object, that carries the exception as well as its error messages.
44
44
 
45
- The object stays untouched (and can be made immutable).
45
+ In both cases the inspected object stays untouched (and can be made immutable).
46
46
 
47
47
  Installation
48
48
  ------------
@@ -66,8 +66,8 @@ Or add it manually:
66
66
  gem install attestor
67
67
  ```
68
68
 
69
- Basic Use
70
- ----------
69
+ Base Use
70
+ --------
71
71
 
72
72
  Declare validation in the same way as ActiveModel's `.validate` method does:
73
73
 
@@ -135,8 +135,6 @@ report.messages # => ["Credit differs from debet by 10"]
135
135
  report.error # => <Attestor::InvalidError ...>
136
136
  ```
137
137
 
138
- Once again, the report collects messages outside of the checked object.
139
-
140
138
  Use of Contexts
141
139
  ---------------
142
140
 
@@ -344,25 +342,14 @@ expect(object.validate).to be_valid
344
342
  expect(object.validate).to be_invalid
345
343
  ```
346
344
 
347
- Latest changes
348
- --------------
349
-
350
- ### Version 2.0.0
351
-
352
- 1. The method `#validate` doesn't raise an error. It returns a validation results report. To raise an exception use the unsafe `#validate!` method (see [Basic Use](#basic-use) for details).
353
-
354
- 2. Policies doesn't have `#valid?` and `#invalid?` methods any longer. Both the methods are removed to `#validate` report.
355
-
356
- ### Version 2.1.0
357
-
358
345
  Compatibility
359
346
  -------------
360
347
 
361
- Tested under rubies compatible to rubies with API 2.0+:
348
+ Tested under rubies compatible to rubies with API 1.9.3+:
362
349
 
363
- * MRI 2.0+
364
- * Rubinius-2 (mode 2.0)
365
- * JRuby 9000+ (mode 2.0+)
350
+ * MRI 1.9.3+
351
+ * Rubinius-2 (modes 1.9+)
352
+ * JRuby 9.0.0.0.pre1+
366
353
 
367
354
  Uses [RSpec] 3.0+ for testing and [hexx-suit] for dev/test tools collection.
368
355
 
@@ -372,15 +359,18 @@ Uses [RSpec] 3.0+ for testing and [hexx-suit] for dev/test tools collection.
372
359
  Contributing
373
360
  ------------
374
361
 
375
- * Fork the project.
376
362
  * Read the [STYLEGUIDE](config/metrics/STYLEGUIDE).
377
- * Make your feature addition or bug fix.
378
- * Add tests for it. This is important so I don't break it in a
379
- future version unintentionally.
380
- * Commit, do not mess with Rakefile or version
381
- (if you want to have your own version, that is fine but bump version
382
- in a commit by itself I can ignore when I pull)
383
- * Send me a pull request. Bonus points for topic branches.
363
+ * Fork the project
364
+ * Create your feature branch (`git checkout -b my-new-feature`)
365
+ * Add tests for it
366
+ * Commit your changes (`git commit -am '[UPDATE] Add some feature'`)
367
+ * Push to the branch (`git push origin my-new-feature`)
368
+ * Create a new Pull Request
369
+
370
+ Latest Changes
371
+ --------------
372
+
373
+ See the [CHANGELOG](CHANGELOG.md)
384
374
 
385
375
  License
386
376
  -------
@@ -32,7 +32,7 @@ module Attestor
32
32
  def self.new(*attributes, &block)
33
33
  Struct.new(*attributes) do
34
34
  include Policy
35
- instance_eval(&block) if block_given?
35
+ class_eval(&block) if block_given?
36
36
  end
37
37
  end
38
38
 
@@ -128,8 +128,8 @@ module Attestor
128
128
  # @param [Proc] block
129
129
  #
130
130
  # @return [undefined]
131
- def validations(**options, &block)
132
- Context.new(self, options).instance_eval(&block) if block_given?
131
+ def validations(*options, &block)
132
+ Context.new(self, Hash[*options]).instance_eval(&block) if block_given?
133
133
  end
134
134
 
135
135
  end # module ClassMethods
@@ -4,6 +4,6 @@ module Attestor
4
4
 
5
5
  # The semantic version of the module.
6
6
  # @see http://semver.org/ Semantic versioning 2.0
7
- VERSION = "2.2.0".freeze
7
+ VERSION = "2.2.1".freeze
8
8
 
9
9
  end # module Attestor
@@ -37,8 +37,14 @@ describe Attestor::Policy do
37
37
  end
38
38
 
39
39
  it "yields the block in class scope" do
40
- subject = described_class.new(:foo) { attr_reader :bar }
40
+ subject = described_class.new(:foo) do
41
+ attr_reader :bar
42
+ def foobar; end
43
+ def self.barfoo; end
44
+ end
41
45
  expect(subject.new(:baz)).to respond_to :bar
46
+ expect(subject.new(:baz)).to respond_to :foobar
47
+ expect(subject.new(:baz).class).to respond_to :barfoo
42
48
  end
43
49
 
44
50
  end # describe .new
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attestor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: extlib
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hexx-rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.4'
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
40
  version: '0.4'
41
41
  description: Validations for immutable Ruby objects
@@ -46,13 +46,14 @@ extra_rdoc_files:
46
46
  - README.md
47
47
  - LICENSE
48
48
  files:
49
- - .coveralls.yml
50
- - .gitignore
51
- - .metrics
52
- - .rspec
53
- - .rubocop.yml
54
- - .travis.yml
55
- - .yardopts
49
+ - ".coveralls.yml"
50
+ - ".gitignore"
51
+ - ".metrics"
52
+ - ".rspec"
53
+ - ".rubocop.yml"
54
+ - ".travis.yml"
55
+ - ".yardopts"
56
+ - CHANGELOG.md
56
57
  - Gemfile
57
58
  - Guardfile
58
59
  - LICENSE
@@ -121,12 +122,12 @@ require_paths:
121
122
  - lib
122
123
  required_ruby_version: !ruby/object:Gem::Requirement
123
124
  requirements:
124
- - - ~>
125
+ - - "~>"
125
126
  - !ruby/object:Gem::Version
126
127
  version: '2.0'
127
128
  required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  requirements:
129
- - - '>='
130
+ - - ">="
130
131
  - !ruby/object:Gem::Version
131
132
  version: '0'
132
133
  requirements: []
@@ -137,24 +138,24 @@ specification_version: 4
137
138
  summary: Validations for immutable Ruby objects
138
139
  test_files:
139
140
  - spec/spec_helper.rb
140
- - spec/tests/policy_spec.rb
141
141
  - spec/tests/invalid_error_spec.rb
142
- - spec/tests/validations_spec.rb
143
- - spec/tests/report_spec.rb
144
- - spec/tests/validations/context_spec.rb
145
- - spec/tests/validations/message_spec.rb
146
- - spec/tests/validations/validator_spec.rb
147
- - spec/tests/validations/reporter_spec.rb
148
- - spec/tests/validations/delegator_spec.rb
149
- - spec/tests/validations/validators_spec.rb
150
- - spec/tests/policy/or_spec.rb
151
- - spec/tests/policy/factory_spec.rb
152
- - spec/tests/policy/and_spec.rb
153
142
  - spec/tests/policy/xor_spec.rb
154
143
  - spec/tests/policy/negator_spec.rb
155
- - spec/tests/policy/not_spec.rb
144
+ - spec/tests/policy/factory_spec.rb
156
145
  - spec/tests/policy/node_spec.rb
146
+ - spec/tests/policy/and_spec.rb
147
+ - spec/tests/policy/not_spec.rb
148
+ - spec/tests/policy/or_spec.rb
157
149
  - spec/tests/rspec_spec.rb
158
- - spec/features/example_spec.rb
150
+ - spec/tests/validations/context_spec.rb
151
+ - spec/tests/validations/validator_spec.rb
152
+ - spec/tests/validations/delegator_spec.rb
153
+ - spec/tests/validations/message_spec.rb
154
+ - spec/tests/validations/reporter_spec.rb
155
+ - spec/tests/validations/validators_spec.rb
156
+ - spec/tests/policy_spec.rb
157
+ - spec/tests/validations_spec.rb
158
+ - spec/tests/report_spec.rb
159
159
  - spec/support/policies.rb
160
+ - spec/features/example_spec.rb
160
161
  has_rdoc: