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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7f7e3344abd0ff825ff02d118f014a8676c4e150753e6e9096ccdadef07eac8
4
- data.tar.gz: 3c43d307498731879e123ce50baebe9b71e0c203274a495d4ba158ffd0f6c510
3
+ metadata.gz: 48af980ab18545c232dc3fd4f4ee2ebedbfeca066aabe1faa4c3455c2aa4c152
4
+ data.tar.gz: f0b985c040dea524b0004cc90edb81ce8f4920e135d9def3253896a38b75099c
5
5
  SHA512:
6
- metadata.gz: 940a14e38d002673c933da78a80aef9b68adb2a77bf4a243f8cdb134e50a9342e3606c2005792c0411cff79fffa269a711dcf639aad51036481f066630291b24
7
- data.tar.gz: f9b791e61f0f3a4f78a34460f3128dc127c5d067c94e09508f70d8310c6a9af5e8558e81b39fd6b2d7a3202ab54a9f9dbd54510aa81aa7198b58fa8e15e48941
6
+ metadata.gz: 3de872ab2036bd2ffcfb7c6c13aa8a58aee0b208e89da68281547e60a61acc8eaaf7b7f587d08d9672b6c84ad18219e61d7c227a71d47b3a6396c59ebb9dd840
7
+ data.tar.gz: f278877cc37ddf979b7f68fb35d3f333881095203eb40a95b330e217c28cc9708ba658a5466fcb2b171ace3ffd83b60270ec64b781d6a9b6ccdd64a37d728223
@@ -21,7 +21,7 @@ module Inky
21
21
  spacer: 'spacer',
22
22
  wrapper: 'wrapper',
23
23
  menu_item: 'item'
24
- }.merge(options[:components] || {})
24
+ }.merge(::Inky.configuration.components).merge(options[:components] || {})
25
25
 
26
26
  self.component_lookup = components.invert
27
27
 
@@ -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}px" style="font-size:#{size}px;line-height:#{size}px;">&#xA0;</td></tr></tbody></table>} }
129
+ build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}" style="font-size:#{size}px;line-height:#{size}px;">&#xA0;</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')
@@ -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
- attr_accessor :template_engine, :column_count
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
@@ -1,6 +1,6 @@
1
1
  module Inky
2
2
  module Rails
3
- VERSION = '1.3.7.5'.freeze
3
+ VERSION = '1.3.8.0'.freeze
4
4
  end
5
5
  NODE_VERSION, GEM_VERSION = Rails::VERSION.rpartition('.').map(&:freeze)
6
6
  end
@@ -259,7 +259,7 @@ RSpec.describe "Spacer" do
259
259
  <table class="spacer">
260
260
  <tbody>
261
261
  <tr>
262
- <td height="10px" style="font-size:10px;line-height:10px;">&#xA0;</td>
262
+ <td height="10" style="font-size:10px;line-height:10px;">&#xA0;</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="10px" style="font-size:10px;line-height:10px;">&#xA0;</td>
277
+ <td height="10" style="font-size:10px;line-height:10px;">&#xA0;</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="20px" style="font-size:20px;line-height:20px;">&#xA0;</td>
292
+ <td height="20" style="font-size:20px;line-height:20px;">&#xA0;</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="10px" style="font-size:10px;line-height:10px;">&#xA0;</td>
307
+ <td height="10" style="font-size:10px;line-height:10px;">&#xA0;</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="20px" style="font-size:20px;line-height:20px;">&#xA0;</td>
314
+ <td height="20" style="font-size:20px;line-height:20px;">&#xA0;</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="10px" style="font-size:10px;line-height:10px;">&#xA0;</td>
329
+ <td height="10" style="font-size:10px;line-height:10px;">&#xA0;</td>
330
330
  </tr>
331
331
  </tbody>
332
332
  </table>
@@ -1,44 +1,114 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe "Configuration" do
4
- around do |spec|
5
- Inky.configure do |config|
6
- old = config.template_engine
7
- spec.run
8
- config.template_engine = old
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
- it "default value is :erb" do
13
- Inky::Configuration.new.template_engine = :erb
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 "#configuration=" do
17
- it "can set template_engine" do
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 "can set column_count" do
57
+ it "accepts symbols" do
24
58
  config = Inky::Configuration.new
25
- config.column_count = 4
26
- expect(config.column_count).to eq(4)
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 "#configuration=" do
31
- before do
32
- Inky.configure do |config|
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
- it "returns :haml as configured template_engine" do
38
- template_engine = Inky.configuration.template_engine
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
- expect(template_engine).to be_a(Symbol)
41
- expect(template_engine).to eq(:haml)
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
@@ -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.7.5
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: 2019-03-29 00:00:00.000000000 Z
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.0.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