Skip to content

Commit

Permalink
Lint and temporary disable some rubocop rules
Browse files Browse the repository at this point in the history
  • Loading branch information
clairezed committed Nov 6, 2023
1 parent dcaa98f commit 7edbbe9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/mjml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Mjml
'Droid Sans': 'https://fonts.googleapis.com/css?family=Droid+Sans:300,400,500,700',
Lato: 'https://fonts.googleapis.com/css?family=Lato:300,400,500,700',
Roboto: 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
Ubuntu: 'https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700',
Ubuntu: 'https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700'
}.to_json

def self.check_version(bin)
Expand Down
7 changes: 6 additions & 1 deletion lib/mjml/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ def render
#
# @return [String] The result as string
# rubocop:disable Style/OptionalBooleanParameter: Fixing this offense would imply a change in the public API.
# rubocop:disable Metrics/MethodLength: Fixing this offense would imply a change in the public API.
# rubocop:disable Metrics/ParameterLists: Fixing this offense would imply a change in the public API.
def run(in_tmp_file, beautify = true, minify = false, validation_level = 'strict', fonts = Mjml.fonts)
Tempfile.create(['out', '.html']) do |out_tmp_file|
command = "-r #{in_tmp_file} -o #{out_tmp_file.path} " \
"--config.beautify #{beautify} --config.minify #{minify} --config.validationLevel #{validation_level} --config.fonts #{fonts.to_json}"
"--config.beautify #{beautify} --config.minify #{minify}" \
"--config.validationLevel #{validation_level} --config.fonts #{fonts.to_json}"
_, stderr, status = Mjml.run_mjml(command)

unless status.success?
Expand All @@ -52,6 +55,8 @@ def run(in_tmp_file, beautify = true, minify = false, validation_level = 'strict
out_tmp_file.read
end
end
# rubocop:enable Metrics/ParameterLists
# rubocop:enable Metrics/MethodLength
# rubocop:enable Style/OptionalBooleanParameter
end
end
16 changes: 5 additions & 11 deletions test/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,21 @@
'Droid Sans': 'https://fonts.googleapis.com/css?family=Droid+Sans:300,400,500,700',
Lato: 'https://fonts.googleapis.com/css?family=Lato:300,400,500,700',
Roboto: 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
Ubuntu: 'https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700',
}.to_json)
Ubuntu: 'https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700'
}.to_json)
end

it 'uses setup config' do
Mjml.setup do |config|
config.beautify = false
config.minify = true
config.validation_level = 'soft'
config.fonts = {}
config.fonts = { Lato: 'https://fonts.googleapis.com/css?family=Lato:300,400,500,700' }.to_json
end

expect(Mjml.beautify).must_equal(false)
expect(Mjml.minify).must_equal(true)
expect(Mjml.validation_level).must_equal('soft')
expect(Mjml.fonts).must_equal({})

Mjml.setup do |config|
config.fonts = { Lato: 'https://fonts.googleapis.com/css?family=Lato:300,400,500,700' }.to_json
end

expect(Mjml.fonts).must_equal({ Lato: 'https://fonts.googleapis.com/css?family=Lato:300,400,500,700' }.to_json)

Mjml.setup do |config|
Expand All @@ -79,8 +73,8 @@
'Droid Sans': 'https://fonts.googleapis.com/css?family=Droid+Sans:300,400,500,700',
Lato: 'https://fonts.googleapis.com/css?family=Lato:300,400,500,700',
Roboto: 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
Ubuntu: 'https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700',
}.to_json
Ubuntu: 'https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700'
}.to_json
end
end
end
Expand Down

0 comments on commit 7edbbe9

Please sign in to comment.