inky-email 2.0.0.pre.beta.2
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 +7 -0
- data/lib/inky.rb +111 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c6f7ec824af6f8d7f81c2aa48f6fa897a11ef7ed1c93dea08b5c5f4d164ac249
|
|
4
|
+
data.tar.gz: 200de3c595617419968edf302b01fc9a1755ef4728d64064becc4e225bd4f45e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e21c3b34435d8347430bb9b21d584eabd75959b90360567e94767057b8fd92104b76b92e77d184e4512f3b74045cd84929fd72fd289455089efd695c2ab2521c
|
|
7
|
+
data.tar.gz: 1c0e50f58f8607b6188d26a90aa1c6dc4642d4203b91af72232ff120eeb05885469b42963b77e2a1ba66768ba08c72b8d08096f2188e4eb55c98d495fdcf94fb
|
data/lib/inky.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fiddle"
|
|
4
|
+
require "fiddle/import"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
# Inky — Transform email templates into email-safe HTML.
|
|
8
|
+
#
|
|
9
|
+
# Powered by Rust via Fiddle FFI.
|
|
10
|
+
module Inky
|
|
11
|
+
VERSION = "2.0.0"
|
|
12
|
+
|
|
13
|
+
module Native
|
|
14
|
+
extend Fiddle::Importer
|
|
15
|
+
|
|
16
|
+
LIB_NAMES = case RUBY_PLATFORM
|
|
17
|
+
when /darwin/ then ["libinky.dylib"]
|
|
18
|
+
when /mingw|mswin/ then ["inky.dll"]
|
|
19
|
+
else ["libinky.so"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.find_library
|
|
23
|
+
name = LIB_NAMES.first
|
|
24
|
+
candidates = [
|
|
25
|
+
# Development: cargo build output
|
|
26
|
+
File.join(__dir__, "..", "..", "..", "target", "release", name),
|
|
27
|
+
File.join(__dir__, "..", "..", "..", "target", "debug", name),
|
|
28
|
+
# Bundled with gem
|
|
29
|
+
File.join(__dir__, name),
|
|
30
|
+
# System paths
|
|
31
|
+
File.join("/usr/local/lib", name),
|
|
32
|
+
File.join("/usr/lib", name),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
candidates.each do |path|
|
|
36
|
+
resolved = File.expand_path(path)
|
|
37
|
+
return resolved if File.exist?(resolved)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
lib_path = find_library
|
|
44
|
+
raise "Could not find libinky shared library. Build it with: cargo build -p inky-ffi --release" unless lib_path
|
|
45
|
+
|
|
46
|
+
dlload lib_path
|
|
47
|
+
|
|
48
|
+
extern "char* inky_transform(const char*)"
|
|
49
|
+
extern "char* inky_transform_with_columns(const char*, unsigned int)"
|
|
50
|
+
extern "char* inky_transform_inline(const char*)"
|
|
51
|
+
extern "char* inky_migrate(const char*)"
|
|
52
|
+
extern "char* inky_migrate_with_details(const char*)"
|
|
53
|
+
extern "char* inky_validate(const char*)"
|
|
54
|
+
extern "char* inky_version()"
|
|
55
|
+
extern "void inky_free(char*)"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Transform Inky HTML into email-safe table markup.
|
|
59
|
+
#
|
|
60
|
+
# @param html [String] Inky template HTML
|
|
61
|
+
# @param columns [Integer] Number of grid columns (default: 12)
|
|
62
|
+
# @return [String] Transformed HTML
|
|
63
|
+
def self.transform(html, columns: 12)
|
|
64
|
+
if columns != 12
|
|
65
|
+
Native.inky_transform_with_columns(html, columns).to_s
|
|
66
|
+
else
|
|
67
|
+
Native.inky_transform(html).to_s
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Transform Inky HTML and inline CSS from <style> blocks.
|
|
72
|
+
#
|
|
73
|
+
# @param html [String] Inky template HTML with <style> blocks
|
|
74
|
+
# @return [String] Transformed HTML with CSS inlined
|
|
75
|
+
def self.transform_inline(html)
|
|
76
|
+
Native.inky_transform_inline(html).to_s
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Migrate v1 Inky syntax to v2.
|
|
80
|
+
#
|
|
81
|
+
# @param html [String] v1 Inky template HTML
|
|
82
|
+
# @return [String] Migrated v2 HTML
|
|
83
|
+
def self.migrate(html)
|
|
84
|
+
Native.inky_migrate(html).to_s
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Migrate v1 syntax and return detailed results.
|
|
88
|
+
#
|
|
89
|
+
# @param html [String] v1 Inky template HTML
|
|
90
|
+
# @return [Hash] Hash with :html and :changes keys
|
|
91
|
+
def self.migrate_with_details(html)
|
|
92
|
+
json = Native.inky_migrate_with_details(html).to_s
|
|
93
|
+
JSON.parse(json, symbolize_names: true)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Validate an Inky template and return diagnostics.
|
|
97
|
+
#
|
|
98
|
+
# @param html [String] Inky template HTML
|
|
99
|
+
# @return [Array<Hash>] Array of hashes with :severity, :rule, :message keys
|
|
100
|
+
def self.validate(html)
|
|
101
|
+
json = Native.inky_validate(html).to_s
|
|
102
|
+
JSON.parse(json, symbolize_names: true)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Get the Inky engine version.
|
|
106
|
+
#
|
|
107
|
+
# @return [String] Version string
|
|
108
|
+
def self.version
|
|
109
|
+
Native.inky_version().to_s
|
|
110
|
+
end
|
|
111
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: inky-email
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.0.0.pre.beta.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ZURB
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Inky converts simple HTML with custom components into email-safe table
|
|
14
|
+
markup. Powered by Rust via Fiddle.
|
|
15
|
+
email:
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/inky.rb
|
|
21
|
+
homepage: https://github.com/foundation/inky
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata:
|
|
25
|
+
source_code_uri: https://github.com/foundation/inky
|
|
26
|
+
bug_tracker_uri: https://github.com/foundation/inky/issues
|
|
27
|
+
post_install_message:
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 2.7.0
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 1.3.1
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.0.3.1
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Transform email templates into email-safe HTML
|
|
46
|
+
test_files: []
|