tree_html 0.1.3 → 0.1.4

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: da8586ac3457b5d7299d7038e9246c18e1317021
4
- data.tar.gz: 85559c8310255f1094f0c1f4f0b0fdd8b3d24623
3
+ metadata.gz: 9821ccd545e0f33c61a66334678756dd76cd3469
4
+ data.tar.gz: 4a959045dde16108369f743bd1605cebf5e949c1
5
5
  SHA512:
6
- metadata.gz: 643cb5f1641906cd1ceecaf8cade22432af6f747cabe50f2501bb4b6a8af1672d773445f460fe0a08440cccdc2bb88120064a1620c9c2a0fe7cd4080534665d1
7
- data.tar.gz: 609518b6c208b1c80eed08bba7b1d02d3c9a77c254314367f007a523d222096a6379e002123b666266445e1b3e18ff71e3baeb0bf3ffd6816c103bc810688544
6
+ metadata.gz: 9aa8bceb50ff91d99f1d6f52a3a5de640d0625ff2dd6c02926e4071c95aec147774049571aa4800ea750867f89121edb89d073ffeb3f85a99b9522eb43c37486
7
+ data.tar.gz: 961d699aa74346477e187740f943c7b0a6b074396f38a14d3929b99752322425bb6145256178bd5f1f7b9e245c0d95265393a87b322011c2dd5a4ab2a08194fa
data/lib/tree_html.rb CHANGED
@@ -1,35 +1,59 @@
1
1
  require "tree_html/version"
2
2
 
3
3
  module TreeHtml
4
+
5
+ NO_DATA_IN_A = {}.freeze
6
+ NO_CHECKBOX = "<label class='placeholder'></label>".freeze
7
+ BLANK = ''.freeze
8
+
4
9
  def tree_html
5
- "<ul class='tree-html'>#{li}</ul>"
10
+ "<ul class='tree-html'>#{li_for_tree_html}</ul>"
6
11
  end
7
12
 
8
13
  def tree_html_full
9
- "<!DOCTYPE HTML><html><head><meta charset='utf-8'/><style>#{css + css_for_tree_html}</style></head><body>#{tree_html}</body></html>"
14
+ "<!DOCTYPE HTML><html>"\
15
+ "<head><meta charset='utf-8'/><style>#{main_css_for_tree_html + css_for_tree_html}</style></head>"\
16
+ "<body>#{tree_html}</body>"\
17
+ "</html>"
10
18
  end
11
19
 
12
20
  Css = File.expand_path('../tree_html/tree_html.css', __FILE__)
13
21
 
14
- def css
22
+ def main_css_for_tree_html
15
23
  File.read(Css)
16
24
  end
17
25
 
18
26
  protected
19
27
 
20
- def li
21
- "<li>#{checkbox}<a>#{label_for_tree_html}</a>#{sub_ul}</li>"
28
+ def li_for_tree_html
29
+ "<li>#{checkbox_for_tree_html}<a #{data_in_a_for_tree_html}>#{label_for_tree_html}</a>#{sub_ul_for_tree_html}</li>"
30
+ end
31
+
32
+ def data_in_a_for_tree_html
33
+ data_for_tree_html.map{ |k, v| "data-#{k}='#{v}'" }.join(" ")
34
+ end
35
+
36
+ def data_for_tree_html
37
+ NO_DATA_IN_A
22
38
  end
23
39
 
24
- def checkbox
25
- children_for_tree_html.empty? ? "<label class='placeholder'></label>" : "<input type='checkbox' id='#{object_id}'><label for='#{object_id}'></label>"
40
+ def checkbox_for_tree_html
41
+ if children_for_tree_html.empty?
42
+ NO_CHECKBOX
43
+ else
44
+ "<input type='checkbox' id='#{object_id}'><label for='#{object_id}'></label>"
45
+ end
26
46
  end
27
47
 
28
- def sub_ul
29
- children_for_tree_html.empty? ? '' : "<ul>#{children_for_tree_html.map{|c| c.li}.join}</ul>"
48
+ def sub_ul_for_tree_html
49
+ if children_for_tree_html.empty?
50
+ BLANK
51
+ else
52
+ "<ul>#{children_for_tree_html.map{|c| c.li_for_tree_html}.join}</ul>"
53
+ end
30
54
  end
31
55
 
32
56
  def css_for_tree_html
33
- ''
57
+ BLANK
34
58
  end
35
59
  end
@@ -1,3 +1,3 @@
1
1
  module TreeHtml
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler