eb_nested_set 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,8 +14,8 @@ Edge:
14
14
 
15
15
  From source:
16
16
 
17
- git clone git://github.com/jnicklas/even_better_nested_set.git
18
- cd even_better_nested_set
17
+ git clone git://github.com/jnicklas/eb_nested_set.git
18
+ cd eb_nested_set
19
19
  rake install
20
20
 
21
21
  If you're running Rails, just add it to your environment.rb file
@@ -24,7 +24,7 @@ If you're running Rails, just add it to your environment.rb file
24
24
 
25
25
  You can also install it as a Rails plugin.
26
26
 
27
- script/plugin install git://github.com/jnicklas/even_better_nested_set.git
27
+ script/plugin install git://github.com/jnicklas/eb_nested_set.git
28
28
 
29
29
  ## Contributing
30
30
 
@@ -72,7 +72,7 @@ or more conveniently:
72
72
 
73
73
  Add these keys to your translation file:
74
74
 
75
- even_better_nested_set:
75
+ eb_nested_set:
76
76
  parent_not_in_scope: "nay, thy parent not be in scope {{scope_name}}"
77
77
  illegal_nesting: "arr tis be illegal nesting"
78
78
 
data/Rakefile CHANGED
@@ -6,10 +6,10 @@ require 'spec/rake/spectask'
6
6
  require 'yard'
7
7
 
8
8
  GEM = "eb_nested_set"
9
- GEM_VERSION = "0.3.7"
9
+ GEM_VERSION = "0.3.8"
10
10
  AUTHOR = "Jonas Nicklas"
11
11
  EMAIL = "jonas.nicklas@gmail.com"
12
- HOMEPAGE = "http://github.com/jnicklas/even_better_nested_set/tree/master"
12
+ HOMEPAGE = "http://github.com/jnicklas/eb_nested_set/tree/master"
13
13
  SUMMARY = "A cool acts_as_nested_set alternative"
14
14
 
15
15
  spec = Gem::Specification.new do |s|
data/init.rb CHANGED
@@ -1 +1 @@
1
- require File.join(File.dirname(__FILE__), 'lib', 'even_better_nested_set')
1
+ require File.join(File.dirname(__FILE__), 'lib', 'eb_nested_set')
@@ -33,8 +33,8 @@ module EvenBetterNestedSet
33
33
  end
34
34
  RUBY
35
35
 
36
- named_scope :roots, :conditions => { :parent_id => nil }, :order => "#{nested_set_column(:left)} asc"
37
- has_many :children, :class_name => self.name, :foreign_key => :parent_id, :order => "#{nested_set_column(:left)} asc"
36
+ named_scope :roots, :conditions => { :parent_id => nil }
37
+ has_many :children, :class_name => self.name, :foreign_key => :parent_id
38
38
  belongs_to :parent, :class_name => self.name, :foreign_key => :parent_id
39
39
 
40
40
  named_scope :descendants, lambda { |node|
@@ -182,6 +182,10 @@ module EvenBetterNestedSet
182
182
  def root?
183
183
  not parent_id?
184
184
  end
185
+
186
+ def leaf?
187
+ (right - left) <= 1
188
+ end
185
189
 
186
190
  ##
187
191
  # Checks if this node is a descendant of node
@@ -371,7 +375,7 @@ module EvenBetterNestedSet
371
375
 
372
376
  def illegal_nesting
373
377
  if parent_id? and family_ids.include?(parent_id)
374
- errors.add(:parent_id, I18n.t('even_better_nested_set.illegal_nesting', :default => 'cannot move node to its own descendant'))
378
+ errors.add(:parent_id, I18n.t('eb_nested_set.illegal_nesting', :default => 'cannot move node to its own descendant'))
375
379
  end
376
380
  end
377
381
 
@@ -456,7 +460,7 @@ module EvenBetterNestedSet
456
460
  if self.class.nested_set_options[:scope] && parent_id
457
461
  parent.reload # Make sure we are testing the record corresponding to the parent_id
458
462
  if self.send(self.class.nested_set_options[:scope]) != parent.send(self.class.nested_set_options[:scope])
459
- message = I18n.t('even_better_nested_set.parent_not_in_scope',
463
+ message = I18n.t('eb_nested_set.parent_not_in_scope',
460
464
  :default => "cannot be a record with a different {{scope_name}} to this record",
461
465
  :scope_name => self.class.nested_set_options[:scope]
462
466
  )
Binary file
@@ -402,6 +402,15 @@ describe "all nested set models", :shared => true do
402
402
  end
403
403
  end
404
404
 
405
+ describe "#leaf?" do
406
+ it "should be true if node doesn't have descendants" do
407
+ @r1.reload.should_not be_leaf
408
+ @r1c1.reload.should_not be_leaf
409
+ @r1c1s1.reload.should be_leaf
410
+ @r2c1.reload.should be_leaf
411
+ end
412
+ end
413
+
405
414
  describe "#descendant_of(other_node)" do
406
415
  it "should be true if other_node is an ancestor of node" do
407
416
  reload_models @r1, @r1c2s2
@@ -14,13 +14,13 @@ dbconfig = case ENV["DB"]
14
14
  when "postgresql"
15
15
  {
16
16
  :adapter => 'postgresql',
17
- :database => 'even_better_nested_set_test',
17
+ :database => 'eb_nested_set_test',
18
18
  :host => '127.0.0.1'
19
19
  }
20
20
  when "mysql"
21
21
  {
22
22
  :adapter => 'mysql',
23
- :database => 'even_better_nested_set_test',
23
+ :database => 'eb_nested_set_test',
24
24
  :host => '127.0.0.1'
25
25
  }
26
26
  else
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eb_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ hash: 3
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 8
10
+ version: 0.3.8
5
11
  platform: ruby
6
12
  authors:
7
13
  - Jonas Nicklas
@@ -9,7 +15,7 @@ autorequire: eb_nested_set
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-06-16 00:00:00 +02:00
18
+ date: 2010-06-30 00:00:00 +02:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -34,7 +40,7 @@ files:
34
40
  - spec/nested_set_behavior.rb
35
41
  - spec/spec_helper.rb
36
42
  has_rdoc: true
37
- homepage: http://github.com/jnicklas/even_better_nested_set/tree/master
43
+ homepage: http://github.com/jnicklas/eb_nested_set/tree/master
38
44
  licenses: []
39
45
 
40
46
  post_install_message:
@@ -43,21 +49,27 @@ rdoc_options: []
43
49
  require_paths:
44
50
  - lib
45
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
46
53
  requirements:
47
54
  - - ">="
48
55
  - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
49
59
  version: "0"
50
- version:
51
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
52
62
  requirements:
53
63
  - - ">="
54
64
  - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
55
68
  version: "0"
56
- version:
57
69
  requirements: []
58
70
 
59
71
  rubyforge_project:
60
- rubygems_version: 1.3.2
72
+ rubygems_version: 1.3.7
61
73
  signing_key:
62
74
  specification_version: 3
63
75
  summary: A cool acts_as_nested_set alternative