nutmeg 0.0.2 → 0.0.3
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/nutmeg/tag_tree.rb +3 -3
- data/lib/nutmeg/tag_tree_helper.rb +1 -1
- data/lib/nutmeg/version.rb +1 -1
- data/spec/tag_tree_helper_spec.rb +1 -1
- data/spec/tag_tree_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b68dde6b721ba5628dd4c0f11b27baf1088a9a73
|
4
|
+
data.tar.gz: 07ec3c8770abb0d8083f73750669fbdd42ecbfee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb84459fa571a321194c60b9286bd319aa88a03d66081ccbf42dd827fdb51f8f3b7b6a71adb577c3d71ba9a8801486a8c7b105d412959f296ca886661304e4b0
|
7
|
+
data.tar.gz: 50d53ebfb824495c3bdfcb382f6cc44c67431c090517f45963d0026ff588f48e9500bed9f5de9f54456f92b178a0122b6051462a38452afb8b15b5cf37716f92
|
data/lib/nutmeg/tag_tree.rb
CHANGED
@@ -14,8 +14,8 @@ module Nutmeg
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_paths(tags_given)
|
17
|
-
start_nodes = @original.children.select{|l| tags_given.include?(l.content[:
|
18
|
-
end_nodes = @original.each_leaf.select{|l| tags_given.include?(l.content[:
|
17
|
+
start_nodes = @original.children.select{|l| tags_given.include?(l.content[:slug])}
|
18
|
+
end_nodes = @original.each_leaf.select{|l| tags_given.include?(l.content[:slug])}
|
19
19
|
|
20
20
|
end_nodes.select do |end_node|
|
21
21
|
(end_node.parentage & start_nodes).count >= 1
|
@@ -23,7 +23,7 @@ module Nutmeg
|
|
23
23
|
([leaf] + leaf.parentage).reverse
|
24
24
|
end.select do |path|
|
25
25
|
# we always include the 'root' tag
|
26
|
-
(path.map{|tag| tag.content[:
|
26
|
+
(path.map{|tag| tag.content[:slug] } - tags_given).count == 1
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -49,7 +49,7 @@ module Nutmeg
|
|
49
49
|
def traverse_node?(node, tags_given)
|
50
50
|
return true if node.is_root?
|
51
51
|
return true if node.level == 1
|
52
|
-
(node.parentage.select{|n| n.level == 1}.map{|n| n.content[:
|
52
|
+
(node.parentage.select{|n| n.level == 1}.map{|n| n.content[:slug]} & tags_given).count >= 1
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/lib/nutmeg/version.rb
CHANGED
@@ -9,7 +9,7 @@ describe Nutmeg::TagTreeHelper do
|
|
9
9
|
describe "#print_html" do
|
10
10
|
it "outputs html" do
|
11
11
|
expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_html([1]).class).to eq(String)
|
12
|
-
expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_html([
|
12
|
+
expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_html(["north", "men", "collections", "summer_2015"])).to eq("<ul><li class='level_1 active'> <a >north</a><ul><li class='level_2 active'> <a >men</a><ul><li class='level_3 active'> <a >collections</a><ul><li class='level_4 leaf'> <a href='/north/men/collections/winter_2015'>winter_2015</a></li><li class='level_4 leaf'> <a href='/north/men/collections/spring_2015'>spring_2015</a></li><li class='level_4 leaf active'> <a href='/north/men/collections/summer_2015'>summer_2015</a></li></ul></li></ul></li><li class='level_2'> <a >women</a><ul><li class='level_3'> <a >collections</a><ul><li class='level_4 leaf'> <a href='/north/women/collections/winter_2015'>winter_2015</a></li><li class='level_4 leaf'> <a href='/north/women/collections/spring_2015'>spring_2015</a></li><li class='level_4 leaf'> <a href='/north/women/collections/summer_2015'>summer_2015</a></li></ul></li></ul></li><li class='level_2'> <a >events</a><ul><li class='level_3 leaf'> <a href='/north/events/lowlands_2014'>lowlands_2014</a></li><li class='level_3 leaf'> <a href='/north/events/sinterklaas_2014'>sinterklaas_2014</a></li></ul></li><li class='level_2'> <a >collaborations</a><ul><li class='level_3 leaf'> <a href='/north/collaborations/afro_jack'>afro_jack</a></li><li class='level_3 leaf'> <a href='/north/collaborations/pr_co'>pr_co</a></li></ul></li></ul></li><li class='level_1'> <a >south</a><ul></li></li></ul></li></ul>")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/spec/tag_tree_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe Nutmeg::TagTree do
|
|
27
27
|
|
28
28
|
describe "#get_paths_formatted" do
|
29
29
|
it "returns base/child when using [1,2] as selector" do
|
30
|
-
expect(@tag_tree.get_paths_formatted([
|
30
|
+
expect(@tag_tree.get_paths_formatted(["base", "child"]).first).to eq("base/child")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutmeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis van der Vliet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubytree
|