dbd 0.0.18 → 0.0.19

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: 13af9d019e4b27d4833ee8630d0c5bf039a7aaab
4
- data.tar.gz: ed9e32664574ea16ae259b5ba86e22b4692a8609
3
+ metadata.gz: 74d54382f08bbd348679cb10c1c8b91f3be990cf
4
+ data.tar.gz: b566258aea1a3a5fd2086094cce17d7459989cc0
5
5
  SHA512:
6
- metadata.gz: 97555491b38015176f6e0fbef78653203da669090da4e0d778e85c7045138e106f10558b02c526db7c97166f3da46ae90917f7be0557ac6e36ff1210972d5a78
7
- data.tar.gz: 01a111a1f113c469d95749dcdc68ddaaf806295be267ca47c14bcae4a82e013837ae79160f8eabb4e05f223a73c02346a1f03d6dd55f4a4437004d3ad6939d05
6
+ metadata.gz: 3d7eb71352a57bce730c5f2198d26bd30e1c5a5ab67bbe9cca9d85351cd0051d91522e42bdd4233049a20e3930a956508efe15f9161b534381ced3f23362eb5b
7
+ data.tar.gz: 1c73a36ccfda7a251914d65d84e8c427f72eaf02a007e69b1f52a3f5d324e8fb8bf603a06aaf16cf1b3db632f6385b90d86430df576c33d0644409711f242c9a
@@ -112,3 +112,8 @@
112
112
  ======
113
113
 
114
114
  * add Fact::Collection#subjects (all subjects for contexts and resources)
115
+
116
+ 0.0.19 (4 Sept 2013)
117
+ ======
118
+
119
+ * Resource|Context << also accepts an array of Facts|ContextFacts
@@ -21,13 +21,18 @@ module Dbd
21
21
  end
22
22
 
23
23
  ##
24
- # Add a ContextFact (strictly only a ContextFact).
24
+ # Add a ContextFact (strictly only a ContextFact) or recursive collection of ContextFacts
25
25
  #
26
26
  # Side effect on the context_fact argument:
27
27
  # * if it has no subject, the subject is set in the context_fact
28
28
  # * if is has the same subject as the resource, added unchanged.
29
29
  # * if it has a different subject, a SubjectError is raised.
30
- def <<(context_fact)
30
+ #
31
+ # NOTE: this implementation is really only here for the documentation
32
+ #
33
+ # @param [ContextFact, #each] context_fact_collection a recursive collection of ContextFacts
34
+ # @return [Context] self
35
+ def <<(context_fact_collection)
31
36
  super
32
37
  end
33
38
 
@@ -97,7 +97,6 @@ module Dbd
97
97
  end
98
98
 
99
99
  end
100
-
101
100
  end
102
101
  end
103
102
  end
@@ -54,7 +54,7 @@ module Dbd
54
54
  end
55
55
 
56
56
  ##
57
- # Add a Fact (strictly not a ContextFact)
57
+ # Add a Fact (strictly not a ContextFact) or recursive collection of facts
58
58
  #
59
59
  # Side effects on subject and context_subject:
60
60
  # * if it has no subject, the subject is set (this modifies the fact !)
@@ -64,11 +64,17 @@ module Dbd
64
64
  # * if it has no context_subject, the context_subject is set (this modifies the fact !)
65
65
  # * if is has the same context_subject as the resource, added unchanged.
66
66
  # * if it has a different context_subject, a ContextError is raised.
67
- def <<(fact)
68
- assert_fact_or_context_fact(fact)
69
- set_fact_subject!(fact)
70
- set_fact_context_subject!(fact)
71
- super(fact)
67
+ #
68
+ # @param [Fact, #each] fact_collection a recursive collection of Facts
69
+ # @return [Resource] self
70
+ def <<(fact_collection)
71
+ fact_collection.each_recursively do |fact|
72
+ assert_fact_or_context_fact(fact)
73
+ set_fact_subject!(fact)
74
+ set_fact_context_subject!(fact)
75
+ super(fact)
76
+ end
77
+ self
72
78
  end
73
79
 
74
80
  private
@@ -1,3 +1,3 @@
1
1
  module Dbd
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
@@ -6,40 +6,6 @@ module Dbd
6
6
  let(:context) { described_class.new }
7
7
  let(:context_subject) { context.subject }
8
8
 
