inky-rb 1.3.7.2 → 1.3.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f486e08b00ec2b699b7a5143bf8470fe0cac860c
4
- data.tar.gz: e0c04b5643e02a1d97ee14551e00bc2dca90b386
2
+ SHA256:
3
+ metadata.gz: 6f128cd66f4c50d6498301a720c686a24f75afb6121f7574fcf38ae4e4197e39
4
+ data.tar.gz: 9953f571f49f8fe6712a89331726eca0e1c6756129d75d782e12685190549487
5
5
  SHA512:
6
- metadata.gz: 0e85ff5da6cd267d4422026ebdac6cc0898d8f5fa922f027722662c6e1be212b38e19ee1bf54bb2977446e2e5484dac3f0790f96c8ec136418f84eda1d5ddab1
7
- data.tar.gz: 6d45c612c490c64e1ab555d6fcf197ac622fbac4abdbe75619353b126642f4b7e2b3d093d3be4a634ed0d3122fe133354317128f7e192091510fdbc53c641dd3
6
+ metadata.gz: a0c09ee38d1611662c935d09e4326fde73ff2261ff1cd45f457e693d37b640f4303da063269ae663fdf574564cdc368f0877a8219ade38a174d0f474e6e2ca61
7
+ data.tar.gz: b3154afa14af608c817f92b20a2763de1e681eb8b253aae12e76c85b5c7859e937afd7da7cee3243a86842f20611b69e151ae15291301f0a6d907f2dc66e745c
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.2
1
4
  # Relaxed.Ruby.Style
2
5
 
3
6
  Style/Alias:
@@ -16,7 +19,7 @@ Style/Documentation:
16
19
  Enabled: false
17
20
  StyleGuide: http://relaxed.ruby.style/#styledocumentation
18
21
 
19
- Style/DotPosition:
22
+ Layout/DotPosition:
20
23
  Enabled: false
21
24
  StyleGuide: http://relaxed.ruby.style/#styledotposition
22
25
 
@@ -84,11 +87,11 @@ Style/SingleLineMethods:
84
87
  Enabled: false
85
88
  StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
86
89
 
87
- Style/SpaceBeforeBlockBraces:
90
+ Layout/SpaceBeforeBlockBraces:
88
91
  Enabled: false
89
92
  StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
90
93
 
91
- Style/SpaceInsideParens:
94
+ Layout/SpaceInsideParens:
92
95
  Enabled: false
93
96
  StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
94
97
 
@@ -100,10 +103,6 @@ Style/StringLiterals:
100
103
  Enabled: false
101
104
  StyleGuide: http://relaxed.ruby.style/#stylestringliterals
102
105
 
103
- Style/TrailingCommaInLiteral:
104
- Enabled: false
105
- StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral
106
-
107
106
  Style/WhileUntilModifier:
108
107
  Enabled: false
109
108
  StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
@@ -148,3 +147,11 @@ Lint/HandleExceptions:
148
147
  Exclude:
149
148
  - 'Rakefile'
150
149
  - 'lib/inky.rb'
150
+
151
+ Metrics/BlockLength:
152
+ Exclude:
153
+ - 'Rakefile'
154
+ - 'spec/**/*.rb'
155
+
156
+ Style/Encoding:
157
+ Enabled: false
@@ -2,7 +2,7 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.0.0
5
- - 2.2.5
5
+ - 2.4.1
6
6
  gemfile:
7
7
  - gemfiles/rails_3.gemfile
8
8
  - gemfiles/rails_4.gemfile
@@ -1,153 +1,173 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inky-rb (1.3.7.1)
4
+ inky-rb (1.3.7.2)
5
5
  foundation_emails (~> 2)
6
6
  nokogiri
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionmailer (4.2.7.1)
12
- actionpack (= 4.2.7.1)
13
- actionview (= 4.2.7.1)
14
- activejob (= 4.2.7.1)
11
+ actioncable (5.2.1)
12
+ actionpack (= 5.2.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.1)
16
+ actionpack (= 5.2.1)
17
+ actionview (= 5.2.1)
18
+ activejob (= 5.2.1)
15
19
  mail (~> 2.5, >= 2.5.4)
16
- rails-dom-testing (~> 1.0, >= 1.0.5)
17
- actionpack (4.2.7.1)
18
- actionview (= 4.2.7.1)
19
- activesupport (= 4.2.7.1)
20
- rack (~> 1.6)
21
- rack-test (~> 0.6.2)
22
- rails-dom-testing (~> 1.0, >= 1.0.5)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.2.1)
22
+ actionview (= 5.2.1)
23
+ activesupport (= 5.2.1)
24
+ rack (~> 2.0)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
23
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
24
- actionview (4.2.7.1)
25
- activesupport (= 4.2.7.1)
28
+ actionview (5.2.1)
29
+ activesupport (= 5.2.1)
26
30
  builder (~> 3.1)
