psd 1.1.0 → 1.1.1
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/lib/psd/nodes/ancestry.rb +5 -1
- data/lib/psd/version.rb +1 -1
- data/spec/hierarchy_spec.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bc299dfcc8a9b41a3f17b16a204c2894668b5cc
|
4
|
+
data.tar.gz: bf991e614ddb7f6e151c42d6bcc627e7d34a1050
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f2cbfb412549b89d2c4dc0bfa579c31c1c92e3451b0bf498adcbffafcdff48024ddc68625fc2db0c01910f22e195839efaaf84bdb137187bfc6d09411fa8e2
|
7
|
+
data.tar.gz: aaabac77598af888c915cc9e600c9ac393f7aff6cd1a3ea3e987a7186d7d698204669040f3f5eb2eb476fb1dbc408a148b18459736d721681536d667cff577ab
|
data/lib/psd/nodes/ancestry.rb
CHANGED
@@ -50,7 +50,7 @@ class PSD
|
|
50
50
|
|
51
51
|
# Recursively get all descendant nodes, not including this node.
|
52
52
|
def descendants
|
53
|
-
children
|
53
|
+
children.map(&:subtree).flatten
|
54
54
|
end
|
55
55
|
|
56
56
|
# Same as descendants, except it includes this node.
|
@@ -63,6 +63,10 @@ class PSD
|
|
63
63
|
return ancestors.length + 1
|
64
64
|
end
|
65
65
|
|
66
|
+
def path
|
67
|
+
(ancestors.map(&:name) + [name]).join('/')
|
68
|
+
end
|
69
|
+
|
66
70
|
def method_missing(method, *args, &block)
|
67
71
|
test = /^(.+)_(layers|groups)$/.match(method)
|
68
72
|
if test
|
data/lib/psd/version.rb
CHANGED
data/spec/hierarchy_spec.rb
CHANGED
@@ -66,6 +66,11 @@ describe "Hierarchy" do
|
|
66
66
|
expect(@tree.children.first.depth).to eq(1)
|
67
67
|
end
|
68
68
|
|
69
|
+
it "should be able to generate a path to a node" do
|
70
|
+
node = @tree.children_at_path('Version A/Matte').first
|
71
|
+
expect(node.path).to eq('Version A/Matte')
|
72
|
+
end
|
73
|
+
|
69
74
|
describe "Searching" do
|
70
75
|
it "should find a node given a path" do
|
71
76
|
expect(@tree.children_at_path('Version A/Matte')).to be_an_instance_of(Array)
|