nutmeg 0.0.15 → 0.0.16

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: 45bc0ab6b0e5f0b93afd8dded9a9379ad8ec521d
4
- data.tar.gz: 0e05ab2cf1ac11e2758550f26d95c7569b9f2b45
3
+ metadata.gz: 8081560032321ec09fe513cfa9d24985698d01ce
4
+ data.tar.gz: 893a745732a0173eb915d1f8a8223550ceb1f333
5
5
  SHA512:
6
- metadata.gz: 9710faf0aee7300ef59df18fa4d507ba15e597af38afbbd9e013ea61f59732465b9f8078f5597914dee598a02e8102df8bc641ec715f6f0b274003ba18ef2f62
7
- data.tar.gz: 5900b9396108b3dbc0bca967bca05c877114749482567c52fab68abffc855a485909d901903a7e059840471e65052dda2f74655c6e2b295a3705e7f1a89d3465
6
+ metadata.gz: d99b116a303647a3f099534f8dcd1a988f479f17909ccd1e0beaf33ee87645d09245d166da01ac19b3e8da665fe5947c0398b98263efa29bb17db2052a2bf035
7
+ data.tar.gz: 677b1ad91d6a6ba65eabf84039805ff744e4e38f9548f0d210536017e1a779b52027a3fc21da433b7b61d28ac78c573fb61e436275fb7f5054d28650bc358e35
@@ -18,12 +18,30 @@ module Nutmeg
18
18
  def title(node)
19
19
  node.content[:name] || node.content[:slug]
20
20
  end
21
+
21
22
  def print_html(tags_given, greedy = false, extra_html = nil, do_not_wrap = false)
22
23
  [print_node(@tree.original, tags_given, greedy, extra_html, do_not_wrap)].join("")
23
24
  end
24
25
 
25
- def node_html(node, active, leaf, content, extra_html = nil)
26
+ def print_relevant_html(tags_given, greedy = false, extra_html = nil, do_not_wrap = false)
27
+ html_nodes = []
28
+ intersectional_tags(tags_given).each do |node|
29
+ html_nodes << node_html(node, false, true, title(node), extra_html) + "</li>"
30
+ end
31
+ return html_nodes.join
32
+ end
26
33
 
34
+ def intersectional_tags(tags_given)
35
+ tree_nodes = []
36
+ @tree.original.each do |node|
37
+ if tags_given.include? node.content[:slug]
38
+ tree_nodes << node
39
+ end
40
+ end
41
+ return tree_nodes.uniq{|p| p.content[:slug]}
42
+ end
43
+
44
+ def node_html(node, active, leaf, content, extra_html = nil)
27
45
  "<li class='level_#{node.level}#{leaf ? ' leaf' : ''}#{active ? ' active' : ''}'> <a #{(leaf) ? "href=\'#{prepend_path}#{node_path(node)}#{append_path}\'" : ''}>#{content}</a>#{extra_html && active && leaf ? extra_html : ''}"
28
46
  end
29
47
 
@@ -1,3 +1,3 @@
1
1
  module Nutmeg
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -55,6 +55,10 @@ describe Nutmeg::TagTreeHelper do
55
55
  end
56
56
  end
57
57
  end
58
-
59
58
  end
59
+
60
+
61
+ it "outputs relevant tags as html" do
62
+ expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_relevant_html(['men', 'summer_2015'])).to eq("<li class='level_2 leaf'> <a href='/north/men'>men</a></li><li class='level_4 leaf'> <a href='/north/men/collections/summer_2015'>summer_2015</a></li>")
63
+ end
60
64
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutmeg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
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: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubytree
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Make creating trees in rails easier and close to fun
@@ -73,9 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - ".gitignore"
77
- - ".rspec"
78
- - ".travis.yml"
76
+ - .gitignore
77
+ - .rspec
78
+ - .travis.yml
79
79
  - Gemfile
80
80
  - LICENSE.txt
81
81
  - README.md
@@ -107,17 +107,17 @@ require_paths:
107
107
  - lib
108
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ">="
110
+ - - '>='
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.2.2
120
+ rubygems_version: 2.1.9
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Easy trees in rails