27
- erubis (~> 2.7.0)
28
- rails-dom-testing (~> 1.0, >= 1.0.5)
29
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
- activejob (4.2.7.1)
31
- activesupport (= 4.2.7.1)
32
- globalid (>= 0.3.0)
33
- activemodel (4.2.7.1)
34
- activesupport (= 4.2.7.1)
35
- builder (~> 3.1)
36
- activerecord (4.2.7.1)
37
- activemodel (= 4.2.7.1)
38
- activesupport (= 4.2.7.1)
39
- arel (~> 6.0)
40
- activesupport (4.2.7.1)
41
- i18n (~> 0.7)
42
- json (~> 1.7, >= 1.7.7)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (5.2.1)
35
+ activesupport (= 5.2.1)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.2.1)
38
+ activesupport (= 5.2.1)
39
+ activerecord (5.2.1)
40
+ activemodel (= 5.2.1)
41
+ activesupport (= 5.2.1)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.1)
44
+ actionpack (= 5.2.1)
45
+ activerecord (= 5.2.1)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.1)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (>= 0.7, < 2)
43
50
  minitest (~> 5.1)
44
- thread_safe (~> 0.3, >= 0.3.4)
45
51
  tzinfo (~> 1.1)
46
- addressable (2.3.8)
47
- arel (6.0.3)
48
- ast (2.3.0)
49
- builder (3.2.2)
50
- capybara (2.7.0)
52
+ addressable (2.5.2)
53
+ public_suffix (>= 2.0.2, < 4.0)
54
+ arel (9.0.0)
55
+ ast (2.4.0)
56
+ builder (3.2.3)
57
+ capybara (3.9.0)
51
58
  addressable
52
- mime-types (>= 1.16)
53
- nokogiri (>= 1.3.3)
54
- rack (>= 1.0.0)
55
- rack-test (>= 0.5.4)
56
- xpath (~> 2.0)
57
- concurrent-ruby (1.0.2)
58
- diff-lcs (1.2.5)
59
- erubis (2.7.0)
59
+ mini_mime (>= 0.1.3)
60
+ nokogiri (~> 1.8)
61
+ rack (>= 1.6.0)
62
+ rack-test (>= 0.6.3)
63
+ xpath (~> 3.1)
64
+ concurrent-ruby (1.0.5)
65
+ crass (1.0.4)
66
+ diff-lcs (1.3)
67
+ erubi (1.7.1)
60
68
  foundation_emails (2.2.1.0)
61
- globalid (0.3.7)
62
- activesupport (>= 4.1.0)
63
- i18n (0.7.0)
64
- json (1.8.3)
65
- loofah (2.0.3)
69
+ globalid (0.4.1)
70
+ activesupport (>= 4.2.0)
71
+ i18n (1.1.1)
72
+ concurrent-ruby (~> 1.0)
73
+ jaro_winkler (1.5.1)
74
+ loofah (2.2.2)
75
+ crass (~> 1.0.2)
66
76
  nokogiri (>= 1.5.9)
67
- mail (2.6.4)
68
- mime-types (>= 1.16, < 4)
69
- mime-types (3.1)
70
- mime-types-data (~> 3.2015)
71
- mime-types-data (3.2016.0521)
72
- mini_portile2 (2.1.0)
73
- minitest (5.9.1)
74
- nokogiri (1.6.8.1)
75
- mini_portile2 (~> 2.1.0)
76
- parser (2.3.1.4)
77
- ast (~> 2.2)
78
- powerpack (0.1.1)
79
- rack (1.6.4)
80
- rack-test (0.6.3)
81
- rack (>= 1.0)
82
- rails (4.2.7.1)
83
- actionmailer (= 4.2.7.1)
84
- actionpack (= 4.2.7.1)
85
- actionview (= 4.2.7.1)
86
- activejob (= 4.2.7.1)
87
- activemodel (= 4.2.7.1)
88
- activerecord (= 4.2.7.1)
89
- activesupport (= 4.2.7.1)
90
- bundler (>= 1.3.0, < 2.0)
91
- railties (= 4.2.7.1)
92
- sprockets-rails
93
- rails-deprecated_sanitizer (1.0.3)
94
- activesupport (>= 4.2.0.alpha)
95
- rails-dom-testing (1.0.7)
96
- activesupport (>= 4.2.0.beta, < 5.0)
97
- nokogiri (~> 1.6.0)
98
- rails-deprecated_sanitizer (>= 1.0.1)
99
- rails-html-sanitizer (1.0.3)
100
- loofah (~> 2.0)
101
- railties (4.2.7.1)
102
- actionpack (= 4.2.7.1)
103
- activesupport (= 4.2.7.1)
77
+ mail (2.7.1)
78
+ mini_mime (>= 0.1.1)
79
+ marcel (0.3.3)
80
+ mimemagic (~> 0.3.2)
81
+ method_source (0.9.0)
82
+ mimemagic (0.3.2)
83
+ mini_mime (1.0.1)
84
+ mini_portile2 (2.3.0)
85
+ minitest (5.11.3)
86
+ nio4r (2.3.1)
87
+ nokogiri (1.8.5)
88
+ mini_portile2 (~> 2.3.0)
89
+ parallel (1.12.1)
90
+ parser (2.5.1.2)
91
+ ast (~> 2.4.0)
92
+ powerpack (0.1.2)
93
+ public_suffix (3.0.3)
94
+ rack (2.0.5)
95
+ rack-test (1.1.0)
96
+ rack (>= 1.0, < 3)
97
+ rails (5.2.1)
98
+ actioncable (= 5.2.1)
99
+ actionmailer (= 5.2.1)
100
+ actionpack (= 5.2.1)
101
+ actionview (= 5.2.1)
102
+ activejob (= 5.2.1)
103
+ activemodel (= 5.2.1)
104
+ activerecord (= 5.2.1)
105
+ activestorage (= 5.2.1)
106
+ activesupport (= 5.2.1)
107
+ bundler (>= 1.3.0)
108
+ railties (= 5.2.1)
109
+ sprockets-rails (>= 2.0.0)
110
+ rails-dom-testing (2.0.3)
111
+ activesupport (>= 4.2.0)
112
+ nokogiri (>= 1.6)
113
+ rails-html-sanitizer (1.0.4)
114
+ loofah (~> 2.2, >= 2.2.2)
115
+ railties (5.2.1)
116
+ actionpack (= 5.2.1)
117
+ activesupport (= 5.2.1)
118
+ method_source
104
119
  rake (>= 0.8.7)
