compo 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 +4 -4
- data/CHANGELOG +8 -0
- data/lib/compo/branches/array.rb +17 -0
- data/lib/compo/branches/branch.rb +35 -0
- data/lib/compo/branches/constant.rb +34 -0
- data/lib/compo/branches/hash.rb +17 -0
- data/lib/compo/branches/leaf.rb +15 -0
- data/lib/compo/branches.rb +15 -0
- data/lib/compo/composites/array.rb +105 -0
- data/lib/compo/composites/composite.rb +183 -0
- data/lib/compo/composites/hash.rb +72 -0
- data/lib/compo/composites/leaf.rb +64 -0
- data/lib/compo/composites/parentless.rb +133 -0
- data/lib/compo/composites.rb +20 -0
- data/lib/compo/finders/url.rb +166 -0
- data/lib/compo/finders.rb +10 -0
- data/lib/compo/mixins/movable.rb +55 -0
- data/lib/compo/mixins/parent_tracker.rb +74 -0
- data/lib/compo/mixins/url_referenceable.rb +70 -0
- data/lib/compo/mixins.rb +9 -0
- data/lib/compo/version.rb +1 -1
- data/lib/compo.rb +4 -21
- data/spec/array_branch_spec.rb +4 -2
- data/spec/array_composite_shared_examples.rb +2 -2
- data/spec/array_composite_spec.rb +1 -1
- data/spec/branch_shared_examples.rb +38 -5
- data/spec/branch_spec.rb +1 -1
- data/spec/composite_shared_examples.rb +1 -1
- data/spec/composite_spec.rb +1 -1
- data/spec/constant_branch_spec.rb +18 -0
- data/spec/hash_branch_spec.rb +4 -2
- data/spec/hash_composite_shared_examples.rb +3 -3
- data/spec/hash_composite_spec.rb +1 -1
- data/spec/leaf_branch_spec.rb +9 -0
- data/spec/{null_composite_shared_examples.rb → leaf_composite_shared_examples.rb} +1 -1
- data/spec/leaf_composite_spec.rb +7 -0
- data/spec/movable_shared_examples.rb +3 -3
- data/spec/movable_spec.rb +1 -1
- data/spec/parent_tracker_spec.rb +2 -15
- data/spec/parentless_spec.rb +2 -2
- data/spec/url_finder_shared_examples.rb +104 -0
- data/spec/url_finder_spec.rb +25 -114
- data/spec/url_referenceable_spec.rb +1 -1
- metadata +30 -21
- data/lib/compo/array_branch.rb +0 -16
- data/lib/compo/array_composite.rb +0 -103
- data/lib/compo/branch.rb +0 -18
- data/lib/compo/composite.rb +0 -181
- data/lib/compo/hash_branch.rb +0 -17
- data/lib/compo/hash_composite.rb +0 -70
- data/lib/compo/leaf.rb +0 -14
- data/lib/compo/movable.rb +0 -53
- data/lib/compo/null_composite.rb +0 -62
- data/lib/compo/parent_tracker.rb +0 -80
- data/lib/compo/parentless.rb +0 -131
- data/lib/compo/url_finder.rb +0 -164
- data/lib/compo/url_referenceable.rb +0 -68
- data/spec/leaf_spec.rb +0 -9
- data/spec/null_composite_spec.rb +0 -7
data/spec/branch_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'compo'
|
|
3
3
|
shared_examples 'a removal of a child from its parent' do
|
4
4
|
it 'calls #update_parent on the child with a Parentless' do
|
5
5
|
expect(child).to receive(:update_parent).once do |parent, _|
|
6
|
-
expect(parent).to be_a(Compo::Parentless)
|
6
|
+
expect(parent).to be_a(Compo::Composites::Parentless)
|
7
7
|
end
|
8
8
|
op.call
|
9
9
|
end
|
data/spec/composite_spec.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'compo'
|
3
|
+
require 'branch_shared_examples'
|
4
|
+
require 'leaf_composite_shared_examples'
|
5
|
+
|
6
|
+
describe Compo::Branches::Constant do
|
7
|
+
let(:value) { 3.141592653 }
|
8
|
+
subject { Compo::Branches::Constant.new(value) }
|
9
|
+
|
10
|
+
it_behaves_like 'a branch'
|
11
|
+
it_behaves_like 'a leaf composite'
|
12
|
+
|
13
|
+
describe '#value' do
|
14
|
+
it 'returns the constant value' do
|
15
|
+
expect(subject.value).to eq(value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/hash_branch_spec.rb
CHANGED
@@ -3,7 +3,9 @@ require 'compo'
|
|
3
3
|
require 'branch_shared_examples'
|
4
4
|
require 'hash_composite_shared_examples'
|
5
5
|
|
6
|
-
describe Compo::
|
7
|
-
it_behaves_like 'a branch'
|
6
|
+
describe Compo::Branches::Hash do
|
7
|
+
it_behaves_like 'a branch with children' do
|
8
|
+
let(:initial_ids) { %w(a b) }
|
9
|
+
end
|
8
10
|
it_behaves_like 'a hash composite'
|
9
11
|
end
|
@@ -38,7 +38,7 @@ shared_examples 'a hash composite' do
|
|
38
38
|
|
39
39
|
it 'calls #update_parent on the old child with a Parentless' do
|
40
40
|
expect(child1).to receive(:update_parent).once do |parent, _|
|
41
|
-
expect(parent).to be_a(Compo::Parentless)
|
41
|
+
expect(parent).to be_a(Compo::Composites::Parentless)
|
42
42
|
end
|
43
43
|
subject.add(:a, child2)
|
44
44
|
end
|
@@ -91,7 +91,7 @@ shared_examples 'a hash composite' do
|
|
91
91
|
|
92
92
|
it 'calls #update_parent on the child with a Parentless' do
|
93
93
|
expect(child1).to receive(:update_parent).once do |parent, _|
|
94
|
-
expect(parent).to be_a(Compo::Parentless)
|
94
|
+
expect(parent).to be_a(Compo::Composites::Parentless)
|
95
95
|
end
|
96
96
|
subject.remove(child1)
|
97
97
|
end
|
@@ -139,7 +139,7 @@ shared_examples 'a hash composite' do
|
|
139
139
|
|
140
140
|
it 'calls #update_parent on the child with a Parentless' do
|
141
141
|
expect(child1).to receive(:update_parent).once do |parent, _|
|
142
|
-
expect(parent).to be_a(Compo::Parentless)
|
142
|
+
expect(parent).to be_a(Compo::Composites::Parentless)
|
143
143
|
end
|
144
144
|
subject.remove_id(:a)
|
145
145
|
end
|
data/spec/hash_composite_spec.rb
CHANGED
@@ -46,7 +46,7 @@ shared_examples 'a movable object' do
|
|
46
46
|
let(:new_parent) { nil }
|
47
47
|
|
48
48
|
context 'and the Movable has no parent' do
|
49
|
-
let(:old_parent) { Compo::Parentless.new }
|
49
|
+
let(:old_parent) { Compo::Composites::Parentless.new }
|
50
50
|
|
51
51
|
it_behaves_like 'a normal call to #move_to' do
|
52
52
|
let(:to) { new_parent }
|
@@ -69,7 +69,7 @@ shared_examples 'a movable object' do
|
|
69
69
|
let(:add_result) { nil }
|
70
70
|
|
71
71
|
context 'and the Movable has no parent' do
|
72
|
-
let(:old_parent) { Compo::Parentless.new }
|
72
|
+
let(:old_parent) { Compo::Composites::Parentless.new }
|
73
73
|
|
74
74
|
it_behaves_like 'a normal call to #move_to' do
|
75
75
|
let(:to) { new_parent }
|
@@ -111,7 +111,7 @@ shared_examples 'a movable object' do
|
|
111
111
|
|
112
112
|
context 'when the receiving parent allows the Movable to be added' do
|
113
113
|
context 'and the Movable has no parent' do
|
114
|
-
let(:old_parent) { Compo::Parentless.new }
|
114
|
+
let(:old_parent) { Compo::Composites::Parentless.new }
|
115
115
|
|
116
116
|
it_behaves_like 'a normal call to #move_to' do
|
117
117
|
let(:to) { new_parent }
|
data/spec/movable_spec.rb
CHANGED
data/spec/parent_tracker_spec.rb
CHANGED
@@ -3,14 +3,13 @@ require 'compo'
|
|
3
3
|
|
4
4
|
# Mock implementation of a ParentTracker
|
5
5
|
class MockParentTracker
|
6
|
-
include Compo::ParentTracker
|
6
|
+
include Compo::Mixins::ParentTracker
|
7
7
|
|
8
8
|
# Initialises a MockParentTracker
|
9
9
|
#
|
10
10
|
# @api private
|
11
11
|
def initialize(parent, id_function)
|
12
|
-
|
13
|
-
@id_function = id_function
|
12
|
+
update_parent(parent, id_function)
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
@@ -51,16 +50,4 @@ describe MockParentTracker do
|
|
51
50
|
expect(subject.id).to eq(:new_id)
|
52
51
|
end
|
53
52
|
end
|
54
|
-
|
55
|
-
describe '#remove_parent' do
|
56
|
-
it 'sets the parent to an instance of Parentless' do
|
57
|
-
subject.remove_parent
|
58
|
-
expect(subject.parent).to be_a(Compo::Parentless)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'sets the ID function to one returning nil' do
|
62
|
-
subject.remove_parent
|
63
|
-
expect(subject.id).to be_nil
|
64
|
-
end
|
65
|
-
end
|
66
53
|
end
|
data/spec/parentless_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'compo'
|
3
3
|
|
4
|
-
describe Compo::Parentless do
|
4
|
+
describe Compo::Composites::Parentless do
|
5
5
|
let(:child) { double(:child) }
|
6
6
|
|
7
7
|
describe '#add' do
|
@@ -13,7 +13,7 @@ describe Compo::Parentless do
|
|
13
13
|
|
14
14
|
it 'calls #update_parent on the child with a Parentless' do
|
15
15
|
expect(child).to receive(:update_parent).once do |parent, _|
|
16
|
-
expect(parent).to be_a(Compo::Parentless)
|
16
|
+
expect(parent).to be_a(Compo::Composites::Parentless)
|
17
17
|
end
|
18
18
|
subject.add(:id, child)
|
19
19
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'compo'
|
2
|
+
|
3
|
+
shared_examples 'a URL finding' do
|
4
|
+
let(:target) { Compo::Branches::Leaf.new }
|
5
|
+
|
6
|
+
context 'when given a nil URL' do
|
7
|
+
specify { expect { |b| proc.call(nil, &b) }.to raise_error }
|
8
|
+
end
|
9
|
+
|
10
|
+
shared_examples 'a successful finding' do
|
11
|
+
it 'returns the correct resource' do
|
12
|
+
expect { |b| proc.call(url, &b) }.to yield_with_args(target)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples 'an unsuccessful finding' do
|
17
|
+
specify do
|
18
|
+
expect { |b| proc.call(url, &b) }.to raise_error(
|
19
|
+
"Could not find resource: #{url}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shared_examples 'an unsuccessful finding with custom error' do
|
25
|
+
specify do
|
26
|
+
mp = ->(_) { :a }
|
27
|
+
expect { |b| proc.call(url, missing_proc: mp, &b) }
|
28
|
+
.to yield_with_args(:a)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when given a correct root but incorrect URL' do
|
33
|
+
context 'using the default missing resource handler' do
|
34
|
+
context 'when the URL has a leading slash' do
|
35
|
+
it_behaves_like 'an unsuccessful finding' do
|
36
|
+
let(:url) { "/#{incorrect_url}" }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context 'when the URL has a trailing slash' do
|
40
|
+
it_behaves_like 'an unsuccessful finding' do
|
41
|
+
let(:url) { "#{incorrect_url}/" }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
context 'when the URL has a leading and trailing slash' do
|
45
|
+
it_behaves_like 'an unsuccessful finding' do
|
46
|
+
let(:url) { "/#{incorrect_url}/" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
context 'when the URL has neither leading nor trailing slash' do
|
50
|
+
it_behaves_like 'an unsuccessful finding' do
|
51
|
+
let(:url) { "#{incorrect_url}" }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'using a custom error handler' do
|
57
|
+
context 'when the URL has a leading slash' do
|
58
|
+
it_behaves_like 'an unsuccessful finding with custom error' do
|
59
|
+
let(:url) { "/#{incorrect_url}" }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
context 'when the URL has a trailing slash' do
|
63
|
+
it_behaves_like 'an unsuccessful finding with custom error' do
|
64
|
+
let(:url) { "#{incorrect_url}/" }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
context 'when the URL has a leading and trailing slash' do
|
68
|
+
it_behaves_like 'an unsuccessful finding with custom error' do
|
69
|
+
let(:url) { "/#{incorrect_url}/" }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
context 'when the URL has neither leading nor trailing slash' do
|
73
|
+
it_behaves_like 'an unsuccessful finding with custom error' do
|
74
|
+
let(:url) { "#{incorrect_url}" }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when given a correct root and URL' do
|
81
|
+
context 'when the URL leads to a resource' do
|
82
|
+
context 'when the URL has a leading slash' do
|
83
|
+
it_behaves_like 'a successful finding' do
|
84
|
+
let(:url) { "/#{correct_url}" }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
context 'when the URL has a trailing slash' do
|
88
|
+
it_behaves_like 'a successful finding' do
|
89
|
+
let(:url) { "#{correct_url}/" }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
context 'when the URL has a leading and trailing slash' do
|
93
|
+
it_behaves_like 'a successful finding' do
|
94
|
+
let(:url) { "/#{correct_url}/" }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
context 'when the URL has neither leading nor trailing slash' do
|
98
|
+
it_behaves_like 'a successful finding' do
|
99
|
+
let(:url) { "#{correct_url}" }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/spec/url_finder_spec.rb
CHANGED
@@ -1,128 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'compo'
|
3
|
+
require 'url_finder_shared_examples'
|
3
4
|
|
4
|
-
describe Compo::
|
5
|
-
subject { Compo::
|
5
|
+
describe Compo::Finders::Url do
|
6
|
+
subject { Compo::Finders::Url }
|
6
7
|
describe '.find' do
|
7
|
-
let(:target) { Compo::Leaf.new }
|
8
|
-
|
9
|
-
let(:root) do
|
10
|
-
s = Compo::HashBranch.new
|
11
|
-
a = Compo::HashBranch.new
|
12
|
-
b = Compo::ArrayBranch.new
|
13
|
-
d = Compo::Leaf.new
|
14
|
-
e = Compo::Leaf.new
|
15
|
-
zero = Compo::Leaf.new
|
16
|
-
|
17
|
-
s.add('a', a)
|
18
|
-
a.add('b', b)
|
19
|
-
b.add(0, zero)
|
20
|
-
b.add(1, target)
|
21
|
-
s.add('d', d)
|
22
|
-
a.add('e', e)
|
23
|
-
s
|
24
|
-
end
|
25
|
-
|
26
8
|
context 'when given a nil root' do
|
27
9
|
specify { expect { |b| subject.find(nil, 'a/b/1', &b) }.to raise_error }
|
28
10
|
end
|
29
11
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
12
|
+
it_behaves_like 'a URL finding' do
|
13
|
+
let(:target) { Compo::Branches::Leaf.new }
|
14
|
+
|
15
|
+
let(:root) do
|
16
|
+
s = Compo::Branches::Hash.new
|
17
|
+
a = Compo::Branches::Hash.new
|
18
|
+
b = Compo::Branches::Array.new
|
19
|
+
d = Compo::Branches::Leaf.new
|
20
|
+
e = Compo::Branches::Leaf.new
|
21
|
+
zero = Compo::Branches::Leaf.new
|
22
|
+
|
23
|
+
s.add('a', a)
|
24
|
+
a.add('b', b)
|
25
|
+
b.add(0, zero)
|
26
|
+
b.add(1, target)
|
27
|
+
s.add('d', d)
|
28
|
+
a.add('e', e)
|
29
|
+
s
|
37
30
|
end
|
38
|
-
end
|
39
31
|
|
40
|
-
|
41
|
-
|
42
|
-
expect { |b| subject.find(root, url, &b) }.to raise_error(
|
43
|
-
"Could not find resource: #{url}"
|
44
|
-
)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
shared_examples 'an unsuccessful finding with custom error' do
|
49
|
-
specify do
|
50
|
-
mp = ->(_) { :a }
|
51
|
-
expect { |b| subject.find(root, url, missing_proc: mp, &b) }
|
52
|
-
.to yield_with_args(:a)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when given a correct root but incorrect URL' do
|
57
|
-
context 'using the default missing resource handler' do
|
58
|
-
context 'when the URL has a leading slash' do
|
59
|
-
it_behaves_like 'an unsuccessful finding' do
|
60
|
-
let(:url) { '/a/z' }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
context 'when the URL has a trailing slash' do
|
64
|
-
it_behaves_like 'an unsuccessful finding' do
|
65
|
-
let(:url) { 'a/z/' }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
context 'when the URL has a leading and trailing slash' do
|
69
|
-
it_behaves_like 'an unsuccessful finding' do
|
70
|
-
let(:url) { '/a/z/' }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
context 'when the URL has neither leading nor trailing slash' do
|
74
|
-
it_behaves_like 'an unsuccessful finding' do
|
75
|
-
let(:url) { 'a/z' }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'using a custom error handler' do
|
81
|
-
context 'when the URL has a leading slash' do
|
82
|
-
it_behaves_like 'an unsuccessful finding with custom error' do
|
83
|
-
let(:url) { '/d/e/d' }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
context 'when the URL has a trailing slash' do
|
87
|
-
it_behaves_like 'an unsuccessful finding with custom error' do
|
88
|
-
let(:url) { 'd/e/d/' }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
context 'when the URL has a leading and trailing slash' do
|
92
|
-
it_behaves_like 'an unsuccessful finding with custom error' do
|
93
|
-
let(:url) { '/d/e/d/' }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
context 'when the URL has neither leading nor trailing slash' do
|
97
|
-
it_behaves_like 'an unsuccessful finding with custom error' do
|
98
|
-
let(:url) { 'd/e/d' }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
32
|
+
let(:correct_url) { 'a/b/1' }
|
33
|
+
let(:incorrect_url) { 'a/z/1' }
|
103
34
|
|
104
|
-
|
105
|
-
|
106
|
-
context 'when the URL has a leading slash' do
|
107
|
-
it_behaves_like 'a successful finding' do
|
108
|
-
let(:url) { '/a/b/1' }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
context 'when the URL has a trailing slash' do
|
112
|
-
it_behaves_like 'a successful finding' do
|
113
|
-
let(:url) { 'a/b/1/' }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
context 'when the URL has a leading and trailing slash' do
|
117
|
-
it_behaves_like 'a successful finding' do
|
118
|
-
let(:url) { '/a/b/1/' }
|
119
|
-
end
|
120
|
-
end
|
121
|
-
context 'when the URL has neither leading nor trailing slash' do
|
122
|
-
it_behaves_like 'a successful finding' do
|
123
|
-
let(:url) { 'a/b/1' }
|
124
|
-
end
|
125
|
-
end
|
35
|
+
let(:proc) do
|
36
|
+
->(*args, &b) { Compo::Finders::Url.find(root, *args, &b) }
|
126
37
|
end
|
127
38
|
end
|
128
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Windsor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backports
|
@@ -140,19 +140,24 @@ files:
|
|
140
140
|
- Rakefile
|
141
141
|
- compo.gemspec
|
142
142
|
- lib/compo.rb
|
143
|
-
- lib/compo/
|
144
|
-
- lib/compo/
|
145
|
-
- lib/compo/branch.rb
|
146
|
-
- lib/compo/
|
147
|
-
- lib/compo/
|
148
|
-
- lib/compo/
|
149
|
-
- lib/compo/
|
150
|
-
- lib/compo/
|
151
|
-
- lib/compo/
|
152
|
-
- lib/compo/
|
153
|
-
- lib/compo/
|
154
|
-
- lib/compo/
|
155
|
-
- lib/compo/
|
143
|
+
- lib/compo/branches.rb
|
144
|
+
- lib/compo/branches/array.rb
|
145
|
+
- lib/compo/branches/branch.rb
|
146
|
+
- lib/compo/branches/constant.rb
|
147
|
+
- lib/compo/branches/hash.rb
|
148
|
+
- lib/compo/branches/leaf.rb
|
149
|
+
- lib/compo/composites.rb
|
150
|
+
- lib/compo/composites/array.rb
|
151
|
+
- lib/compo/composites/composite.rb
|
152
|
+
- lib/compo/composites/hash.rb
|
153
|
+
- lib/compo/composites/leaf.rb
|
154
|
+
- lib/compo/composites/parentless.rb
|
155
|
+
- lib/compo/finders.rb
|
156
|
+
- lib/compo/finders/url.rb
|
157
|
+
- lib/compo/mixins.rb
|
158
|
+
- lib/compo/mixins/movable.rb
|
159
|
+
- lib/compo/mixins/parent_tracker.rb
|
160
|
+
- lib/compo/mixins/url_referenceable.rb
|
156
161
|
- lib/compo/version.rb
|
157
162
|
- spec/array_branch_spec.rb
|
158
163
|
- spec/array_composite_shared_examples.rb
|
@@ -161,17 +166,19 @@ files:
|
|
161
166
|
- spec/branch_spec.rb
|
162
167
|
- spec/composite_shared_examples.rb
|
163
168
|
- spec/composite_spec.rb
|
169
|
+
- spec/constant_branch_spec.rb
|
164
170
|
- spec/hash_branch_spec.rb
|
165
171
|
- spec/hash_composite_shared_examples.rb
|
166
172
|
- spec/hash_composite_spec.rb
|
167
|
-
- spec/
|
173
|
+
- spec/leaf_branch_spec.rb
|
174
|
+
- spec/leaf_composite_shared_examples.rb
|
175
|
+
- spec/leaf_composite_spec.rb
|
168
176
|
- spec/movable_shared_examples.rb
|
169
177
|
- spec/movable_spec.rb
|
170
|
-
- spec/null_composite_shared_examples.rb
|
171
|
-
- spec/null_composite_spec.rb
|
172
178
|
- spec/parent_tracker_spec.rb
|
173
179
|
- spec/parentless_spec.rb
|
174
180
|
- spec/spec_helper.rb
|
181
|
+
- spec/url_finder_shared_examples.rb
|
175
182
|
- spec/url_finder_spec.rb
|
176
183
|
- spec/url_referenceable_shared_examples.rb
|
177
184
|
- spec/url_referenceable_spec.rb
|
@@ -207,17 +214,19 @@ test_files:
|
|
207
214
|
- spec/branch_spec.rb
|
208
215
|
- spec/composite_shared_examples.rb
|
209
216
|
- spec/composite_spec.rb
|
217
|
+
- spec/constant_branch_spec.rb
|
210
218
|
- spec/hash_branch_spec.rb
|
211
219
|
- spec/hash_composite_shared_examples.rb
|
212
220
|
- spec/hash_composite_spec.rb
|
213
|
-
- spec/
|
221
|
+
- spec/leaf_branch_spec.rb
|
222
|
+
- spec/leaf_composite_shared_examples.rb
|
223
|
+
- spec/leaf_composite_spec.rb
|
214
224
|
- spec/movable_shared_examples.rb
|
215
225
|
- spec/movable_spec.rb
|
216
|
-
- spec/null_composite_shared_examples.rb
|
217
|
-
- spec/null_composite_spec.rb
|
218
226
|
- spec/parent_tracker_spec.rb
|
219
227
|
- spec/parentless_spec.rb
|
220
228
|
- spec/spec_helper.rb
|
229
|
+
- spec/url_finder_shared_examples.rb
|
221
230
|
- spec/url_finder_spec.rb
|
222
231
|
- spec/url_referenceable_shared_examples.rb
|
223
232
|
- spec/url_referenceable_spec.rb
|
data/lib/compo/array_branch.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'compo/branch'
|
2
|
-
|
3
|
-
module Compo
|
4
|
-
# A simple implementation of a branch, whose children are stored in an Array
|
5
|
-
#
|
6
|
-
# An ArrayBranch is a composite object that may be moved into other composite
|
7
|
-
# objects. It stores its children as an Array, and the ID of each child is
|
8
|
-
# its current index in the array. Inserting and removing items into the
|
9
|
-
# ArrayBranch may change the IDs of items with higher indices in the array.
|
10
|
-
#
|
11
|
-
# This is an extension of ArrayComposite to include the Movable and
|
12
|
-
# ParentTracker mixins.
|
13
|
-
class ArrayBranch < ArrayComposite
|
14
|
-
include Branch
|
15
|
-
end
|
16
|
-
end
|