inky-email 2.0.0.pre.beta.9 → 2.0.0.pre.beta.10
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 +79 -10
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76d1dace37c6af57ebca01bac83c7e33b933ecda3613fb191c0497fdbcc1c209
|
|
4
|
+
data.tar.gz: 9a047eb4f1b366b81dda1211ee1cf51edf242246f0e7ebfd25dfd1cb995cf3cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8308281ee9453b803f43c8bab17a68d00b39d3c0d21d8832908d266f774de356b394f28161c53c60d167bbcd5a6ad1333d90882124157eab7361ce26a2f191a7
|
|
7
|
+
data.tar.gz: d206d052d716c9aa6169cbcc1f9dfb186e5485aea790bcad14c20523967c72bd6fdf0b38b7fa8f0cb248ca37d6abd62a60bf5c2cfc13c09d5947365e0ccfb2b2
|
data/lib/inky.rb
CHANGED
|
@@ -10,6 +10,23 @@ require "json"
|
|
|
10
10
|
module Inky
|
|
11
11
|
VERSION = "2.0.0"
|
|
12
12
|
|
|
13
|
+
# Raised when the native inky library reports an error.
|
|
14
|
+
class Error < StandardError; end
|
|
15
|
+
|
|
16
|
+
# Raised when the full build pipeline fails.
|
|
17
|
+
class BuildError < Error
|
|
18
|
+
# @return [Array<String>] Non-fatal notes collected before the failure.
|
|
19
|
+
attr_reader :warnings
|
|
20
|
+
|
|
21
|
+
def initialize(message, warnings = [])
|
|
22
|
+
super(message)
|
|
23
|
+
@warnings = warnings
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Result of a full pipeline build.
|
|
28
|
+
BuildResult = Struct.new(:html, :text, :warnings, keyword_init: true)
|
|
29
|
+
|
|
13
30
|
module Native
|
|
14
31
|
extend Fiddle::Importer
|
|
15
32
|
|
|
@@ -52,20 +69,41 @@ module Inky
|
|
|
52
69
|
extern "char* inky_migrate_with_details(const char*)"
|
|
53
70
|
extern "char* inky_validate(const char*)"
|
|
54
71
|
extern "char* inky_version()"
|
|
72
|
+
extern "char* inky_build(const char*, const char*, const char*)"
|
|
55
73
|
extern "void inky_free(char*)"
|
|
56
74
|
end
|
|
57
75
|
|
|
76
|
+
# Copy and free a char* result from libinky. A null pointer signals an
|
|
77
|
+
# internal engine error (or null input).
|
|
78
|
+
def self.string_result(ptr)
|
|
79
|
+
raise Error, "inky native call failed (null result)" if ptr.null?
|
|
80
|
+
|
|
81
|
+
begin
|
|
82
|
+
ptr.to_s
|
|
83
|
+
ensure
|
|
84
|
+
Native.inky_free(ptr)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
private_class_method :string_result
|
|
88
|
+
|
|
89
|
+
def self.check_html!(html)
|
|
90
|
+
raise TypeError, "html must be a String, got #{html.class}" unless html.is_a?(String)
|
|
91
|
+
end
|
|
92
|
+
private_class_method :check_html!
|
|
93
|
+
|
|
58
94
|
# Transform Inky HTML into email-safe table markup.
|
|
59
95
|
#
|
|
60
96
|
# @param html [String] Inky template HTML
|
|
61
97
|
# @param columns [Integer] Number of grid columns (default: 12)
|
|
62
98
|
# @return [String] Transformed HTML
|
|
63
99
|
def self.transform(html, columns: 12)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
100
|
+
check_html!(html)
|
|
101
|
+
ptr = if columns != 12
|
|
102
|
+
Native.inky_transform_with_columns(html, columns)
|
|
103
|
+
else
|
|
104
|
+
Native.inky_transform(html)
|
|
105
|
+
end
|
|
106
|
+
string_result(ptr)
|
|
69
107
|
end
|
|
70
108
|
|
|
71
109
|
# Transform Inky HTML and inline CSS from <style> blocks.
|
|
@@ -73,7 +111,8 @@ module Inky
|
|
|
73
111
|
# @param html [String] Inky template HTML with <style> blocks
|
|
74
112
|
# @return [String] Transformed HTML with CSS inlined
|
|
75
113
|
def self.transform_inline(html)
|
|
76
|
-
|
|
114
|
+
check_html!(html)
|
|
115
|
+
string_result(Native.inky_transform_inline(html))
|
|
77
116
|
end
|
|
78
117
|
|
|
79
118
|
# Migrate v1 Inky syntax to v2.
|
|
@@ -81,7 +120,8 @@ module Inky
|
|
|
81
120
|
# @param html [String] v1 Inky template HTML
|
|
82
121
|
# @return [String] Migrated v2 HTML
|
|
83
122
|
def self.migrate(html)
|
|
84
|
-
|
|
123
|
+
check_html!(html)
|
|
124
|
+
string_result(Native.inky_migrate(html))
|
|
85
125
|
end
|
|
86
126
|
|
|
87
127
|
# Migrate v1 syntax and return detailed results.
|
|
@@ -89,7 +129,8 @@ module Inky
|
|
|
89
129
|
# @param html [String] v1 Inky template HTML
|
|
90
130
|
# @return [Hash] Hash with :html and :changes keys
|
|
91
131
|
def self.migrate_with_details(html)
|
|
92
|
-
|
|
132
|
+
check_html!(html)
|
|
133
|
+
json = string_result(Native.inky_migrate_with_details(html))
|
|
93
134
|
JSON.parse(json, symbolize_names: true)
|
|
94
135
|
end
|
|
95
136
|
|
|
@@ -98,7 +139,8 @@ module Inky
|
|
|
98
139
|
# @param html [String] Inky template HTML
|
|
99
140
|
# @return [Array<Hash>] Array of hashes with :severity, :rule, :message keys
|
|
100
141
|
def self.validate(html)
|
|
101
|
-
|
|
142
|
+
check_html!(html)
|
|
143
|
+
json = string_result(Native.inky_validate(html))
|
|
102
144
|
JSON.parse(json, symbolize_names: true)
|
|
103
145
|
end
|
|
104
146
|
|
|
@@ -106,6 +148,33 @@ module Inky
|
|
|
106
148
|
#
|
|
107
149
|
# @return [String] Version string
|
|
108
150
|
def self.version
|
|
109
|
-
Native.inky_version()
|
|
151
|
+
string_result(Native.inky_version())
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Run the full build pipeline: layouts, includes, custom components,
|
|
155
|
+
# data merge, framework SCSS, component transform, CSS inlining, and
|
|
156
|
+
# output cleanup — identical to `inky build`.
|
|
157
|
+
#
|
|
158
|
+
# @param html [String] Inky template HTML
|
|
159
|
+
# @param base_path [String, nil] Directory used to resolve layouts,
|
|
160
|
+
# includes, custom components, and linked SCSS/CSS
|
|
161
|
+
# @param options [Hash] inline_css, framework_css, components_dir,
|
|
162
|
+
# columns, hybrid, bulletproof_buttons, plain_text, data (Hash of
|
|
163
|
+
# merge variables)
|
|
164
|
+
# @return [BuildResult]
|
|
165
|
+
# @raise [BuildError] if the pipeline fails; carries #warnings
|
|
166
|
+
def self.build(html, base_path: nil, **options)
|
|
167
|
+
check_html!(html)
|
|
168
|
+
options_json = JSON.generate(options)
|
|
169
|
+
|
|
170
|
+
json = string_result(Native.inky_build(html, base_path, options_json))
|
|
171
|
+
envelope = JSON.parse(json, symbolize_names: true)
|
|
172
|
+
|
|
173
|
+
warnings = envelope[:warnings] || []
|
|
174
|
+
unless envelope[:ok]
|
|
175
|
+
raise BuildError.new(envelope[:error] || "unknown build error", warnings)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
BuildResult.new(html: envelope[:html], text: envelope[:text], warnings: warnings)
|
|
110
179
|
end
|
|
111
180
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inky-email
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.pre.beta.
|
|
4
|
+
version: 2.0.0.pre.beta.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ZURB
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Inky converts simple HTML with custom components into email-safe table
|
|
14
14
|
markup. Powered by Rust via Fiddle.
|