105
- thor (>= 0.18.1, < 2.0)
106
- rainbow (2.1.0)
107
- rake (11.3.0)
108
- rspec-core (3.5.0)
109
- rspec-support (~> 3.5.0)
110
- rspec-expectations (3.5.0)
120
+ thor (>= 0.19.0, < 2.0)
121
+ rainbow (3.0.0)
122
+ rake (12.3.1)
123
+ rspec-core (3.8.0)
124
+ rspec-support (~> 3.8.0)
125
+ rspec-expectations (3.8.2)
111
126
  diff-lcs (>= 1.2.0, < 2.0)
112
- rspec-support (~> 3.5.0)
113
- rspec-mocks (3.5.0)
127
+ rspec-support (~> 3.8.0)
128
+ rspec-mocks (3.8.0)
114
129
  diff-lcs (>= 1.2.0, < 2.0)
115
- rspec-support (~> 3.5.0)
116
- rspec-rails (3.5.2)
130
+ rspec-support (~> 3.8.0)
131
+ rspec-rails (3.8.0)
117
132
  actionpack (>= 3.0)
118
133
  activesupport (>= 3.0)
119
134
  railties (>= 3.0)
120
- rspec-core (~> 3.5.0)
121
- rspec-expectations (~> 3.5.0)
122
- rspec-mocks (~> 3.5.0)
123
- rspec-support (~> 3.5.0)
124
- rspec-support (3.5.0)
125
- rubocop (0.43.0)
126
- parser (>= 2.3.1.1, < 3.0)
135
+ rspec-core (~> 3.8.0)
136
+ rspec-expectations (~> 3.8.0)
137
+ rspec-mocks (~> 3.8.0)
138
+ rspec-support (~> 3.8.0)
139
+ rspec-support (3.8.0)
140
+ rubocop (0.59.2)
141
+ jaro_winkler (~> 1.5.1)
142
+ parallel (~> 1.10)
143
+ parser (>= 2.5, != 2.5.1.1)
127
144
  powerpack (~> 0.1)
128
- rainbow (>= 1.99.1, < 3.0)
145
+ rainbow (>= 2.2.2, < 4.0)
129
146
  ruby-progressbar (~> 1.7)
130
147
  unicode-display_width (~> 1.0, >= 1.0.1)
131
- ruby-progressbar (1.7.5)
132
- slim (3.0.6)
133
- temple (~> 0.7.3)
134
- tilt (>= 1.3.3, < 2.1)
135
- sprockets (3.7.0)
148
+ ruby-progressbar (1.10.0)
149
+ slim (4.0.1)
150
+ temple (>= 0.7.6, < 0.9)
151
+ tilt (>= 2.0.6, < 2.1)
152
+ sprockets (3.7.2)
136
153
  concurrent-ruby (~> 1.0)
137
154
  rack (> 1, < 3)
138
- sprockets-rails (3.2.0)
155
+ sprockets-rails (3.2.1)
139
156
  actionpack (>= 4.0)
140
157
  activesupport (>= 4.0)
141
158
  sprockets (>= 3.0.0)
142
- temple (0.7.6)
143
- thor (0.19.1)
144
- thread_safe (0.3.5)
145
- tilt (1.4.1)
146
- tzinfo (1.2.2)
159
+ temple (0.8.0)
160
+ thor (0.20.0)
161
+ thread_safe (0.3.6)
162
+ tilt (2.0.8)
163
+ tzinfo (1.2.5)
147
164
  thread_safe (~> 0.1)
148
- unicode-display_width (1.1.1)
149
- xpath (2.0.0)
150
- nokogiri (~> 1.3)
165
+ unicode-display_width (1.4.0)
166
+ websocket-driver (0.7.0)
167
+ websocket-extensions (>= 0.1.0)
168
+ websocket-extensions (0.1.3)
169
+ xpath (3.2.0)
170
+ nokogiri (~> 1.8)
151
171
 
152
172
  PLATFORMS
153
173
  ruby
