text_based_nested_set 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/README.md +2 -0
- data/lib/text_based_nested_set/model.rb +5 -2
- data/lib/text_based_nested_set/version.rb +1 -1
- data/spec/db/database.yml +1 -2
- data/spec/text_based_nested_set_spec.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78749e7217cec62deb80deeead9fc78f0a772ef7
|
|
4
|
+
data.tar.gz: 8d4c60d74da99f5713ca8fb6b1c8d01c48de47e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: baa53fc66973c9493c9e1a76fcf17ddbf478676b4ff82d098368286ea1317d80f49bae1a04b2ab5953136bfacd6d80219e03726019466e19b96fc80686964e5a
|
|
7
|
+
data.tar.gz: 08abf2d09fea02c5b9444268b6205a1362c48f837792f9bffcdef38e718c998304cff070b29b8291b1db8c570556c67abdc386a73e7c1161524b9da3bdd8d35f
|
data/.travis.yml
ADDED
data/README.md
CHANGED
|
@@ -140,8 +140,7 @@ module BeyondAlbert
|
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
def self_and_ancestors
|
|
143
|
-
|
|
144
|
-
current_class.where(id: parent_ids)
|
|
143
|
+
ancestors << self
|
|
145
144
|
end
|
|
146
145
|
|
|
147
146
|
def children
|
|
@@ -154,6 +153,10 @@ module BeyondAlbert
|
|
|
154
153
|
current_class.where("path LIKE ?", descendants_path).order("LENGTH(path) ASC, position ASC")
|
|
155
154
|
end
|
|
156
155
|
|
|
156
|
+
def self_and_descendants
|
|
157
|
+
descendants.unshift(self)
|
|
158
|
+
end
|
|
159
|
+
|
|
157
160
|
def right_sibling
|
|
158
161
|
right_siblings = current_class.where(path: self.path, position: self.position + 1)
|
|
159
162
|
if right_siblings.empty?
|
data/spec/db/database.yml
CHANGED
|
@@ -119,6 +119,13 @@ describe 'TextBasedNestedSet' do
|
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
+
describe 'self_and_descendants' do
|
|
123
|
+
it "should return current node and it's all descendants" do
|
|
124
|
+
expect(@child_1.self_and_descendants).to eq([@child_1, @child_1_1, @child_1_2, @child_1_3, @child_1_2_1, @child_1_1_1])
|
|
125
|
+
expect(@root.self_and_descendants).to eq([@root, @child_1, @child_2, @child_1_1, @child_1_2, @child_1_3, @child_1_2_1, @child_1_1_1])
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
122
129
|
describe 'right_sibling' do
|
|
123
130
|
it "should return current node's right sibling" do
|
|
124
131
|
expect(@child_1_2.right_sibling).to eq(@child_1_3)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: text_based_nested_set
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- beyondalbert
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-02-
|
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
|
131
131
|
files:
|
|
132
132
|
- ".gitignore"
|
|
133
133
|
- ".rspec"
|
|
134
|
+
- ".travis.yml"
|
|
134
135
|
- Gemfile
|
|
135
136
|
- LICENSE.txt
|
|
136
137
|
- README.md
|