order_tree 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,19 @@ module OrderTree
16
16
  self.prev.next = next_node if self.prev
17
17
 
18
18
  if self.tree.root.first.equal? self
19
- self.tree.root.first = self.next
19
+ if next_node
20
+ self.tree.root.instance_eval do
21
+ self.first = next_node
22
+ end
23
+ end
24
+ end
25
+
26
+ if self.tree.root.last.equal? self
27
+ if prev_node
28
+ self.tree.root.instance_eval do
29
+ self.last = prev_node
30
+ end
31
+ end
20
32
  end
21
33
 
22
34
  # try this so that the node can remove
@@ -1,3 +1,3 @@
1
1
  module OrderTree
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -41,7 +41,7 @@ describe OrderTree::UniqueProxy do
41
41
  proxy(5).inspect.should eq "5"
42
42
  OrderTree::UniqueProxy.verbose_inspect = true
43
43
  p = proxy(5)
44
- p.inspect.to_s.should match(/#<UniqueProxy:(.*?)\s=>\s5>/)
44
+ p.inspect.to_s.should match(/#<OrderTree::UniqueProxy:(.*?)\s=>\s5>/)
45
45
  p.to_s.should == "proxy(5)"
46
46
  OrderTree::UniqueProxy.verbose_inspect = false
47
47
  p2 = eval(p.to_s)
@@ -191,6 +191,26 @@ describe OrderTree::OrderTree do
191
191
  v.should eq 4
192
192
  end
193
193
 
194
+ it "can overwrite the last node without losing it" do
195
+ ot = OrderTree::OrderTree.new({:first => { :a => 'a', :b => 'c'}, :second => { :a => 'a', :b => 'b'}})
196
+ last_path = ot.each_path.to_a.last
197
+ ot[*last_path] = "b"
198
+
199
+ ot.each_path.to_a.last
200
+ ot[*last_path].should eq "b"
201
+ end
202
+
203
+ it "can overwrite the first node without losing it" do
204
+ ot = OrderTree::OrderTree.new({:first => { :a => 'a', :b => 'c'}, :second => { :a => 'a', :b => 'b'}})
205
+
206
+ first_path, second_path = ot.each_path.to_a[0..1]
207
+ ot[*first_path] = "old_first"
208
+
209
+ # is no last
210
+ ot[*ot.each_path.to_a.last].should eq "old_first"
211
+ ot.each_path.to_a.first.should eq second_path
212
+ end
213
+
194
214
  it "does == comparison" do
195
215
  ot = OrderTree::OrderTree.new @testhash
196
216
  ot2 = OrderTree::OrderTree.new @testhash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: order_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-25 00:00:00.000000000 -05:00
12
+ date: 2011-07-26 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &3691310 !ruby/object:Gem::Requirement
17
+ requirement: &3691050 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *3691310
25
+ version_requirements: *3691050
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: simplecov
28
- requirement: &3691090 !ruby/object:Gem::Requirement
28
+ requirement: &3690830 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *3691090
36
+ version_requirements: *3690830
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: ruby-prof
39
- requirement: &3690870 !ruby/object:Gem::Requirement
39
+ requirement: &3690610 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *3690870
47
+ version_requirements: *3690610
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: ruby-debug19
50
- requirement: &3690650 !ruby/object:Gem::Requirement
50
+ requirement: &3690400 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *3690650
58
+ version_requirements: *3690400
59
59
  description: Use OrderTree when you need both insertion order access and nested hash
60
60
  path style access
61
61
  email: