Module: MJML
- Defined in:
- lib/mjml.rb,
lib/mjml/logger.rb,
lib/mjml/parser.rb,
lib/mjml/feature.rb,
lib/mjml/railtie.rb,
lib/mjml/version.rb,
lib/mjml/rails/template_handler.rb
Overview
MJML library for ruby
Defined Under Namespace
Modules: Config, Rails Classes: BinaryNotFound, Feature, Logger, Parser, Railtie
Constant Summary collapse
- MIME_TYPE =
Constants
'text/mjml'.freeze
- EXTENSION =
'.mjml'.freeze
- VERSION_3_REGEX =
/^(\d+\.\d+\.\d+)/i
- VERSION_4_REGEX =
/^mjml-cli: (\d+\.\d+\.\d+)/i
- VERSION =
'0.4.1'.freeze
Class Method Summary collapse
- .executable_version ⇒ Object
- .extract_executable_version ⇒ Object
- .find_executable ⇒ Object
- .logger ⇒ Object
- .setup! ⇒ Object
Class Method Details
.executable_version ⇒ Object
43 44 45 |
# File 'lib/mjml.rb', line 43 def self.executable_version @executable_version ||= extract_executable_version end |
.extract_executable_version ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mjml.rb', line 47 def self.extract_executable_version ver, _status = Open3.capture2(Config.bin_path, '--version') # mjml 3.x outputs version directly: # 3.3.5 # --> just take this as the version # mjml 4.x outputs two rows: # mjml-core: 4.0.0 # mjml-cli: 4.0.0 # --> we take the second number as the version, since we call the cli case ver.count("\n") when 1 # one line, mjml 3.x match = ver.match(VERSION_3_REGEX) when 2 # two lines, might be 4.x match = ver.match(VERSION_4_REGEX) end match.nil? ? nil : match[1] rescue Errno::ENOENT => _e raise BinaryNotFound, "mjml binary not found for path '#{Config.bin_path}'" end |
.find_executable ⇒ Object
37 38 39 40 41 |
# File 'lib/mjml.rb', line 37 def self.find_executable local_path = File.('node_modules/.bin/mjml', Dir.pwd) return local_path if File.file?(local_path) `/usr/bin/env which mjml`.strip end |