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 +4 -4
- data/lib/tree_html.rb +34 -10
- data/lib/tree_html/version.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: 9821ccd545e0f33c61a66334678756dd76cd3469
|
4
|
+
data.tar.gz: 4a959045dde16108369f743bd1605cebf5e949c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'>#{
|
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
|
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
|
22
|
+
def main_css_for_tree_html
|
15
23
|
File.read(Css)
|
16
24
|
end
|
17
25
|
|
18
26
|
protected
|
19
27
|
|
20
|
-
def
|
21
|
-
"<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
|
25
|
-
children_for_tree_html.empty?
|
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
|
29
|
-
children_for_tree_html.empty?
|
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
|
data/lib/tree_html/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|