9
- describe '.new' do
10
- describe 'without a subject argument' do
11
- it 'has created a new subject' do
12
- context.subject.should be_a(described_class.new_subject.class)
13
- end
14
- end
15
-
16
- describe 'with a subject argument' do
17
- it 'has stored the resource_subject' do
18
- described_class.new(subject: context_subject).subject.
19
- should == context_subject
20
- end
21
- end
22
-
23
- describe 'with a context_subject argument' do
24
- it 'raises an ContextError' do
25
- lambda{ described_class.new(context_subject: context_subject) }.
26
- should raise_error(ArgumentError)
27
- end
28
- end
29
- end
30
-
31
- describe 'context_subject' do
32
- it 'raises NoMethodError when called' do
33
- lambda{ context.context_subject }.should raise_error(NoMethodError)
34
- end
35
- end
36
-
37
- describe 'TestFactories::Context' do
38
- it '.context works' do
39
- TestFactories::Context.context
40
- end
41
- end
42
-
43
9
  describe 'the collection' do
44
10
 
45
11
  let(:context_fact_visibility) { TestFactories::ContextFact.visibility } # nil subject
@@ -52,6 +18,15 @@ module Dbd
52
18
  context.first.subject.should == context_subject
53
19
  end
54
20
 
21
+ it 'works with an array of contexts_facts' do
22
+ context << [context_visibility_with_correct_subject]
23
+ context.first.subject.should == context_subject
24
+ end
25
+
26
+ it 'returns self' do
27
+ (context << [context_visibility_with_correct_subject]).should be_a(Context)
28
+ end
29
+
55
30
  it 'with incorrect subject it raises SetOnceError' do
56
31
  lambda{ context << context_visibility_with_incorrect_subject }.
57
32
  should raise_error(RubyPeterV::SetOnceError),
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module Dbd
4
+ describe Context do
5
+
6
+ let(:context) { described_class.new }
7
+ let(:context_subject) { context.subject }
8
+
9
+ describe '.new' do
10
+ describe 'without a subject argument' do
11
+ it 'has created a new subject' do
12
+ context.subject.should be_a(described_class.new_subject.class)
13
+ end
14
+ end
15
+
16
+ describe 'with a subject argument' do
17
+ it 'has stored the resource_subject' do
18
+ described_class.new(subject: context_subject).subject.
19
+ should == context_subject
20
+ end
21
+ end
22
+
23
+ describe 'with a context_subject argument' do
24
+ it 'raises an ContextError' do
25
+ lambda{ described_class.new(context_subject: context_subject) }.
26
+ should raise_error(ArgumentError)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe 'context_subject' do
32
+ it 'raises NoMethodError when called' do
33
+ lambda{ context.context_subject }.should raise_error(NoMethodError)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module Dbd
4
+ describe Context do
5
+
6
+ let(:context) { described_class.new }
7
+ let(:context_subject) { context.subject }
8
+
9
+ describe 'TestFactories::Context' do
10
+ it '.context works' do
11
+ TestFactories::Context.context
12
+ end
13
+ end
14
+ end
15
+ end
@@ -30,6 +30,17 @@ module Dbd
30
30
  resource.size.should == 2
31
31
  end
32
32
 
33
+ it 'works with an array facts' do
34
+ resource << [fact_without_subject, fact_with_context]
35
+ resource.size.should == 2
36
+ resource.first.should == fact_without_subject
37
+ resource.last.should == fact_with_context
38
+ end
39
+
40
+ it 'returns self' do
41
+ (resource << [fact_without_subject, fact_with_context]).should be_a(Resource)
42
+ end
43
+
33
44
  it 'complains if a context_subject is added' do
34
45
  lambda{ resource << context_fact_visibility }.should raise_error(
35
46
  ArgumentError,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenabeele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-02 00:00:00.000000000 Z
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -203,7 +203,9 @@ files:
203
203
  - lib/dbd/resource.rb
204
204
  - lib/dbd/time_stamp.rb
205
205
  - lib/dbd/version.rb
206
- - spec/lib/dbd/context/context_spec.rb
206
+ - spec/lib/dbd/context/collection_spec.rb
207
+ - spec/lib/dbd/context/new_spec.rb
208
+ - spec/lib/dbd/context/test_factories_spec.rb
207
209
  - spec/lib/dbd/context_fact/methods_spec.rb
208
210
  - spec/lib/dbd/context_fact/new_spec.rb
209
211
  - spec/lib/dbd/context_fact/test_factories_spec.rb
@@ -269,7 +271,9 @@ signing_key:
269
271
  specification_version: 4
270
272
  summary: A data store that (almost) never forgets
271
273
  test_files:
272
- - spec/lib/dbd/context/context_spec.rb
274
+ - spec/lib/dbd/context/collection_spec.rb
275
+ - spec/lib/dbd/context/new_spec.rb
276
+ - spec/lib/dbd/context/test_factories_spec.rb
273
277
  - spec/lib/dbd/context_fact/methods_spec.rb
274
278
  - spec/lib/dbd/context_fact/new_spec.rb
275
279
  - spec/lib/dbd/context_fact/test_factories_spec.rb