html-native 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/html-native.rb +1 -0
- data/lib/html-native/builder.rb +8 -8
- data/lib/html-native/logic.rb +38 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21997059907e655e0171cd63d1b7bac5be51d1c3474c87849b508463a1ab011b
|
4
|
+
data.tar.gz: c87c0911546412b8954dd674f22ccd128f0b2ce985df085e2f38cbce3c150686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 566d2c708f9c6829eb727f71f461d1499093ab995a35fdb5748f8b68dc157fb4bf6c650c02acc5cd6a6fc14c88224ea1c0921cbfded11244ebe6a7890ff4e3d7
|
7
|
+
data.tar.gz: ed6f3a80fea8a20e058770804255f87b93999dcf6d0b81cebaead9bbd2628750e2581549cbc536c16f8581b046e8f5fdfd0f6fc07fe86dc2165a10bf2a35cfdc
|
data/lib/html-native.rb
CHANGED
data/lib/html-native/builder.rb
CHANGED
@@ -9,14 +9,14 @@ module HTMLComponent
|
|
9
9
|
# the initial value.
|
10
10
|
def initialize(strings = [])
|
11
11
|
@strings = []
|
12
|
-
@cache =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
@cache =
|
13
|
+
if strings.kind_of? Array
|
14
|
+
strings.join
|
15
|
+
elsif strings.kind_of? Enumerable
|
16
|
+
strings.to_a.join
|
17
|
+
else
|
18
|
+
strings.to_s
|
19
|
+
end
|
20
20
|
@cached = true
|
21
21
|
end
|
22
22
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module HTMLComponent
|
2
|
+
class Builder
|
3
|
+
define_method(:if) do |bool|
|
4
|
+
if bool
|
5
|
+
self
|
6
|
+
else
|
7
|
+
Builder.new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
define_method(:unless) do |bool|
|
12
|
+
if bool
|
13
|
+
Builder.new
|
14
|
+
else
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class String
|
22
|
+
define_method(:if) do |bool|
|
23
|
+
if bool
|
24
|
+
Builder.new(self)
|
25
|
+
else
|
26
|
+
Builder.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
define_method(:unless) do |bool|
|
31
|
+
# BAd form, purely for symmetry
|
32
|
+
unless bool
|
33
|
+
Builder.new(self)
|
34
|
+
else
|
35
|
+
Builder.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kellen Watt
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- lib/html-native/builder.rb
|
21
21
|
- lib/html-native/collections.rb
|
22
22
|
- lib/html-native/constants.rb
|
23
|
+
- lib/html-native/logic.rb
|
23
24
|
homepage: https://github.com/KellenWatt/html-native
|
24
25
|
licenses:
|
25
26
|
- MIT
|