cooperator 0.1.0 → 0.1.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: 6671fcd41b0cea041ba1f0191cd5760d1cf2bab3
4
- data.tar.gz: 9beb667615a70908cecba636f6ae3b0a80d9d119
3
+ metadata.gz: 3c4488b6b7b963727bdc7fd71b29fed2a6a689df
4
+ data.tar.gz: ba79736c55a012ae4c9e388cf686615a3d5d2de8
5
5
  SHA512:
6
- metadata.gz: e2779ddbd074fc07515eeb3ec9494f2367463627748826df8a71747eacb1dcd96c12e5e253ba94cb7d77ba79f43cfca38619af734c60b317fbf3d40c1db18fd3
7
- data.tar.gz: fcc74dba7a8c3e156ffd3095a8c521b41fb22c26a42bba8054dd0e38f393b130d9bb9c1a195b452d643bb726610777b1b46b97d661da08735dbf9f4bf6236e8a
6
+ metadata.gz: 6955b1fcd5dd16d7a52b5ceb5533188c597e1753a3c0390a2f63a7b1cff94776d41fd567488614fa60e69ee201e34fcbb3eb6025aa5c13412f827a37b690c24d
7
+ data.tar.gz: 8795e69ff4dda864bb1af0adbad1b91efeb058b1fb56c6e0b4c28f6123a44dc11d9777507b682afc06e557409b4eec3cef22131edbdc4aad85774894ed949466
@@ -9,16 +9,16 @@ module Cooperator
9
9
  end
10
10
 
11
11
  def errors
12
- @_errors ||= []
12
+ @_errors ||= Hash.new { |h, k| h[k] = [] }
13
13
  end
14
14
 
15
15
  def success!
16
16
  self._failure = false
17
17
  end
18
18
 
19
- def failure!(*args)
20
- args.each do |error|
21
- errors.push error
19
+ def failure!(messages = {})
20
+ messages.each do |key, message|
21
+ errors[key].push message
22
22
  end
23
23
 
24
24
  self._failure = true
@@ -1,3 +1,3 @@
1
1
  module Cooperator
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/spec/context.rb CHANGED
@@ -15,10 +15,10 @@ spec '.new accepts a hash' do
15
15
  assert context.name, :==, 'Apple'
16
16
  end
17
17
 
18
- spec '#errors is an array' do
18
+ spec '#errors is a hash of error messages' do
19
19
  context = Cooperator::Context.new
20
20
 
21
- assert context.errors, :is_a?, Array
21
+ assert context.errors, :is_a?, Hash
22
22
  end
23
23
 
24
24
  spec '#success! marks the context as a success' do
@@ -37,11 +37,11 @@ spec '#failure! marks the context as a failure' do
37
37
  refute context, :success?
38
38
  end
39
39
 
40
- spec '#failure! accepts an error message' do
40
+ spec '#failure! accepts an error key and message' do
41
41
  context = Cooperator::Context.new
42
- context.failure! 'Failure!'
42
+ context.failure! action: 'Failure!'
43
43
 
44
- assert context.errors, :include?, 'Failure!'
44
+ assert context.errors, :==, action: ['Failure!']
45
45
  end
46
46
 
47
47
  spec '#include? returns true for an existing attribute' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cooperator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erol Fornoles
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.2.0
82
+ rubygems_version: 2.2.2
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Simple cooperative interactors for Ruby