Module: MJML
- Extended by:
- Dry::Configurable
- 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
Defined Under Namespace
Modules: Rails
Classes: BinaryNotFound, Feature, Logger, Parser, Railtie
Constant Summary
collapse
- MIME_TYPE =
'text/mjml'.freeze
- EXTENSION =
'.mjml'.freeze
- VERSION_3_REGEX =
/^(\d\.\d\.\d)/i
- VERSION_4_REGEX =
/^mjml-cli: (\d\.\d\.\d)/i
- VERSION =
'0.3.5'.freeze
Class Method Summary
collapse
Class Method Details
.executable_version ⇒ Object
41
42
43
|
# File 'lib/mjml.rb', line 41
def self.executable_version
@executable_version ||=
end
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/mjml.rb', line 45
def self.
ver, _status = Open3.capture2(config.bin_path, '--version')
case ver.count("\n")
when 1
match = ver.match(VERSION_3_REGEX)
when 2
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
35
36
37
38
39
|
# File 'lib/mjml.rb', line 35
def self.find_executable
local_path = File.expand_path('node_modules/.bin/mjml', Dir.pwd)
return local_path if File.file?(local_path)
`/usr/bin/env bash -c "which mjml"`.strip
end
|
.logger ⇒ Object
71
72
73
|
# File 'lib/mjml.rb', line 71
def self.logger
config.logger
end
|
.setup! ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/mjml.rb', line 24
def self.setup!
configure do |config|
config.bin_path = find_executable
config.debug = nil
config.logger = Logger.setup!(STDOUT)
config.minify_output = false
config.validation_level = :skip
end
end
|