mrml 1.4.2 → 1.4.3

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: dd784db00a3c005e5e1adaf5df181f2c6a9aa1bc28d35a1eed5952dc8f5eba57
4
- data.tar.gz: 835836835cd290c5548965f251e9a47fd9418edb6cf5ff064c85744cc3eae0ee
3
+ metadata.gz: 99a1f399bc017d97eaab24e983115301bbdb879fff0f42c92d248200bca213b6
4
+ data.tar.gz: 77385ffd61d836431900c8eddd102486b41bda606518b951582a3b62d9e56dfc
5
5
  SHA512:
6
- metadata.gz: 042a8847470a0de9e4d1fcf47456de8578407d7cc7b281fd7c36720e0a284adc02fc52af0025be56146061508662470639e3692b764cea567e837e5e8a1c9db6
7
- data.tar.gz: af605ddf56d3fc9e07b921589b29f4d36e563e1a8fd754279e59cd923086141348cd5def5a181ce114a5651f5d99508f3cde4e26d846e55996d5c0544197470b
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
  }
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.2'
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.2
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-09-18 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
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.4.19
106
+ rubygems_version: 3.5.3
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Ruby wrapper for MRML Rust