nutmeg 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 123b62c1b70f93ad02f00b754a735d2cab3e9e74
4
- data.tar.gz: 7f189ebe9a2a44b3634b16b5874b7387c2466ed2
3
+ metadata.gz: d46add46ba66cdd0a75ef3f905581a56d19c52a9
4
+ data.tar.gz: 0a823d5a6a20be742c214bdf56cbf7ff5ae1e432
5
5
  SHA512:
6
- metadata.gz: 489de4a4be48f792cee9a68efdacb700bbd86c808a8d8eb6b8b22fabcdcec068aead0d045ebe1e462d67873c94f7853c1e1aadeb18f051886ed25032b83dac4f
7
- data.tar.gz: f8d6f1f8845d61d8308446eb977a203f27870bc8fe4a26af16958ecd8c26636c91c071b808a251f8c131f8dbfc9756085efb52ce75359b3d6a2da5714ae3713c
6
+ metadata.gz: 13453f13317042df4e4fdd803ec9377f7f218453b0eba8472958ed5f2008d26834f7fb7c6947bdb9291053c621f040ec1b56118730a2c26d065264840b1578cb
7
+ data.tar.gz: ab785e32e4ee8f80e4a111da75d3f8498d21c88a93eab0297dce37668523fb662cf45d6d742637f69db1bf667e948a19c6a458e2f51374dcdcb80b3cf395a448
@@ -6,8 +6,8 @@ module Nutmeg
6
6
  @tree = tree
7
7
  end
8
8
 
9
- def print_html(tags_given)
10
- [print_node(@tree.original, tags_given)].join("")
9
+ def print_html(tags_given, greedy = false)
10
+ [print_node(@tree.original, tags_given, greedy)].join("")
11
11
  end
12
12
 
13
13
  def node_html(node, active, leaf, content)
@@ -18,10 +18,10 @@ module Nutmeg
18
18
  ([""] + node.parentage.map{|p| p.content[:slug]}.reverse.reject{|n| n == "root"} + [node.content[:slug]]).join("/")
19
19
  end
20
20
 
21
- def print_node(node, tags_given)
21
+ def print_node(node, tags_given, greedy = false)
22
22
  output = []
23
23
  if render_node?(node,tags_given)
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])
24
+ output << node_html(node, (!@tree.get_paths(tags_given).first.nil? && @tree.get_paths(tags_given).first.map(&:name).include?(node.name) || (greedy == true && tags_given.include?(node.content[:slug]))), node.is_leaf?, node.content[:slug])
25
25
  end
26
26
 
27
27
  if !traverse_node?(node, tags_given)
@@ -31,7 +31,7 @@ module Nutmeg
31
31
  if node.has_children?
32
32
  output << "<ul>"
33
33
  node.children.each do |child|
34
- output << print_node(child, tags_given)
34
+ output << print_node(child, tags_given, greedy)
35
35
  end
36
36
  output << "</ul>"
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module Nutmeg
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -17,6 +17,11 @@ describe Nutmeg::TagTreeHelper do
17
17
  expect(Nutmeg::TagTreeHelper.new(subtree).print_html(["men", "collections", "summer_2015"])).to eq("<ul><li class='level_1 active'> <a >men</a><ul><li class='level_2 active'> <a >collections</a><ul><li class='level_3 leaf'> <a href='/north/men/collections/winter_2015'>winter_2015</a></li><li class='level_3 leaf'> <a href='/north/men/collections/spring_2015'>spring_2015</a></li><li class='level_3 leaf active'> <a href='/north/men/collections/summer_2015'>summer_2015</a></li></ul></li></ul></li><li class='level_1'> <a >women</a><ul><li class='level_2'> <a >collections</a><ul><li class='level_3 leaf'> <a href='/north/women/collections/winter_2015'>winter_2015</a></li><li class='level_3 leaf'> <a href='/north/women/collections/spring_2015'>spring_2015</a></li><li class='level_3 leaf'> <a href='/north/women/collections/summer_2015'>summer_2015</a></li></ul></li></ul></li><li class='level_1'> <a >events</a><ul><li class='level_2 leaf'> <a href='/north/events/lowlands_2014'>lowlands_2014</a></li><li class='level_2 leaf'> <a href='/north/events/sinterklaas_2014'>sinterklaas_2014</a></li></ul></li><li class='level_1'> <a >collaborations</a><ul><li class='level_2 leaf'> <a href='/north/collaborations/afro_jack'>afro_jack</a></li><li class='level_2 leaf'> <a href='/north/collaborations/pr_co'>pr_co</a></li></ul></li></ul>")
18
18
  end
19
19
 
20
+ it "outputs html for subtree (greedy)" do
21
+ subtree = @tree_from_yaml.tree.subtree("north")
22
+ expect(Nutmeg::TagTreeHelper.new(subtree).print_html(["men", "collections"],true)).to eq("<ul><li class='level_1 active'> <a >men</a><ul><li class='level_2 active'> <a >collections</a><ul><li class='level_3 leaf'> <a href='/north/men/collections/winter_2015'>winter_2015</a></li><li class='level_3 leaf'> <a href='/north/men/collections/spring_2015'>spring_2015</a></li><li class='level_3 leaf'> <a href='/north/men/collections/summer_2015'>summer_2015</a></li></ul></li></ul></li><li class='level_1'> <a >women</a><ul><li class='level_2 active'> <a >collections</a><ul><li class='level_3 leaf'> <a href='/north/women/collections/winter_2015'>winter_2015</a></li><li class='level_3 leaf'> <a href='/north/women/collections/spring_2015'>spring_2015</a></li><li class='level_3 leaf'> <a href='/north/women/collections/summer_2015'>summer_2015</a></li></ul></li></ul></li><li class='level_1'> <a >events</a><ul><li class='level_2 leaf'> <a href='/north/events/lowlands_2014'>lowlands_2014</a></li><li class='level_2 leaf'> <a href='/north/events/sinterklaas_2014'>sinterklaas_2014</a></li></ul></li><li class='level_1'> <a >collaborations</a><ul><li class='level_2 leaf'> <a href='/north/collaborations/afro_jack'>afro_jack</a></li><li class='level_2 leaf'> <a href='/north/collaborations/pr_co'>pr_co</a></li></ul></li></ul>")
23
+ end
24
+
20
25
 
21
26
  end
22
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutmeg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis van der Vliet