nutmeg 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/README.md +1 -0
- data/lib/nutmeg/tag_tree_helper.rb +7 -4
- data/lib/nutmeg/version.rb +1 -1
- data/spec/files/tree.yml +7 -7
- data/spec/spec_helper.rb +7 -1
- data/spec/tag_tree_helper_spec.rb +1 -1
- data/tasks/rspec.rake +2 -1
- 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: 839f3094a2c5de6f59f396e3c31a456c2910cee0
|
4
|
+
data.tar.gz: c58024fe9671ff83ab4a3e6b6104b6b440999ead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a22c789b3eb03b59c21069ec5408e5ada70dcaa21d6b3dafa44bb9917933b062a8e92ede09544ad6b737598e842ba7b1252655fc540f9db62c315069c90d55
|
7
|
+
data.tar.gz: 3908dcf8684c2e9b53e33182001586acf4ae8bc162a600caa9abfc1ed014225d6465e804874cf6bd4a949e58f36fb4da7a37f43bcdb3b9b3a4c76771441e4fed
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -10,15 +10,18 @@ module Nutmeg
|
|
10
10
|
[print_node(@tree.original, tags_given)].join("")
|
11
11
|
end
|
12
12
|
|
13
|
-
def node_html(node, active, leaf)
|
14
|
-
"<li class='level_#{node.level}#{leaf ? ' leaf' : ''}#{active ? ' active' : ''}'>"
|
13
|
+
def node_html(node, active, leaf, content)
|
14
|
+
"<li class='level_#{node.level}#{leaf ? ' leaf' : ''}#{active ? ' active' : ''}'> <a #{(leaf) ? "href=\'#{node_path(node)}\'" : ''}>#{content}</a>"
|
15
|
+
end
|
16
|
+
|
17
|
+
def node_path(node)
|
18
|
+
([""] + node.parentage.map{|p| p.content[:slug]}.reverse.reject{|n| n == "root"} + [node.content[:slug]]).join("/")
|
15
19
|
end
|
16
20
|
|
17
21
|
def print_node(node, tags_given)
|
18
22
|
output = []
|
19
23
|
if render_node?(node,tags_given)
|
20
|
-
output << node_html(node, (!@tree.get_paths(tags_given).first.nil? && @tree.get_paths(tags_given).first.map(&:name).include?(node.name)), node.is_leaf
|
21
|
-
output << node.content[:slug]
|
24
|
+
output << node_html(node, (!@tree.get_paths(tags_given).first.nil? && @tree.get_paths(tags_given).first.map(&:name).include?(node.name)), node.is_leaf?, node.content[:slug])
|
22
25
|
end
|
23
26
|
|
24
27
|
if !traverse_node?(node, tags_given)
|
data/lib/nutmeg/version.rb
CHANGED
data/spec/files/tree.yml
CHANGED
@@ -38,10 +38,10 @@ tags:
|
|
38
38
|
5: collections
|
39
39
|
6: events
|
40
40
|
7: collaborations
|
41
|
-
8:
|
42
|
-
9:
|
43
|
-
10:
|
44
|
-
11:
|
45
|
-
12:
|
46
|
-
13:
|
47
|
-
14:
|
41
|
+
8: winter_2015
|
42
|
+
9: spring_2015
|
43
|
+
10: summer_2015
|
44
|
+
11: afro_jack
|
45
|
+
12: pr_co
|
46
|
+
13: lowlands_2014
|
47
|
+
14: sinterklaas_2014
|
data/spec/spec_helper.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([1,3,5,10])).to eq("<ul><li class='level_1 active'>north
|
12
|
+
expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_html([1,3,5,10])).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/tasks/rspec.rake
CHANGED
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.2
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubytree
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
77
|
- .rspec
|
78
|
+
- .travis.yml
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|