keynote 1.0.0 → 1.1.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/CHANGELOG.md +5 -0
- data/lib/keynote/rumble.rb +19 -9
- data/lib/keynote/version.rb +1 -1
- data/spec/rumble_spec.rb +38 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd02a5e8d588001102132e7864b294e34290700
|
4
|
+
data.tar.gz: d8db8a485b076d070774031959cecbc2f0b9fb68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2033a7f5c59e895ac0d8f31202591f02f8d4f5f750203b940696f029968a14c0f59d0d8bba990f7f3ef95bb39358605b961326b869b074366210411ef7b80c9a
|
7
|
+
data.tar.gz: d683f2f2259fbff0ad2ab280ce5300093f25ed4e6bc68a13a5901a7d422fe0764a61dd50f6fb74de5babe3ed582772d47c224d16262218d9000f40a9506797e9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## v1.1.0
|
2
|
+
* Rumble: Fix bug in v1.0.0 that caused an exception if the user passed a `nil`
|
3
|
+
value for an attribute.
|
4
|
+
* Rumble: Add support for `aria` attr hashes, behaving the same way as `data`.
|
5
|
+
|
1
6
|
## v1.0.0
|
2
7
|
* Add support for Rails 5.1.
|
3
8
|
* Fix all Ruby warnings generated by Keynote itself.
|
data/lib/keynote/rumble.rb
CHANGED
@@ -267,14 +267,8 @@ module Keynote
|
|
267
267
|
content = nil
|
268
268
|
end
|
269
269
|
|
270
|
-
|
271
|
-
|
272
|
-
attrs = attrs.dup
|
273
|
-
attrs.delete(:data).each do |key, value|
|
274
|
-
attrs[:"data-#{key}"] = value.to_s
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
270
|
+
attrs = flatten_attr_hash(attrs, :aria)
|
271
|
+
attrs = flatten_attr_hash(attrs, :data)
|
278
272
|
merge_attributes(attrs) if attrs
|
279
273
|
|
280
274
|
if block_given?
|
@@ -321,9 +315,25 @@ module Keynote
|
|
321
315
|
|
322
316
|
def inspect; to_s.inspect end
|
323
317
|
|
318
|
+
private
|
319
|
+
|
320
|
+
# If the given attrs contain an `aria` or `data` hash, flatten its
|
321
|
+
# contents into hyphenated attribute names.
|
322
|
+
def flatten_attr_hash(attrs, name)
|
323
|
+
if attrs && attrs[name].is_a?(Hash)
|
324
|
+
attrs = attrs.dup
|
325
|
+
attrs.delete(name).each do |key, value|
|
326
|
+
next if value.nil?
|
327
|
+
attrs[:"#{name}-#{key}"] = value.to_s
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
attrs
|
332
|
+
end
|
333
|
+
|
324
334
|
def attrs_to_s
|
325
335
|
attributes.inject("") do |res, (name, value)|
|
326
|
-
next unless value
|
336
|
+
next res unless value
|
327
337
|
|
328
338
|
value =
|
329
339
|
if value.is_a?(Array)
|
data/lib/keynote/version.rb
CHANGED
data/spec/rumble_spec.rb
CHANGED
@@ -72,7 +72,34 @@ class TestRumble < klass
|
|
72
72
|
HTML
|
73
73
|
|
74
74
|
assert_rumble str do
|
75
|
-
div data: {
|
75
|
+
div data: {
|
76
|
+
modal: true,
|
77
|
+
safe: '"""'.html_safe,
|
78
|
+
absent: nil,
|
79
|
+
unsafe: '"""'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_string_aria
|
85
|
+
assert_rumble '<div aria="whatever"></div>' do
|
86
|
+
div aria: "whatever"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_hash_aria
|
91
|
+
str = <<-HTML
|
92
|
+
<div aria-modal="true" aria-safe=""""" aria-unsafe=""&quot;"">
|
93
|
+
</div>
|
94
|
+
HTML
|
95
|
+
|
96
|
+
assert_rumble str do
|
97
|
+
div aria: {
|
98
|
+
modal: true,
|
99
|
+
safe: '"""'.html_safe,
|
100
|
+
absent: nil,
|
101
|
+
unsafe: '"""'
|
102
|
+
}
|
76
103
|
end
|
77
104
|
end
|
78
105
|
|
@@ -87,6 +114,16 @@ class TestRumble < klass
|
|
87
114
|
end
|
88
115
|
end
|
89
116
|
|
117
|
+
def test_nil_attr
|
118
|
+
str = <<-HTML
|
119
|
+
<div id="id" class="class"></div>
|
120
|
+
HTML
|
121
|
+
|
122
|
+
assert_rumble str do
|
123
|
+
div id: "id", title: nil, class: "class"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
90
127
|
def test_several
|
91
128
|
str = <<-HTML
|
92
129
|
<p>Hello</p>
|