mrml 1.5.1-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +147 -0
- data/lib/mrml/2.6/mrml.so +0 -0
- data/lib/mrml/2.7/mrml.so +0 -0
- data/lib/mrml/3.1/mrml.so +0 -0
- data/lib/mrml/3.2/mrml.so +0 -0
- data/lib/mrml/3.3/mrml.so +0 -0
- data/lib/mrml/error.rb +6 -0
- data/lib/mrml/template.rb +59 -0
- data/lib/mrml/version.rb +5 -0
- data/lib/mrml.rb +54 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48930121b1177677907b9a3981ebe9c81d37299606dd4e0626a636b2c998d4ee
|
4
|
+
data.tar.gz: 3281c57bfd3548e2c729c29c18dec76d432ea1ebc8ccaa2deea78c7c98e75fbb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b45ca44f2034f049a65cc8c2922d9b24d17db072281cd345c4719d655cb2d0773a89e12a5c24cfe75b3b4bec1b13479b92c1659faed1ee4da55a7bf37afb2cea
|
7
|
+
data.tar.gz: 57f8778c7d81e0fd59db11954b2803164c199dd51e65054d96c5a4b461ca6ab525c753a63808f1db69747112f251352401f7fe749c2dbf7c6ee5eb0d9522a4ed
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Code of Conduct
|
2
|
+
|
3
|
+
All participants of this project are expected to abide by our Code of Conduct, both online and during in-person events that are hosted and/or associated with this project.
|
4
|
+
|
5
|
+
## The Pledge
|
6
|
+
|
7
|
+
In the interest of fostering an open and welcoming environment, we pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
8
|
+
|
9
|
+
## The Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to creating a positive environment include:
|
12
|
+
|
13
|
+
* Using welcoming and inclusive language
|
14
|
+
* Being respectful of differing viewpoints and experiences
|
15
|
+
* Referring to people by their preferred pronouns and using gender-neutral pronouns when uncertain
|
16
|
+
* Gracefully accepting constructive criticism
|
17
|
+
* Focusing on what is best for the community
|
18
|
+
* Showing empathy towards other community members
|
19
|
+
|
20
|
+
Examples of unacceptable behavior by participants include:
|
21
|
+
|
22
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
23
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
26
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
27
|
+
* Dismissing or attacking inclusion-oriented requests
|
28
|
+
|
29
|
+
## Enforcement
|
30
|
+
|
31
|
+
Violations of the Code of Conduct may be reported by sending an email to info@hardpixel.eu. All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Further details of specific enforcement policies may be posted separately.
|
32
|
+
|
33
|
+
We hold the right and responsibility to remove comments or other contributions that are not aligned to this Code of Conduct, or to suspend temporarily or permanently any members for other behaviors that are inappropriate, threatening, offensive, or harmful.
|
34
|
+
|
35
|
+
## Attribution
|
36
|
+
|
37
|
+
This Code of Conduct is adapted from [dev.to](https://dev.to/code-of-conduct).
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 jonian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# MRML Ruby
|
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 if you use a version below [v1.4.2](https://github.com/hardpixel/mrml-ruby/releases/tag/v1.4.2).
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/mrml.svg)](https://badge.fury.io/rb/mrml)
|
6
|
+
[![Build](https://github.com/hardpixel/mrml-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/hardpixel/mrml-ruby/actions/workflows/build.yml)
|
7
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/7e307214d3c2e4d2056d/maintainability)](https://codeclimate.com/github/hardpixel/mrml-ruby/maintainability)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'mrml'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install mrml
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'mrml'
|
29
|
+
|
30
|
+
mjml = <<-HTML
|
31
|
+
<mjml>
|
32
|
+
<mj-head>
|
33
|
+
<mj-title>Newsletter Title</mj-title>
|
34
|
+
<mj-preview>Newsletter Preview</mj-preview>
|
35
|
+
</mj-head>
|
36
|
+
<mj-body>
|
37
|
+
<mj-section>
|
38
|
+
<mj-column>
|
39
|
+
<mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text>
|
40
|
+
</mj-column>
|
41
|
+
</mj-section>
|
42
|
+
</mj-body>
|
43
|
+
</mjml>
|
44
|
+
HTML
|
45
|
+
|
46
|
+
# Using module methods
|
47
|
+
MRML.to_html(mjml) # Generate html from mjml
|
48
|
+
MRML.to_json(mjml) # Generate json from mjml
|
49
|
+
MRML.to_hash(mjml) # Generate hash from mjml
|
50
|
+
|
51
|
+
# Using Template class
|
52
|
+
template = MRML::Template.new(mjml)
|
53
|
+
|
54
|
+
template.title # Get template title
|
55
|
+
template.preview # Get template preview
|
56
|
+
|
57
|
+
template.to_html # Render as html
|
58
|
+
template.to_mjml # Render as mjml
|
59
|
+
template.to_json # Render as json
|
60
|
+
template.to_hash # Render as hash
|
61
|
+
```
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'mrml'
|
65
|
+
|
66
|
+
json = <<-JSON
|
67
|
+
{
|
68
|
+
"type": "mjml",
|
69
|
+
"children": [{
|
70
|
+
"type": "mj-head",
|
71
|
+
"children": [{
|
72
|
+
"type": "mj-title",
|
73
|
+
"children": "Newsletter Title"
|
74
|
+
}, {
|
75
|
+
"type": "mj-preview",
|
76
|
+
"children": "Newsletter Preview"
|
77
|
+
}]
|
78
|
+
}, {
|
79
|
+
"type": "mj-body",
|
80
|
+
"children": [{
|
81
|
+
"type": "mj-section",
|
82
|
+
"children": [{
|
83
|
+
"type": "mj-column",
|
84
|
+
"children": [{
|
85
|
+
"type": "mj-text",
|
86
|
+
"attributes": {
|
87
|
+
"font-size": "20px",
|
88
|
+
"color": "#F45E43",
|
89
|
+
"font-family": "helvetica"
|
90
|
+
},
|
91
|
+
"children": ["Hello World"]
|
92
|
+
}]
|
93
|
+
}]
|
94
|
+
}]
|
95
|
+
}]
|
96
|
+
}
|
97
|
+
JSON
|
98
|
+
|
99
|
+
# Create Template from JSON
|
100
|
+
template = MRML::Template.from_json(json)
|
101
|
+
|
102
|
+
template.to_html # Render as html
|
103
|
+
template.to_mjml # Render as mjml
|
104
|
+
template.to_json # Render as json
|
105
|
+
template.to_hash # Render as hash
|
106
|
+
```
|
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
|
+
|
135
|
+
## Development
|
136
|
+
|
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.
|
138
|
+
|
139
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
140
|
+
|
141
|
+
## Contributing
|
142
|
+
|
143
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/mrml-ruby.
|
144
|
+
|
145
|
+
## License
|
146
|
+
|
147
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/mrml/error.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module MRML
|
6
|
+
# Template object implemented in Rust that can parse MJML templates.
|
7
|
+
class Template
|
8
|
+
class << self
|
9
|
+
# @!method from_json(json)
|
10
|
+
# A new instance of Template from JSON.
|
11
|
+
# @!scope class
|
12
|
+
# @param json [String]
|
13
|
+
# @return [Template]
|
14
|
+
# @raise [Error] if json has invalid format
|
15
|
+
|
16
|
+
# A new instance of Template from Hash.
|
17
|
+
# @param hash [Hash]
|
18
|
+
# @return [Template]
|
19
|
+
# @raise [Error] if hash has invalid format
|
20
|
+
|
21
|
+
def from_hash(hash)
|
22
|
+
from_json(JSON.generate(hash))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @!method initialize(mjml)
|
27
|
+
# A new instance of Template.
|
28
|
+
# @param mjml [String]
|
29
|
+
# @return [Template]
|
30
|
+
# @raise [Error] if mjml is not a valid template
|
31
|
+
|
32
|
+
# @!attribute [r] title
|
33
|
+
# Gets mj-title tag value.
|
34
|
+
# @return [String]
|
35
|
+
|
36
|
+
# @!attribute [r] preview
|
37
|
+
# Gets mj-preview tag value.
|
38
|
+
# @return [String]
|
39
|
+
|
40
|
+
# @!method to_mjml
|
41
|
+
# MJML representation of the template.
|
42
|
+
# @return [String]
|
43
|
+
|
44
|
+
# @!method to_json
|
45
|
+
# JSON representation of the template.
|
46
|
+
# @return [String]
|
47
|
+
|
48
|
+
# @!method to_html
|
49
|
+
# HTML representation of the template.
|
50
|
+
# @return [String]
|
51
|
+
|
52
|
+
# Hash representation of the template.
|
53
|
+
# @return [Hash]
|
54
|
+
|
55
|
+
def to_hash
|
56
|
+
JSON.parse(to_json)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/mrml/version.rb
ADDED
data/lib/mrml.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
5
|
+
require "mrml/#{$1}/mrml"
|
6
|
+
rescue LoadError
|
7
|
+
require 'mrml/mrml'
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'mrml/error'
|
11
|
+
require 'mrml/template'
|
12
|
+
require 'mrml/version'
|
13
|
+
|
14
|
+
# Module that renders MJML templates into HTML/JSON using MRML,
|
15
|
+
# a reimplementation of the MJML markup language in Rust.
|
16
|
+
module MRML
|
17
|
+
class << self
|
18
|
+
# Render template as HTML.
|
19
|
+
# @param mjml [String]
|
20
|
+
# @return (see Template#to_html)
|
21
|
+
# @raise (see Template#initialize)
|
22
|
+
|
23
|
+
def to_html(mjml)
|
24
|
+
return if mjml.nil?
|
25
|
+
|
26
|
+
template = Template.new(mjml)
|
27
|
+
template.to_html
|
28
|
+
end
|
29
|
+
|
30
|
+
# Render template as JSON.
|
31
|
+
# @param mjml [String]
|
32
|
+
# @return (see Template#to_json)
|
33
|
+
# @raise (see Template#initialize)
|
34
|
+
|
35
|
+
def to_json(mjml)
|
36
|
+
return if mjml.nil?
|
37
|
+
|
38
|
+
template = Template.new(mjml)
|
39
|
+
template.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
# Render template as Hash.
|
43
|
+
# @param mjml [String]
|
44
|
+
# @return (see Template#to_hash)
|
45
|
+
# @raise (see Template#initialize)
|
46
|
+
|
47
|
+
def to_hash(mjml)
|
48
|
+
return if mjml.nil?
|
49
|
+
|
50
|
+
template = Template.new(mjml)
|
51
|
+
template.to_hash
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mrml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.5.1
|
5
|
+
platform: aarch64-linux-musl
|
6
|
+
authors:
|
7
|
+
- Jonian Guveli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-07-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake-compiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
55
|
+
description: Ruby wrapper for MRML, the MJML parser implementation in Rust.
|
56
|
+
email:
|
57
|
+
- jonian@hardpixel.eu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CODE_OF_CONDUCT.md
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
- lib/mrml.rb
|
66
|
+
- lib/mrml/2.6/mrml.so
|
67
|
+
- lib/mrml/2.7/mrml.so
|
68
|
+
- lib/mrml/3.1/mrml.so
|
69
|
+
- lib/mrml/3.2/mrml.so
|
70
|
+
- lib/mrml/3.3/mrml.so
|
71
|
+
- lib/mrml/error.rb
|
72
|
+
- lib/mrml/template.rb
|
73
|
+
- lib/mrml/version.rb
|
74
|
+
homepage: https://github.com/hardpixel/mrml-ruby
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '2.6'
|
87
|
+
- - "<"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.4.dev
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 3.3.22
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.4.4
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Ruby wrapper for MRML Rust
|
100
|
+
test_files: []
|