@@ -165,4 +185,4 @@ DEPENDENCIES
165
185
  slim
166
186
 
167
187
  BUNDLED WITH
168
- 1.13.6
188
+ 1.16.4
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013-2018 ZURB, inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -108,6 +108,29 @@ welcome.html.haml => welcome.html.inky-haml
108
108
  pw_reset.html.erb => pw_reset.html.inky-erb
109
109
  ```
110
110
 
111
+ ## Other options
112
+
113
+ ### Column Count
114
+
115
+ You can change the column count in the initializer too:
116
+
117
+ ```ruby
118
+ # config/initializers/inky.rb
119
+ Inky.configure do |config|
120
+ config.column_count = 24
121
+ end
122
+ ```
123
+
124
+ Make sure to change the SASS variable as well:
125
+
126
+ ```sass
127
+ # assets/stylesheets/foundation_emails.scss
128
+ # ...
129
+ $grid-column-count: 24;
130
+
131
+ @import "foundation-emails";
132
+ ```
133
+
111
134
  ## Custom Elements
112
135
 
113
136
  Inky simplifies the process of creating HTML emails by expanding out simple tags like `<row>` and `<column>` into full table syntax. The names of the tags can be changed with the `components` setting.
data/Rakefile CHANGED
@@ -9,6 +9,6 @@ begin
9
9
  rescue LoadError
10
10
  end
11
11
 
12
- task test_all: [:spec, :rubocop]
12
+ task test_all: %i[spec rubocop]
13
13
 
14
14
  task default: :test_all
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "rails", "~>3.0"
4
4
 
5
- gemspec :path => "../"
5
+ gemspec path: "../"
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "rails", "~>4.0"
4
4
 
5
- gemspec :path => "../"
5
+ gemspec path: "../"
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "rails", "~>5.0"
4
4
 
5
- gemspec :path => "../"
5
+ gemspec path: "../"
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'inky/rails/version'
4
4
 
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.authors = ["ZURB"]
11
11
  s.email = ['foundation@zurb.com']
12
12
  s.homepage = 'https://github.com/zurb/inky-rb'
13
+ s.licenses = ['MIT']
13
14
 
14
15
  s.files = `git ls-files -z`.split("\x0")
15
16
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -18,11 +19,11 @@ Gem::Specification.new do |s|
18
19
  s.add_dependency "foundation_emails", "~> 2"
19
20
  s.add_dependency "nokogiri"
20
21
  s.add_development_dependency "bundler", "~> 1.6"
21
- s.add_development_dependency "rake"
22
- s.add_development_dependency "rubocop"
23
- s.add_development_dependency "rspec-rails"
24
22
  s.add_development_dependency "capybara"
25
23
  s.add_development_dependency "rails"
24
+ s.add_development_dependency "rake"
25
+ s.add_development_dependency "rspec-rails"
26
+ s.add_development_dependency "rubocop"
26
27
  s.add_development_dependency "slim"
27
28
  # s.add_development_dependency "pry-byebug"
28
29
  end
@@ -12,6 +12,7 @@ module Inky
12
12
 
13
13
  def preserve_original_mailer_layout
14
14
  return unless layout_name == 'mailer' && extension == 'erb'
15
+
15
16
  original_mailer = File.join(layouts_base_dir, "mailer.html.erb")
16
17
  rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb")
17
18
  File.rename(original_mailer, rename_filename) if File.exist? original_mailer
@@ -25,19 +25,21 @@ module Inky
25
25
 
26
26
  self.component_lookup = components.invert
27
27
 
28
- self.column_count = options[:column_count] || 12
28
+ self.column_count = options[:column_count] || ::Inky.configuration.column_count
29
29
 
30
30
  self.component_tags = components.values
31
31
  end
32
32
 
33
33
  def release_the_kraken(html_string)
34
- html_string.force_encoding('utf-8') # transform_doc barfs if encoding is ASCII-8bit
34
+ if html_string.encoding.name == "ASCII-8BIT"
35
+ html_string.force_encoding('utf-8') # transform_doc barfs if encoding is ASCII-8bit
36
+ end
35
37
  html_string = html_string.gsub(/doctype/i, 'DOCTYPE')
36
38
  raws, str = Inky::Core.extract_raws(html_string)
37
39
  parse_cmd = str =~ /<html/i ? :parse : :fragment
38
40
  html = Nokogiri::HTML.public_send(parse_cmd, str)
39
41
  transform_doc(html)
40
- string = html.to_html(encoding: 'US-ASCII')
42
+ string = html.to_html
41
43
  Inky::Core.re_inject_raws(string, raws)
42
44
  end
43
45
 
@@ -3,6 +3,7 @@ module Inky
3
3
  def component_factory(elem)
4
4
  transform_method = :"_transform_#{component_lookup[elem.name]}"
5
5
  return unless respond_to?(transform_method)
6
+
6
7
  inner = elem.children.map(&:to_s).join
7
8
  send(transform_method, elem, inner)
8
9
  end
@@ -22,7 +23,10 @@ module Inky
22
23
  end
23
24
 
24
25
  def _combine_classes(elem, extra_classes)
25
- [elem['class'], extra_classes].join(' ')
26
+ existing = elem['class'].to_s.split(' ')
27
+ to_add = extra_classes.to_s.split(' ')
28
+
29
+ (existing + to_add).uniq.join(' ')
26
30
  end
27
31
 
28
32
  def _combine_attributes(elem, extra_classes = nil)
@@ -15,6 +15,7 @@ module Inky
15
15
  # ```
