jcredding-is_tree 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == Description
4
4
 
5
- Describe your gem here ...
5
+ A gem version of acts_as_tree[http://github.com/rails/acts_as_tree/tree/master]. Provides the same functionality, but uses new rails features, such as scopes.
6
6
 
7
7
  == Installation
8
8
 
@@ -12,9 +12,13 @@ Describe your gem here ...
12
12
 
13
13
  require 'is_tree'
14
14
 
15
+ == Credit
16
+
17
+ The idea and implementation for this gem all come from the acts_as_tree[http://github.com/rails/acts_as_tree/tree/master] plugin. Credit for the idea and concept go to the authors of that plugin.
18
+
15
19
  == License
16
20
 
17
- Copyright (c) <year> <copyright holders>
21
+ Copyright (c) 2007-2009 John Collin Redding and David Heinemeier Hansson
18
22
 
19
23
  Permission is hereby granted, free of charge, to any person
20
24
  obtaining a copy of this software and associated documentation
@@ -43,11 +43,8 @@ module IsTree
43
43
  nodes
44
44
  end
45
45
 
46
- # Returns the root node of the tree.
47
46
  def root
48
- node = self
49
- node = node.parent while node.parent
50
- node
47
+ self.ancestors.last
51
48
  end
52
49
 
53
50
  def leaf?
@@ -59,11 +56,11 @@ module IsTree
59
56
  end
60
57
 
61
58
  def siblings
62
- self.self_and_siblings.reject{|node| node == self}
59
+ self.self_and_siblings.scoped(:conditions => ["id <> :id",{:id => self.id}])
63
60
  end
64
61
 
65
62
  def self_and_siblings
66
- self.parent ? self.parent.children : self.class.roots
63
+ self.parent_id ? self.class.scoped_by_parent_id(self.parent_id) : self.class.roots
67
64
  end
68
65
 
69
66
  end
@@ -3,7 +3,7 @@ module IsTree
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcredding-is_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Collin Redding
@@ -40,6 +40,7 @@ files:
40
40
  - lib/is_tree.rb
41
41
  has_rdoc: false
42
42
  homepage: ""
43
+ licenses:
43
44
  post_install_message:
44
45
  rdoc_options:
45
46
  - --main
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  requirements: []
62
63
 
63
64
  rubyforge_project:
64
- rubygems_version: 1.2.0
65
+ rubygems_version: 1.3.5
65
66
  signing_key:
66
67
  specification_version: 3
67
68
  summary: gem version of acts_as_tree with some other features and tests