Skip to content

Commit

Permalink
Throw error if executable is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykola Basov committed Aug 31, 2016
1 parent 6a0a3eb commit 48f8140
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ notifications:
email: false

before_script:
- nvm install 5.6
- nvm use 5.6
- nvm install 6.5
- nvm use 6.5
- npm install
8 changes: 8 additions & 0 deletions lib/mjml/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ module MJML
# Parser for MJML templates
class Parser
class InvalidTemplate < StandardError; end
class ExecutableNotFound < StandardError; end

ROOT_TAGS_REGEX = %r{<mjml>.*<\/mjml>}im
VERSION_REGEX = /^\d\.\d\.\d/i

def initialize
raise ExecutableNotFound if mjml_version.nil?
end

def call(template)
Expand Down Expand Up @@ -39,5 +42,10 @@ def partial?(template)
def mjml_bin
MJML.config.bin_path
end

def mjml_version
ver = `#{mjml_bin} -V`.strip
(ver =~ VERSION_REGEX).nil? ? nil : ver
end
end
end

0 comments on commit 48f8140

Please sign in to comment.