mrml 1.4.1 → 1.4.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
2
  SHA256:
3
- metadata.gz: d3e5f1cf3b3e3c4e5813b40d9c2836369fd07c729828c5cd4e2d387c1260e91d
4
- data.tar.gz: d0cf666c962b4e62e8f51c72e8aff0aaebafcc8adef8fe98558033705147ba9e
3
+ metadata.gz: 99a1f399bc017d97eaab24e983115301bbdb879fff0f42c92d248200bca213b6
4
+ data.tar.gz: 77385ffd61d836431900c8eddd102486b41bda606518b951582a3b62d9e56dfc
5
5
  SHA512:
6
- metadata.gz: bf21078e3fdd299bab4ea186310aac1efff8008decbc538b20e45d06d3d88c33bc89b73664fdacbf094ee90898a611f4618dcfff37f19e402c98875eca82abda
7
- data.tar.gz: 12f8ae5770dc6fffef828177e06c2117f4e187984ce1e30e5990caaf71d74ccd475d337cdd297ed6ecc604d4e4eb75ac9861d7a4d108b4c7aa44a6fd1f281bf0
6
+ metadata.gz: 358bd8c72c8e4d6b8c4b7977ffa1e014ce381f08cc4b2ba4f1cac0539359edd3e816867154f047ab02621b3928689c5d0f3ff921be3d5d3abc8effeda70509a2
7
+ data.tar.gz: 8b1cb471ab1e07b89ae35b9ec5ae0fd785f2eb368236b5b66c1de6ef7decca4e5d6e9a2ab6623f5f44c11d9fa6bb9fffe562da18bd3855fe25e9f81013a241a9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MRML Ruby
2
2
 
3
- Ruby wrapper for [MRML](https://github.com/jdrouet/mrml), the [MJML](https://mjml.io) markup language implementation in Rust. Rust must be available on your system to install this gem.
3
+ Ruby wrapper for [MRML](https://github.com/jdrouet/mrml), the [MJML](https://mjml.io) markup language implementation in Rust. Rust must be available on your system to install this gem if you use a version below [v1.4.2](https://github.com/hardpixel/mrml-ruby/releases/tag/v1.4.2).
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/mrml.svg)](https://badge.fury.io/rb/mrml)
6
6
  [![Build](https://github.com/hardpixel/mrml-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/hardpixel/mrml-ruby/actions/workflows/build.yml)
@@ -105,6 +105,33 @@ template.to_json # Render as json
105
105
  template.to_hash # Render as hash
106
106
  ```
107
107
 
108
+ ## Benchmark
109
+
110
+ ```
111
+ Warming up --------------------------------------
112
+ mrml 3.069k i/100ms
113
+ mjml 1.000 i/100ms
114
+ Calculating -------------------------------------
115
+ mrml 32.537k (±16.1%) i/s - 156.519k in 5.029759s
116
+ mjml 1.895 (± 0.0%) i/s - 10.000 in 5.283579s
117
+
118
+ Comparison:
119
+ mrml: 32537.2 i/s
120
+ mjml: 1.9 i/s - 17169.16x slower
121
+
122
+ Calculating -------------------------------------
123
+ mrml 3.166k memsize ( 0.000 retained)
124
+ 2.000 objects ( 0.000 retained)
125
+ 1.000 strings ( 0.000 retained)
126
+ mjml 21.253k memsize ( 1.490k retained)
127
+ 107.000 objects ( 15.000 retained)
128
+ 20.000 strings ( 11.000 retained)
129
+
130
+ Comparison:
131
+ mrml: 3166 allocated
132
+ mjml: 21253 allocated - 6.71x more
133
+ ```
134
+
108
135
  ## Development
109
136
 
110
137
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/ext/mrml/src/lib.rs CHANGED
@@ -16,6 +16,12 @@ fn mrml_error() -> ExceptionClass {
16
16
  })
17
17
  }
18
18
 
19
+ macro_rules! error {
20
+ ($ex:ident) => {
21
+ Error::new(mrml_error(), $ex.to_string())
22
+ };
23
+ }
24
+
19
25
  #[magnus::wrap(class = "MRML::Template", free_immediately, size)]
20
26
  struct Template {
21
27
  res: MJML
@@ -25,14 +31,14 @@ impl Template {
25
31
  fn new(input: String) -> Result<Self, Error> {
26
32
  match mrml::parse(&input) {
27
33
  Ok(res) => Ok(Self { res }),
28
- Err(ex) => Err(Error::new(mrml_error(), ex.to_string()))
34
+ Err(ex) => Err(error!(ex))
29
35
  }
30
36
  }
31
37
 
32
38
  fn from_json(input: String) -> Result<Self, Error> {
33
39
  match serde_json::from_str::<MJML>(&input) {
34
40
  Ok(res) => Ok(Self { res }),
35
- Err(ex) => Err(Error::new(mrml_error(), ex.to_string()))
41
+ Err(ex) => Err(error!(ex))
36
42
  }
37
43
  }
38
44
 
@@ -51,14 +57,14 @@ impl Template {
51
57
  fn to_json(&self) -> Result<String, Error> {
52
58
  match serde_json::to_string(&self.res) {
53
59
  Ok(res) => Ok(res),
54
- Err(ex) => Err(Error::new(mrml_error(), ex.to_string()))
60
+ Err(ex) => Err(error!(ex))
55
61
  }
56
62
  }
57
63
 
58
64
  fn to_html(&self) -> Result<String, Error> {
59
65
  match self.res.render(&Options::default()) {
60
66
  Ok(res) => Ok(res),
61
- Err(ex) => Err(Error::new(mrml_error(), ex.to_string()))
67
+ Err(ex) => Err(error!(ex))
62
68
  }
63
69
  }
64
70
  }
@@ -72,7 +78,7 @@ impl Clone for Template {
72
78
  #[magnus::init]
73
79
  fn init() -> Result<(), Error> {
74
80
  let module = define_module("MRML")?;
75
- let class = module.define_class("Template", Default::default())?;
81
+ let class = module.define_class("Template", class::object())?;
76
82
 
77
83
  class.define_singleton_method("new", function!(Template::new, 1))?;
78
84
  class.define_singleton_method("from_json", function!(Template::from_json, 1))?;
data/lib/mrml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MRML
4
- VERSION = '1.4.1'
4
+ VERSION = '1.4.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-11 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -77,7 +77,6 @@ files:
77
77
  - CODE_OF_CONDUCT.md
78
78
  - LICENSE.txt
79
79
  - README.md
80
- - ext/mrml/Cargo.lock
81
80
  - ext/mrml/Cargo.toml
82
81
  - ext/mrml/extconf.rb
83
82
  - ext/mrml/src/lib.rs
@@ -104,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
103
  - !ruby/object:Gem::Version
105
104
  version: '0'
106
105
  requirements: []
107
- rubygems_version: 3.4.8
106
+ rubygems_version: 3.5.3
108
107
  signing_key:
109
108
  specification_version: 4
110
109
  summary: Ruby wrapper for MRML Rust
data/ext/mrml/Cargo.lock DELETED
@@ -1,405 +0,0 @@
1
- # This file is automatically @generated by Cargo.
2
- # It is not intended for manual editing.
3
- version = 3
4
-
5
- [[package]]
6
- name = "aho-corasick"
7
- version = "1.0.1"
8
- source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
10
- dependencies = [
11
- "memchr",
12
- ]
13
-
14
- [[package]]
15
- name = "bindgen"
16
- version = "0.62.0"
17
- source = "registry+https://github.com/rust-lang/crates.io-index"
18
- checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
19
- dependencies = [
20
- "bitflags",
21
- "cexpr",
22
- "clang-sys",
23
- "lazy_static",
24
- "lazycell",
25
- "peeking_take_while",
26
- "proc-macro2",
27
- "quote",
28
- "regex",
29
- "rustc-hash",
30
- "shlex",
31
- "syn 1.0.109",
32
- ]
33
-
34
- [[package]]
35
- name = "bitflags"
36
- version = "1.3.2"
37
- source = "registry+https://github.com/rust-lang/crates.io-index"
38
- checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
39
-
40
- [[package]]
41
- name = "cexpr"
42
- version = "0.6.0"
43
- source = "registry+https://github.com/rust-lang/crates.io-index"
44
- checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
45
- dependencies = [
46
- "nom",
47
- ]
48
-
49
- [[package]]
50
- name = "cfg-if"
51
- version = "1.0.0"
52
- source = "registry+https://github.com/rust-lang/crates.io-index"
53
- checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
54
-
55
- [[package]]
56
- name = "clang-sys"
57
- version = "1.6.1"
58
- source = "registry+https://github.com/rust-lang/crates.io-index"
59
- checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
60
- dependencies = [
61
- "glob",
62
- "libc",
63
- "libloading",
64
- ]
65
-
66
- [[package]]
67
- name = "getrandom"
68
- version = "0.2.9"
69
- source = "registry+https://github.com/rust-lang/crates.io-index"
70
- checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
71
- dependencies = [
72
- "cfg-if",
73
- "libc",
74
- "wasi",
75
- ]
76
-
77
- [[package]]
78
- name = "glob"
79
- version = "0.3.1"
80
- source = "registry+https://github.com/rust-lang/crates.io-index"
81
- checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
82
-
83
- [[package]]
84
- name = "itoa"
85
- version = "1.0.6"
86
- source = "registry+https://github.com/rust-lang/crates.io-index"
87
- checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
88
-
89
- [[package]]
90
- name = "lazy_static"
91
- version = "1.4.0"
92
- source = "registry+https://github.com/rust-lang/crates.io-index"
93
- checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
94
-
95
- [[package]]
96
- name = "lazycell"
97
- version = "1.3.0"
98
- source = "registry+https://github.com/rust-lang/crates.io-index"
99
- checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
100
-
101
- [[package]]
102
- name = "libc"
103
- version = "0.2.144"
104
- source = "registry+https://github.com/rust-lang/crates.io-index"
105
- checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
106
-
107
- [[package]]
108
- name = "libloading"
109
- version = "0.7.4"
110
- source = "registry+https://github.com/rust-lang/crates.io-index"
111
- checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
112
- dependencies = [
113
- "cfg-if",
114
- "winapi",
115
- ]
116
-
117
- [[package]]
118
- name = "magnus"
119
- version = "0.5.3"
120
- source = "registry+https://github.com/rust-lang/crates.io-index"
121
- checksum = "c8dc14463c2552e753ef562961f486ca76f17a857c121db40e9f3ade3f35ab81"
122
- dependencies = [
123
- "magnus-macros",
124
- "rb-sys",
125
- "rb-sys-env",
126
- ]
127
-
128
- [[package]]
129
- name = "magnus-macros"
130
- version = "0.4.1"
131
- source = "registry+https://github.com/rust-lang/crates.io-index"
132
- checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb"
133
- dependencies = [
134
- "proc-macro2",
135
- "quote",
136
- "syn 1.0.109",
137
- ]
138
-
139
- [[package]]
140
- name = "memchr"
141
- version = "2.5.0"
142
- source = "registry+https://github.com/rust-lang/crates.io-index"
143
- checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
144
-
145
- [[package]]
146
- name = "minimal-lexical"
147
- version = "0.2.1"
148
- source = "registry+https://github.com/rust-lang/crates.io-index"
149
- checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
150
-
151
- [[package]]
152
- name = "mrml"
153
- version = "0.1.0"
154
- dependencies = [
155
- "magnus",
156
- "mrml 1.2.11",
157
- "serde",
158
- "serde_json",
159
- ]
160
-
161
- [[package]]
162
- name = "mrml"
163
- version = "1.2.11"
164
- source = "registry+https://github.com/rust-lang/crates.io-index"
165
- checksum = "a21c524cad4503cd722fb13286c5199914f2786280733d947d623cbdcb5e6437"
166
- dependencies = [
167
- "rand",
168
- "serde",
169
- "serde_json",
170
- "xmlparser",
171
- ]
172
-
173
- [[package]]
174
- name = "nom"
175
- version = "7.1.3"
176
- source = "registry+https://github.com/rust-lang/crates.io-index"
177
- checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
178
- dependencies = [
179
- "memchr",
180
- "minimal-lexical",
181
- ]
182
-
183
- [[package]]
184
- name = "peeking_take_while"
185
- version = "0.1.2"
186
- source = "registry+https://github.com/rust-lang/crates.io-index"
187
- checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
188
-
189
- [[package]]
190
- name = "ppv-lite86"
191
- version = "0.2.17"
192
- source = "registry+https://github.com/rust-lang/crates.io-index"
193
- checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
194
-
195
- [[package]]
196
- name = "proc-macro2"
197
- version = "1.0.56"
198
- source = "registry+https://github.com/rust-lang/crates.io-index"
199
- checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
200
- dependencies = [
201
- "unicode-ident",
202
- ]
203
-
204
- [[package]]
205
- name = "quote"
206
- version = "1.0.27"
207
- source = "registry+https://github.com/rust-lang/crates.io-index"
208
- checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500"
209
- dependencies = [
210
- "proc-macro2",
211
- ]
212
-
213
- [[package]]
214
- name = "rand"
215
- version = "0.8.5"
216
- source = "registry+https://github.com/rust-lang/crates.io-index"
217
- checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
218
- dependencies = [
219
- "libc",
220
- "rand_chacha",
221
- "rand_core",
222
- ]
223
-
224
- [[package]]
225
- name = "rand_chacha"
226
- version = "0.3.1"
227
- source = "registry+https://github.com/rust-lang/crates.io-index"
228
- checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
229
- dependencies = [
230
- "ppv-lite86",
231
- "rand_core",
232
- ]
233
-
234
- [[package]]
235
- name = "rand_core"
236
- version = "0.6.4"
237
- source = "registry+https://github.com/rust-lang/crates.io-index"
238
- checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
239
- dependencies = [
240
- "getrandom",
241
- ]
242
-
243
- [[package]]
244
- name = "rb-sys"
245
- version = "0.9.77"
246
- source = "registry+https://github.com/rust-lang/crates.io-index"
247
- checksum = "9d2eb4e2afad796b886b0146e82343f5cf06c5f8abc26648cb7a0c4aff1e5e87"
248
- dependencies = [
249
- "rb-sys-build",
250
- ]
251
-
252
- [[package]]
253
- name = "rb-sys-build"
254
- version = "0.9.77"
255
- source = "registry+https://github.com/rust-lang/crates.io-index"
256
- checksum = "b489abaa43843504e3aab8c7f86aa964b3041452d031281969a5fc70b0bd67c3"
257
- dependencies = [
258
- "bindgen",
259
- "lazy_static",
260
- "proc-macro2",
261
- "quote",
262
- "regex",
263
- "shell-words",
264
- "syn 1.0.109",
265
- ]
266
-
267
- [[package]]
268
- name = "rb-sys-env"
269
- version = "0.1.2"
270
- source = "registry+https://github.com/rust-lang/crates.io-index"
271
- checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
272
-
273
- [[package]]
274
- name = "regex"
275
- version = "1.8.1"
276
- source = "registry+https://github.com/rust-lang/crates.io-index"
277
- checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
278
- dependencies = [
279
- "aho-corasick",
280
- "memchr",
281
- "regex-syntax",
282
- ]
283
-
284
- [[package]]
285
- name = "regex-syntax"
286
- version = "0.7.1"
287
- source = "registry+https://github.com/rust-lang/crates.io-index"
288
- checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c"
289
-
290
- [[package]]
291
- name = "rustc-hash"
292
- version = "1.1.0"
293
- source = "registry+https://github.com/rust-lang/crates.io-index"
294
- checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
295
-
296
- [[package]]
297
- name = "ryu"
298
- version = "1.0.13"
299
- source = "registry+https://github.com/rust-lang/crates.io-index"
300
- checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
301
-
302
- [[package]]
303
- name = "serde"
304
- version = "1.0.163"
305
- source = "registry+https://github.com/rust-lang/crates.io-index"
306
- checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2"
307
- dependencies = [
308
- "serde_derive",
309
- ]
310
-
311
- [[package]]
312
- name = "serde_derive"
313
- version = "1.0.163"
314
- source = "registry+https://github.com/rust-lang/crates.io-index"
315
- checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e"
316
- dependencies = [
317
- "proc-macro2",
318
- "quote",
319
- "syn 2.0.15",
320
- ]
321
-
322
- [[package]]
323
- name = "serde_json"
324
- version = "1.0.96"
325
- source = "registry+https://github.com/rust-lang/crates.io-index"
326
- checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
327
- dependencies = [
328
- "itoa",
329
- "ryu",
330
- "serde",
331
- ]
332
-
333
- [[package]]
334
- name = "shell-words"
335
- version = "1.1.0"
336
- source = "registry+https://github.com/rust-lang/crates.io-index"
337
- checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
338
-
339
- [[package]]
340
- name = "shlex"
341
- version = "1.1.0"
342
- source = "registry+https://github.com/rust-lang/crates.io-index"
343
- checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
344
-
345
- [[package]]
346
- name = "syn"
347
- version = "1.0.109"
348
- source = "registry+https://github.com/rust-lang/crates.io-index"
349
- checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
350
- dependencies = [
351
- "proc-macro2",
352
- "quote",
353
- "unicode-ident",
354
- ]
355
-
356
- [[package]]
357
- name = "syn"
358
- version = "2.0.15"
359
- source = "registry+https://github.com/rust-lang/crates.io-index"
360
- checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
361
- dependencies = [
362
- "proc-macro2",
363
- "quote",
364
- "unicode-ident",
365
- ]
366
-
367
- [[package]]
368
- name = "unicode-ident"
369
- version = "1.0.8"
370
- source = "registry+https://github.com/rust-lang/crates.io-index"
371
- checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
372
-
373
- [[package]]
374
- name = "wasi"
375
- version = "0.11.0+wasi-snapshot-preview1"
376
- source = "registry+https://github.com/rust-lang/crates.io-index"
377
- checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
378
-
379
- [[package]]
380
- name = "winapi"
381
- version = "0.3.9"
382
- source = "registry+https://github.com/rust-lang/crates.io-index"
383
- checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
384
- dependencies = [
385
- "winapi-i686-pc-windows-gnu",
386
- "winapi-x86_64-pc-windows-gnu",
387
- ]
388
-
389
- [[package]]
390
- name = "winapi-i686-pc-windows-gnu"
391
- version = "0.4.0"
392
- source = "registry+https://github.com/rust-lang/crates.io-index"
393
- checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
394
-
395
- [[package]]
396
- name = "winapi-x86_64-pc-windows-gnu"
397
- version = "0.4.0"
398
- source = "registry+https://github.com/rust-lang/crates.io-index"
399
- checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
400
-
401
- [[package]]
402
- name = "xmlparser"
403
- version = "0.13.5"
404
- source = "registry+https://github.com/rust-lang/crates.io-index"
405
- checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd"