mrml 1.4.2 → 1.5.0

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: f5082abdee5d6861d22a39241d896fc680f920982801a4ebb6f40dae2cad8995
4
+ data.tar.gz: 88c08eb3e5fe5ea33c9136b445518e93d25a3ec758809c6268f50ae320c1f9d8
5
5
  SHA512:
6
- metadata.gz: 042a8847470a0de9e4d1fcf47456de8578407d7cc7b281fd7c36720e0a284adc02fc52af0025be56146061508662470639e3692b764cea567e837e5e8a1c9db6
7
- data.tar.gz: af605ddf56d3fc9e07b921589b29f4d36e563e1a8fd754279e59cd923086141348cd5def5a181ce114a5651f5d99508f3cde4e26d846e55996d5c0544197470b
6
+ metadata.gz: 1f2f72040b78f5afbc378ced982c4c8b5744b11d9fea05b7d0560f6645534f2ef36bbfef9593a4c2acc12c81b242d81fb8d16471dd74cf376955f5ca1b1efc1c
7
+ data.tar.gz: 5f51220afa5ad2b600b166739657da060bc962d6a707ee22dd5d786455e3a943fdfe528cab4d1cf20c301276708bd2cdc366698b746f899a9f2a9cdc152ab338
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/Cargo.toml CHANGED
@@ -5,7 +5,7 @@ authors = ["Jonian Guveli <jonian@hardpixel.eu>"]
5
5
  edition = "2018"
6
6
 
7
7
  [dependencies]
8
- mrml = "1.2"
8
+ mrml = "3.0"
9
9
  magnus = "0.5"
10
10
 
11
11
  [dependencies.serde]
data/ext/mrml/src/lib.rs CHANGED
@@ -4,9 +4,9 @@ use magnus::{
4
4
  Error, ExceptionClass, RModule
5
5
  };
6
6
 
7
- use mrml::mjml::MJML;
7
+ use mrml::mjml::Mjml;
8
8
  use mrml::prelude::print::Print;
9
- use mrml::prelude::render::Options;
9
+ use mrml::prelude::render::RenderOptions;
10
10
 
11
11
  fn mrml_error() -> ExceptionClass {
12
12
  *memoize!(ExceptionClass: {
@@ -16,23 +16,29 @@ 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
- res: MJML
27
+ res: Mjml
22
28
  }
23
29
 
24
30
  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
- match serde_json::from_str::<MJML>(&input) {
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
- match self.res.render(&Options::default()) {
65
+ match self.res.render(&RenderOptions::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.5.0'
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.5.0
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-03-07 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