16
16
  # Inky.configure do |config|
17
17
  # config.template_engine = :slim
18
+ # config.column_count = 24
18
19
  # end
19
20
  # ```
20
21
  def self.configure
@@ -22,10 +23,11 @@ module Inky
22
23
  end
23
24
 
24
25
  class Configuration
25
- attr_accessor :template_engine
26
+ attr_accessor :template_engine, :column_count
26
27
 
27
28
  def initialize
28
29
  @template_engine = :erb
30
+ @column_count = 12
29
31
  end
30
32
  end
31
33
  end
@@ -7,6 +7,7 @@ module Inky
7
7
 
8
8
  def engine_handler
9
9
  return @engine_handler if @engine_handler
10
+
10
11
  type = ::Inky.configuration.template_engine
11
12
  ActionView::Template.registered_template_handler(type) ||
12
13
  raise("No template handler found for #{type}")
@@ -14,6 +15,7 @@ module Inky
14
15
 
15
16
  def call(template)
16
17
  compiled_source = engine_handler.call(template)
18
+
17
19
  "Inky::Core.new.release_the_kraken(begin; #{compiled_source};end)"
18
20
  end
19
21
 
@@ -1,6 +1,6 @@
1
1
  module Inky
2
2
  module Rails
3
- VERSION = "1.3.7.2".freeze
3
+ VERSION = '1.3.7.3'.freeze
4
4
  end
5
5
  NODE_VERSION, GEM_VERSION = Rails::VERSION.rpartition('.').map(&:freeze)
6
6
  end
@@ -5,51 +5,55 @@ INKY_VERSION_REQUIRED = Inky::NODE_VERSION
5
5
 
6
6
  def npm_packages
7
7
  JSON.parse(`npm list -g --depth=1 --json=true`)
8
- rescue
9
- puts <<-Err
8
+ rescue SystemCallError, JSON::ParserError
9
+ puts <<-ERR
10
10
  npm not detected, skipping comparison tests.
11
- Err
11
+ ERR
12
12
  nil
13
13
  end
14
14
 
15
15
  def inky_cli_ok?
16
16
  return unless packages = npm_packages
17
+
17
18
  version = packages['dependencies']['inky-cli']['dependencies']['inky']['version']
18
19
  return true if version >= INKY_VERSION_REQUIRED
20
+
19
21
  puts "Requires inky version #{INKY_VERSION_REQUIRED}+, currently installed #{version}"
20
22
  false
21
- rescue
22
- puts <<-Err
23
+ rescue NoMethodError
24
+ puts <<-ERR
23
25
  inky-cli not globally installed, skipping comparison tests.
24
26
  Install with:
25
27
  npm install inky-cli -g
26
- Err
28
+ ERR
27
29
  false
28
30
  end
29
31
 
30
32
  RSpec.describe "Inky-rb" do
31
- context "compared to inky-cli" do
32
- Dir['./spec/cases/*'].each do |path|
33
- folder = File.basename(path)
34
- output_path = "./spec/_cases_output/#{File.basename(folder)}"
35
- sources = "#{path}/*.inky"
36
- source_paths = Dir[sources]
37
-
38
- context "for #{folder} components" do
39
- before(:all) do
40
- shell = source_paths.map { |p| "inky #{p} #{output_path}" }
41
- `#{shell.join(' && ')}`
42
- end
33
+ if inky_cli_ok?
34
+ context "compared to inky-cli" do
35
+ Dir['./spec/cases/*'].each do |path|
36
+ folder = File.basename(path)
37
+ output_path = "./spec/_cases_output/#{File.basename(folder)}"
38
+ sources = "#{path}/*.inky"
39
+ source_paths = Dir[sources]
40
+
41
+ context "for #{folder} components" do
42
+ before(:all) do
43
+ shell = source_paths.map { |p| "inky #{p} #{output_path}" }
44
+ `#{shell.join(' && ')}`
45
+ end
43
46
 
44
- source_paths.each do |filepath|
45
- file = File.basename(filepath, '.inky')
46
- content = File.read(filepath)
47
- exec = content =~ /^<!--\s*(pending|skip)/ ? $1 : :it
48
- send exec, "provides the same results for #{file}" do
49
- compare(content, File.read("#{output_path}/#{file}.inky"))
47
+ source_paths.each do |filepath|
48
+ file = File.basename(filepath, '.inky')
49
+ content = File.read(filepath)
50
+ exec = content =~ /^<!--\s*(pending|skip)/ ? $1 : :it
51
+ send exec, "provides the same results for #{file}" do
52
+ compare(content, File.read("#{output_path}/#{file}.inky"))
53
+ end
50
54
  end
51
55
  end
52
56
  end
53
57
  end
54
- end if inky_cli_ok?
58
+ end
55
59
  end
@@ -14,11 +14,17 @@ RSpec.describe "Configuration" do
14
14
  end
15
15
 
16
16
  describe "#configuration=" do
17
- it "can set value" do
17
+ it "can set template_engine" do
18
18
  config = Inky::Configuration.new
19
19
  config.template_engine = :haml
20
20
  expect(config.template_engine).to eq(:haml)
21
21
  end
22
+
23
+ it "can set column_count" do
24
+ config = Inky::Configuration.new
25
+ config.column_count = 4
26
+ expect(config.column_count).to eq(4)
27
+ end
22
28
  end
23
29
 
24
30
  describe "#configuration=" do
@@ -18,7 +18,7 @@ RSpec.describe "Container" do
18
18
  it 'works when parsing a full HTML document' do
19
19
  input = <<-INKY
20
20
  <!doctype html> <html>
21
- <head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"></head>
21
+ <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
22
22
  <body>
23
23
  <container></container>
24
24
  </body>
@@ -27,7 +27,7 @@ RSpec.describe "Container" do
27
27
  expected = <<-HTML
28
28
  <!DOCTYPE html>
29
29
  <html>
30
- <head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"></head>
30
+ <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
31
31
  <body>
32
32
  <table class="container" align="center">
33
33
  <tbody>
@@ -57,6 +57,50 @@ RSpec.describe 'Grid' do
57
57
  compare(input, expected)
58
58
  end
59
59
 
60
+ it 'creates a single column with default large and small classes' do
61
+ input = '<columns>One</columns>'
62
+ expected = <<-HTML
63
+ <th class="small-12 large-12 columns first last">
64
+ <table>
65
+ <tr>
66
+ <th>One</th>
67
+ <th class="expander"></th>
68
+ </tr>
69
+ </table>
70
+ </th>
71
+ HTML
72
+
73
+ compare(input, expected)
74
+ end
75
+
76
+ it 'creates a single column with default large and small classes using the column_count option' do
77
+ begin
78
+ @previous_column_count = Inky.configuration.column_count
79
+
80
+ Inky.configure do |config|
81
+ config.column_count = 5
82
+ end
83
+
84
+ input = '<columns>One</columns>'
85
+ expected = <<-HTML
86
+ <th class="small-5 large-5 columns first last">
87
+ <table>
88
+ <tr>
89
+ <th>One</th>
90
+ <th class="expander"></th>
91
+ </tr>
92
+ </table>
93
+ </th>
94
+ HTML
95
+
96
+ compare(input, expected)
97
+ ensure
98
+ Inky.configure do |config|
99
+ config.column_count = @previous_column_count
100
+ end
101
+ end
102
+ end
103
+
60
104
  it 'creates a single column with first and last classes' do
61
105
  input = '<columns large="12" small="12">One</columns>'
62
106
  expected = <<-HTML
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe "Inky#release_the_kraken" do
@@ -16,4 +18,37 @@ RSpec.describe "Inky#release_the_kraken" do
16
18
  output = Inky::Core.new.release_the_kraken(input)
17
19
  expect_same_html(output, expected)
18
20
  end
21
+
22
+ it "works on utf-8 text" do
23
+ input = '<container><p>Güten tag Marc-André</p></container>'
24
+ expected = <<-HTML
25
+ <table class="container" align="center">
26
+ <tbody>
27
+ <tr>
28
+ <td><p>Güten tag Marc-André</p></td>
29
+ </tr>
30
+ </tbody>
31
+ </table>
32
+ HTML
33
+
34
+ output = Inky::Core.new.release_the_kraken(input)
35
+ expect_same_html(output, expected)
36
+ end
37
+
38
+ it "works on US-ASCII text" do
39
+ input = '<container><p>G&#252;ten tag Marc-Andr&#233;</p></container>'.force_encoding("us-ascii")
40
+ expected = <<-HTML
41
+ <table class="container" align="center">
42
+ <tbody>
43
+ <tr>
44
+ <td><p>G&#252;ten tag Marc-Andr&#233;</p></td>
45
+ </tr>
46
+ </tbody>
47
+ </table>
48
+ HTML
49
+
50
+ output = Inky::Core.new.release_the_kraken(input)
51
+ expect_same_html(output, expected)
52
+ output.encoding.name.should == 'US-ASCII'
53
+ end
19
54
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'inky'
2
4
 
3
5
  def reformat_html(html)
@@ -8,7 +10,7 @@ def reformat_html(html)
8
10
  .gsub(/ "/, '"').gsub(/\=" /, '="') # Remove leading/trailing spaces inside attributes
9
11
  .gsub(/ </, '<').gsub(/> /, '>') # Remove leading/trailing spaces inside tags
10
12
  .gsub(' data-parsed=""', '') # Don't consider this known inky-node artefact
11
- .gsub('&#xA0', '&#160') # These are the same entity...
13
+ .gsub('&#xA0;', ' ') # These are the same entity...
12
14
  .gsub(/(align="[^"]+") (class="[^"]+")/, '\2 \1') # Tweak order to match inky-node on container
13
15
  .gsub(/class\="([^"]+)"/) do # Sort class names
14
16
  classes = $1.split(' ').sort.join(' ')
@@ -17,9 +17,11 @@ Rails.application.configure do
17
17
  config.action_controller.perform_caching = true
18
18
 
19
19
  config.cache_store = :memory_store
20
- config.public_file_server.headers = {
21
- 'Cache-Control' => 'public, max-age=172800'
22
- } if config.respond_to? :public_file_server
20
+ if config.respond_to? :public_file_server
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => 'public, max-age=172800'
23
+ }
24
+ end
23
25
  else
24
26
  config.action_controller.perform_caching = false
25
27
 
@@ -53,7 +53,7 @@ describe 'Rails', type: :feature do
53
53
  <!DOCTYPE html>
54
54
  <html>
55
55
  <head>
56
- <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
56
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
57
57
  <title>inky : layout</title>
58
58
  </head>
59
59
  <body>
@@ -9,6 +9,6 @@ require 'slim'
9
9
 
10
10
  Rails.backtrace_cleaner.remove_silencers!
11
11
  RSpec.configure do |config|
12
- config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
12
+ config.expect_with(:rspec) { |c| c.syntax = %i[should expect] }
13
13
  # config.infer_spec_type_from_file_location!
14
14
  end
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.2
4
+ version: 1.3.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZURB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foundation_emails
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: capybara
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec-rails
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: capybara
98
+ name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rails
112
+ name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -150,6 +150,7 @@ files:
150
150
  - ".travis.yml"
151
151
  - Gemfile
152
152
  - Gemfile.lock
153
+ - LICENSE.txt
153
154
  - README.md
154
155
  - Rakefile
155
156
  - gemfiles/rails_3.gemfile
@@ -244,7 +245,8 @@ files:
244
245
  - spec/test_app/spec/features/inky_spec.rb
245
246
  - spec/test_app/spec/helper.rb
246
247
  homepage: https://github.com/zurb/inky-rb
247
- licenses: []
248
+ licenses:
249
+ - MIT
248
250
  metadata: {}
249
251
  post_install_message:
250
252
  rdoc_options: []
@@ -262,85 +264,85 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
264
  version: '0'
263
265
  requirements: []
264
266
  rubyforge_project:
265
- rubygems_version: 2.5.1
267
+ rubygems_version: 2.7.6
266
268
  signing_key:
267
269
  specification_version: 4
268
270
  summary: Inky is an HTML-based templating language that converts simple HTML into
269
271
  complex, responsive email-ready HTML. Designed for Foundation for Emails, a responsive
270
272
  email framework from ZURB.
271
273
  test_files:
272
- - spec/cases/button/no_link.inky
273
- - spec/cases/button/with_expand_class.inky
274
- - spec/cases/button/with_image.inky
275
- - spec/cases/button/with_link.inky
276
- - spec/cases/button/with_tricky_class.inky
277
- - spec/cases/callout/basic.inky
278
- - spec/cases/callout/with_attributes.inky
279
- - spec/cases/general/multiple_root.inky
280
- - spec/cases/general/no_tag.inky
281
- - spec/cases/general/root_within_text.inky
282
- - spec/cases/general/void_html_elements.inky
283
- - spec/cases/grid/columns.inky
284
- - spec/cases/grid/container.inky
285
- - spec/cases/grid/container_with_align.inky
286
- - spec/cases/grid/row.inky
287
- - spec/cases/grid/row_with_columns.inky
288
- - spec/cases/menu/item.inky
289
- - spec/cases/menu/menu.inky
290
- - spec/cases/menu/menu_with_align.inky
291
- - spec/cases/menu/menu_with_items.inky
292
- - spec/cases/spacer/basic.inky
293
- - spec/cases/spacer/with_size.inky
294
- - spec/cases/spacer/with_size_lg.inky
295
- - spec/cases/spacer/with_size_sm.inky
296
- - spec/cases/spacer/with_size_sm_and_lg.inky
297
- - spec/cases/wrapper/basic.inky
298
- - spec/cases/wrapper/with_align.inky
299
- - spec/cases/wrapper/with_attributes.inky
300
- - spec/cases_spec.rb
301
- - spec/components_spec.rb
302
- - spec/configuration_spec.rb
303
- - spec/grid_spec.rb
304
- - spec/inky_spec.rb
305
274
  - spec/spec_helper.rb
275
+ - spec/test_app/app/mailers/application_mailer.rb
306
276
  - spec/test_app/app/controllers/application_controller.rb
307
277
  - spec/test_app/app/controllers/inky_controller.rb
308
- - spec/test_app/app/helpers/application_helper.rb
309
- - spec/test_app/app/mailers/application_mailer.rb
310
- - spec/test_app/app/views/inky/_inky_partial.html.inky
311
- - spec/test_app/app/views/inky/explicit_builder.html.inky-builder
312
- - spec/test_app/app/views/inky/explicit_slim.html.inky-slim
278
+ - spec/test_app/app/views/inky/simple.html.inky
313
279
  - spec/test_app/app/views/inky/layout.html.erb
280
+ - spec/test_app/app/views/inky/explicit_slim.html.inky-slim
281
+ - spec/test_app/app/views/inky/_inky_partial.html.inky
314
282
  - spec/test_app/app/views/inky/non_inky.html.erb
315
- - spec/test_app/app/views/inky/simple.html.inky
283
+ - spec/test_app/app/views/inky/explicit_builder.html.inky-builder
316
284
  - spec/test_app/app/views/inky/slim.html.inky
317
- - spec/test_app/app/views/layouts/application.html.erb
318
285
  - spec/test_app/app/views/layouts/inky_layout.html.inky
319
- - spec/test_app/config/application.rb
320
- - spec/test_app/config/boot.rb
286
+ - spec/test_app/app/views/layouts/application.html.erb
287
+ - spec/test_app/app/helpers/application_helper.rb
288
+ - spec/test_app/config/secrets.yml
289
+ - spec/test_app/config/routes.rb
290
+ - spec/test_app/config/locales/en.yml
321
291
  - spec/test_app/config/cable.yml
322
- - spec/test_app/config/database.yml
323
- - spec/test_app/config/environment.rb
324
- - spec/test_app/config/environments/development.rb
325
292
  - spec/test_app/config/environments/production.rb
293
+ - spec/test_app/config/environments/development.rb
326
294
  - spec/test_app/config/environments/test.rb
295
+ - spec/test_app/config/spring.rb
296
+ - spec/test_app/config/environment.rb
297
+ - spec/test_app/config/application.rb
298
+ - spec/test_app/config/puma.rb
299
+ - spec/test_app/config/database.yml
300
+ - spec/test_app/config/boot.rb
327
301
  - spec/test_app/config/initializers/application_controller_renderer.rb
328
- - spec/test_app/config/initializers/assets.rb
329
302
  - spec/test_app/config/initializers/backtrace_silencers.rb
330
- - spec/test_app/config/initializers/cookies_serializer.rb
331
- - spec/test_app/config/initializers/filter_parameter_logging.rb
332
- - spec/test_app/config/initializers/inflections.rb
333
303
  - spec/test_app/config/initializers/mime_types.rb
334
- - spec/test_app/config/initializers/new_framework_defaults.rb
335
- - spec/test_app/config/initializers/secret_token.rb
304
+ - spec/test_app/config/initializers/filter_parameter_logging.rb
336
305
  - spec/test_app/config/initializers/session_store.rb
337
306
  - spec/test_app/config/initializers/wrap_parameters.rb
338
- - spec/test_app/config/locales/en.yml
339
- - spec/test_app/config/puma.rb
340
- - spec/test_app/config/routes.rb
341
- - spec/test_app/config/secrets.yml
342
- - spec/test_app/config/spring.rb
307
+ - spec/test_app/config/initializers/new_framework_defaults.rb
308
+ - spec/test_app/config/initializers/assets.rb
309
+ - spec/test_app/config/initializers/cookies_serializer.rb
310
+ - spec/test_app/config/initializers/secret_token.rb
311
+ - spec/test_app/config/initializers/inflections.rb
343
312
  - spec/test_app/config.ru
344
- - spec/test_app/Rakefile
345
- - spec/test_app/spec/features/inky_spec.rb
346
313
  - spec/test_app/spec/helper.rb
314
+ - spec/test_app/spec/features/inky_spec.rb
315
+ - spec/test_app/Rakefile
316
+ - spec/cases_spec.rb
317
+ - spec/grid_spec.rb
318
+ - spec/configuration_spec.rb
319
+ - spec/cases/wrapper/basic.inky
320
+ - spec/cases/wrapper/with_align.inky
321
+ - spec/cases/wrapper/with_attributes.inky
322
+ - spec/cases/general/no_tag.inky
323
+ - spec/cases/general/multiple_root.inky
324
+ - spec/cases/general/void_html_elements.inky
325
+ - spec/cases/general/root_within_text.inky
326
+ - spec/cases/spacer/basic.inky
327
+ - spec/cases/spacer/with_size_sm.inky
328
+ - spec/cases/spacer/with_size_lg.inky
329
+ - spec/cases/spacer/with_size_sm_and_lg.inky
330
+ - spec/cases/spacer/with_size.inky
331
+ - spec/cases/callout/basic.inky
332
+ - spec/cases/callout/with_attributes.inky
333
+ - spec/cases/button/with_tricky_class.inky
334
+ - spec/cases/button/with_expand_class.inky
335
+ - spec/cases/button/with_link.inky
336
+ - spec/cases/button/no_link.inky
337
+ - spec/cases/button/with_image.inky
338
+ - spec/cases/menu/menu_with_items.inky
339
+ - spec/cases/menu/menu_with_align.inky
340
+ - spec/cases/menu/menu.inky
341
+ - spec/cases/menu/item.inky
342
+ - spec/cases/grid/row.inky
343
+ - spec/cases/grid/row_with_columns.inky
344
+ - spec/cases/grid/columns.inky
345
+ - spec/cases/grid/container.inky
346
+ - spec/cases/grid/container_with_align.inky
347
+ - spec/components_spec.rb
348
+ - spec/inky_spec.rb