Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to configure pretty json in .babelish #109

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mateuszszklarek
Copy link

@mateuszszklarek mateuszszklarek commented Nov 27, 2018

@netbe it would be great if you could look at it 🚀

given_json_filename = 'output.json'

expected_json = File.read('test/data/' + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, :output_basename => 'output', pretty_json: true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Metrics/LineLength: Line is too long. [118/80]

expected_json_filename = 'test_pretty_json.json'
given_json_filename = 'output.json'

expected_json = File.read('test/data/' + expected_json_filename)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

def test_converting_csv_to_json_with_pretty_json
csv_file = "test/data/test_data.csv"
expected_json_filename = 'test_pretty_json.json'
given_json_filename = 'output.json'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


def test_converting_csv_to_json_with_pretty_json
csv_file = "test/data/test_data.csv"
expected_json_filename = 'test_pretty_json.json'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

given_json_filename = 'output.json'

expected_json = File.read('test/data/' + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, :output_basename => 'output', pretty_json: false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Metrics/LineLength: Line is too long. [119/80]

expected_json_filename = 'test_unpretty_json.json'
given_json_filename = 'output.json'

expected_json = File.read('test/data/' + expected_json_filename)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

def test_converting_csv_to_json_with_unpretty_json
csv_file = "test/data/test_data.csv"
expected_json_filename = 'test_unpretty_json.json'
given_json_filename = 'output.json'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


def test_converting_csv_to_json_with_unpretty_json
csv_file = "test/data/test_data.csv"
expected_json_filename = 'test_unpretty_json.json'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -11,7 +16,7 @@ def language_filepaths(language)
end

def hash_to_output(content = {})
return content.to_json
return @pretty_json ? JSON.pretty_generate(content) : content.to_json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantReturn: Redundant return detected.

@@ -31,6 +31,7 @@ class Commandline < Thor
method_option :ignore_lang_path, :type => :boolean, :aliases => "-I", :lazy_default => false, :desc => "Ignore the path component of langs"
method_option :fetch, :type => :boolean, :desc => "Download file from Google Drive"
method_option :sheet, :type => :numeric, :desc => "Index of worksheet to download. First index is 0"
method_option :pretty_json, :type => :boolean, :aliases => "-p", :desc => "Prettify your json output files"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Metrics/LineLength: Line is too long. [111/80]

given_json_filename = "output.json"

expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file, { "English" => "en" }, output_basename: 'output', pretty_json: true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [117/80]
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

given_json_filename = "output.json"

expected_json = File.read('test/data/' + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file, { "English" => "en" }, output_basename: 'output', pretty_json: false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [118/80]
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -31,6 +31,7 @@ class Commandline < Thor
method_option :ignore_lang_path, :type => :boolean, :aliases => "-I", :lazy_default => false, :desc => "Ignore the path component of langs"
method_option :fetch, :type => :boolean, :desc => "Download file from Google Drive"
method_option :sheet, :type => :numeric, :desc => "Index of worksheet to download. First index is 0"
method_option :pretty_json, :type => :boolean, aliases: "-p", desc: "Prettify your json output files"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Metrics/LineLength: Line is too long. [105/80]

expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file,
{ "English" => "en" },
output_basename: "output",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.
Layout/TrailingWhitespace: Trailing whitespace detected.


expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file,
{ "English" => "en" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.
Layout/TrailingWhitespace: Trailing whitespace detected.

given_json_filename = "output.json"

expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file,
{ "English" => "en" },
output_basename: "output",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.
Layout/TrailingWhitespace: Trailing whitespace detected.


expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file,
{ "English" => "en" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.
Layout/TrailingWhitespace: Trailing whitespace detected.

given_json_filename = "output.json"

expected_json = File.read("test/data/" + expected_json_filename)
converter = Babelish::CSV2JSON.new(csv_file,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

@netbe netbe mentioned this pull request Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants