inky-rb 1.3.7.5 → 1.3.8.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/inky.rb +1 -1
- data/lib/inky/component_factory.rb +1 -1
- data/lib/inky/configuration.rb +22 -1
- data/lib/inky/rails/version.rb +1 -1
- data/spec/components_spec.rb +6 -6
- data/spec/configuration_spec.rb +92 -22
- data/spec/spec_helper.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48af980ab18545c232dc3fd4f4ee2ebedbfeca066aabe1faa4c3455c2aa4c152
|
4
|
+
data.tar.gz: f0b985c040dea524b0004cc90edb81ce8f4920e135d9def3253896a38b75099c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3de872ab2036bd2ffcfb7c6c13aa8a58aee0b208e89da68281547e60a61acc8eaaf7b7f587d08d9672b6c84ad18219e61d7c227a71d47b3a6396c59ebb9dd840
|
7
|
+
data.tar.gz: f278877cc37ddf979b7f68fb35d3f333881095203eb40a95b330e217c28cc9708ba658a5466fcb2b171ace3ffd83b60270ec64b781d6a9b6ccdd64a37d728223
|
data/lib/inky.rb
CHANGED
@@ -126,7 +126,7 @@ module Inky
|
|
126
126
|
|
127
127
|
def _transform_spacer(component, _inner)
|
128
128
|
classes = _combine_classes(component, 'spacer')
|
129
|
-
build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}
|
129
|
+
build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}" style="font-size:#{size}px;line-height:#{size}px;"> </td></tr></tbody></table>} }
|
130
130
|
size = component.attr('size')
|
131
131
|
size_sm = component.attr('size-sm')
|
132
132
|
size_lg = component.attr('size-lg')
|
data/lib/inky/configuration.rb
CHANGED
@@ -7,6 +7,8 @@ module Inky
|
|
7
7
|
# Set Inky's configuration
|
8
8
|
# @param config [Inky::Configuration]
|
9
9
|
def self.configuration=(config)
|
10
|
+
raise TypeError, "Not an Inky::Configuration" unless config.is_a?(Configuration)
|
11
|
+
|
10
12
|
@configuration = config
|
11
13
|
end
|
12
14
|
|
@@ -23,11 +25,30 @@ module Inky
|
|
23
25
|
end
|
24
26
|
|
25
27
|
class Configuration
|
26
|
-
|
28
|
+
attr_reader :template_engine, :column_count, :components
|
27
29
|
|
28
30
|
def initialize
|
29
31
|
@template_engine = :erb
|
30
32
|
@column_count = 12
|
33
|
+
@components = {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def template_engine=(value)
|
37
|
+
raise TypeError, "#{value.inspect} (#{value.class}) does not respond to 'to_sym'" unless value.respond_to?(:to_sym)
|
38
|
+
|
39
|
+
@template_engine = value.to_sym
|
40
|
+
end
|
41
|
+
|
42
|
+
def components=(value)
|
43
|
+
raise TypeError, "#{value.inspect} (#{value.class}) does not respond to 'to_hash'" unless value.respond_to?(:to_hash)
|
44
|
+
|
45
|
+
@components = value.to_hash
|
46
|
+
end
|
47
|
+
|
48
|
+
def column_count=(value)
|
49
|
+
raise TypeError, "#{value.inspect} (#{value.class}) does not respond to 'to_int'" unless value.respond_to?(:to_int)
|
50
|
+
|
51
|
+
@column_count = value.to_int
|
31
52
|
end
|
32
53
|
end
|
33
54
|
end
|
data/lib/inky/rails/version.rb
CHANGED
data/spec/components_spec.rb
CHANGED
@@ -259,7 +259,7 @@ RSpec.describe "Spacer" do
|
|
259
259
|
<table class="spacer">
|
260
260
|
<tbody>
|
261
261
|
<tr>
|
262
|
-
<td height="
|
262
|
+
<td height="10" style="font-size:10px;line-height:10px;"> </td>
|
263
263
|
</tr>
|
264
264
|
</tbody>
|
265
265
|
</table>
|
@@ -274,7 +274,7 @@ RSpec.describe "Spacer" do
|
|
274
274
|
<table class="spacer hide-for-large">
|
275
275
|
<tbody>
|
276
276
|
<tr>
|
277
|
-
<td height="
|
277
|
+
<td height="10" style="font-size:10px;line-height:10px;"> </td>
|
278
278
|
</tr>
|
279
279
|
</tbody>
|
280
280
|
</table>
|
@@ -289,7 +289,7 @@ RSpec.describe "Spacer" do
|
|
289
289
|
<table class="spacer show-for-large">
|
290
290
|
<tbody>
|
291
291
|
<tr>
|
292
|
-
<td height="
|
292
|
+
<td height="20" style="font-size:20px;line-height:20px;"> </td>
|
293
293
|
</tr>
|
294
294
|
</tbody>
|
295
295
|
</table>
|
@@ -304,14 +304,14 @@ RSpec.describe "Spacer" do
|
|
304
304
|
<table class="spacer hide-for-large">
|
305
305
|
<tbody>
|
306
306
|
<tr>
|
307
|
-
<td height="
|
307
|
+
<td height="10" style="font-size:10px;line-height:10px;"> </td>
|
308
308
|
</tr>
|
309
309
|
</tbody>
|
310
310
|
</table>
|
311
311
|
<table class="spacer show-for-large">
|
312
312
|
<tbody>
|
313
313
|
<tr>
|
314
|
-
<td height="
|
314
|
+
<td height="20" style="font-size:20px;line-height:20px;"> </td>
|
315
315
|
</tr>
|
316
316
|
</tbody>
|
317
317
|
</table>
|
@@ -326,7 +326,7 @@ RSpec.describe "Spacer" do
|
|
326
326
|
<table class="spacer bgcolor">
|
327
327
|
<tbody>
|
328
328
|
<tr>
|
329
|
-
<td height="
|
329
|
+
<td height="10" style="font-size:10px;line-height:10px;"> </td>
|
330
330
|
</tr>
|
331
331
|
</tbody>
|
332
332
|
</table>
|
data/spec/configuration_spec.rb
CHANGED
@@ -1,44 +1,114 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe "
|
4
|
-
|
5
|
-
Inky.
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
RSpec.describe "Inky.configuration" do
|
4
|
+
it "returns an Inky::Configuration object" do
|
5
|
+
expect(Inky.configuration).to be_an_instance_of Inky::Configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "=" do
|
9
|
+
it "accepts an Inky::Configuration" do
|
10
|
+
current_config = Inky.configuration
|
11
|
+
config = Inky::Configuration.new
|
12
|
+
|
13
|
+
expect { Inky.configuration = config }.to_not raise_error
|
14
|
+
expect(Inky.configuration).to_not eq(current_config)
|
15
|
+
expect(Inky.configuration).to eq(config)
|
16
|
+
|
17
|
+
expect { Inky.configuration = {} }.to raise_error(TypeError, "Not an Inky::Configuration")
|
18
|
+
expect(Inky.configuration).to eq(config)
|
19
|
+
|
20
|
+
expect { Inky.configuration = current_config }.to_not raise_error
|
21
|
+
expect(Inky.configuration).to eq(current_config)
|
9
22
|
end
|
10
23
|
end
|
11
24
|
|
12
|
-
|
13
|
-
|
25
|
+
describe "&block" do
|
26
|
+
it "yields the current configuration" do
|
27
|
+
current_config = Inky.configuration
|
28
|
+
new_config = Inky::Configuration.new
|
29
|
+
|
30
|
+
Inky.configuration = new_config
|
31
|
+
|
32
|
+
Inky.configuration do |config|
|
33
|
+
expect(config).to be_an_instance_of Inky::Configuration
|
34
|
+
expect(config).to_not eq(current_config)
|
35
|
+
expect(config).to eq(new_config)
|
36
|
+
end
|
37
|
+
|
38
|
+
Inky.configuration = current_config
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
RSpec.describe "Configuration" do
|
44
|
+
describe "#template_engine" do
|
45
|
+
it "default value is :erb" do
|
46
|
+
expect(Inky::Configuration.new.template_engine).to eq(:erb)
|
47
|
+
end
|
14
48
|
end
|
15
49
|
|
16
|
-
describe "#
|
17
|
-
it "
|
50
|
+
describe "#template_engine=" do
|
51
|
+
it "sets/updates the template_engine" do
|
18
52
|
config = Inky::Configuration.new
|
19
53
|
config.template_engine = :haml
|
20
54
|
expect(config.template_engine).to eq(:haml)
|
21
55
|
end
|
22
56
|
|
23
|
-
it "
|
57
|
+
it "accepts symbols" do
|
24
58
|
config = Inky::Configuration.new
|
25
|
-
|
26
|
-
expect
|
59
|
+
value = []
|
60
|
+
expect { config.template_engine = value }.to raise_error(TypeError, "#{value.inspect} (#{value.class}) does not respond to 'to_sym'")
|
61
|
+
expect(config.template_engine).to eq(:erb)
|
27
62
|
end
|
28
63
|
end
|
29
64
|
|
30
|
-
describe "#
|
31
|
-
|
32
|
-
Inky.
|
33
|
-
config.template_engine = :haml
|
34
|
-
end
|
65
|
+
describe "#column_count" do
|
66
|
+
it "default value is 12" do
|
67
|
+
expect(Inky::Configuration.new.column_count).to eq(12)
|
35
68
|
end
|
69
|
+
end
|
36
70
|
|
37
|
-
|
38
|
-
|
71
|
+
describe "#column_count=" do
|
72
|
+
it "sets/updates the column_count" do
|
73
|
+
config = Inky::Configuration.new
|
74
|
+
config.column_count = 24
|
75
|
+
expect(config.column_count).to eq(24)
|
76
|
+
end
|
39
77
|
|
40
|
-
|
41
|
-
|
78
|
+
it "accepts integers" do
|
79
|
+
config = Inky::Configuration.new
|
80
|
+
value = :haml
|
81
|
+
expect { config.column_count = value }.to raise_error(TypeError, "#{value.inspect} (#{value.class}) does not respond to 'to_int'")
|
82
|
+
expect(config.column_count).to eq(12)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#components" do
|
87
|
+
it "defaults to an empty hash" do
|
88
|
+
config = Inky::Configuration.new
|
89
|
+
expect(config.components).to eq({})
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#components=" do
|
94
|
+
it "can set overriden component tags" do
|
95
|
+
config = Inky::Configuration.new
|
96
|
+
config.components = { button: 'inky-button' }
|
97
|
+
expect(config.components).to eq(button: 'inky-button')
|
98
|
+
end
|
99
|
+
|
100
|
+
it "will not set an invalid components override" do
|
101
|
+
config = Inky::Configuration.new
|
102
|
+
[
|
103
|
+
nil,
|
104
|
+
1,
|
105
|
+
"{}",
|
106
|
+
false,
|
107
|
+
true
|
108
|
+
].each do |value|
|
109
|
+
expect { config.components = value }.to raise_error(TypeError, "#{value.inspect} (#{value.class}) does not respond to 'to_hash'")
|
110
|
+
expect(config.components).to eq({})
|
111
|
+
end
|
42
112
|
end
|
43
113
|
end
|
44
114
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,6 +17,9 @@ def reformat_html(html)
|
|
17
17
|
classes = $1.split(' ').sort.join(' ')
|
18
18
|
%{class="#{classes}"}
|
19
19
|
end
|
20
|
+
.gsub(/<td height=".+?px"/) do |m| # Tweak out px until https://github.com/zurb/inky/pull/106 resolved
|
21
|
+
m.gsub('px', '')
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
def expect_same_html(input, expected)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inky-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZURB
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foundation_emails
|
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
- !ruby/object:Gem::Version
|
294
294
|
version: '0'
|
295
295
|
requirements: []
|
296
|
-
rubygems_version: 3.
|
296
|
+
rubygems_version: 3.1.2
|
297
297
|
signing_key:
|
298
298
|
specification_version: 4
|
299
299
|
summary: Inky is an HTML-based templating language that converts simple HTML into
|