-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kolybasov/mjml3-compatability
Add compatability with MJML v3.x.x
- Loading branch information
Showing
15 changed files
with
146 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ doc/ | |
|
||
# Node | ||
/node_modules | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module MJML | ||
# Allows to check if feature is availalbe in current mjml version | ||
class Feature | ||
def self.version | ||
semver = MJML.executable_version.split('.') | ||
@version ||= Hash[ | ||
major: semver[0].to_i, | ||
minor: semver[1].to_i, | ||
patch: semver[2].to_i | ||
] | ||
end | ||
|
||
def self.available?(feature_name) | ||
case feature_name | ||
when :validation_level | ||
version[:major] >= 3 | ||
else | ||
false | ||
end | ||
end | ||
|
||
def self.missing?(feature_name) | ||
!available?(feature_name) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module MJML | ||
VERSION = '0.2.3'.freeze | ||
VERSION = '0.3.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require_relative '../spec_helper' | ||
require 'mjml/feature' | ||
|
||
describe MJML::Feature do | ||
let(:mjml_version) { MJML.executable_version } | ||
let(:level_availability) { MJML.executable_version.start_with?('3') } | ||
|
||
describe '#availalbe?' do | ||
it 'should return true for :validation_level if mjml is >v3' do | ||
MJML::Feature.available?(:validation_level).must_equal level_availability | ||
end | ||
|
||
it 'should return false for unknown feature' do | ||
MJML::Feature.available?(:spaceship).must_equal false | ||
end | ||
end | ||
|
||
describe '#missing?' do | ||
it 'should return false for availalbe feature' do | ||
MJML::Feature.missing?(:validation_level).must_equal !level_availability | ||
end | ||
|
||
it 'should return true for unknown feature' do | ||
MJML::Feature.missing?(:spaceship).must_equal true | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require_relative '../spec_helper' | ||
require 'mjml/logger' | ||
require 'logger' | ||
|
||
describe MJML::Logger do | ||
let(:logger) { MJML.logger } | ||
let(:msg) { 'logger msg' } | ||
let(:matcher) { /msg/ } | ||
|
||
it 'should show errors' do | ||
capture_subprocess_io { logger.error(msg) }.to_s.must_match matcher | ||
end | ||
|
||
it 'should show debug messages' do | ||
logger.level = ::Logger::DEBUG | ||
capture_subprocess_io { logger.debug(msg) }.to_s.must_match matcher | ||
logger.level = ::Logger::ERROR | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters