From dbd92d65c0d5c50ebaab8a7250b6d9edb634df32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Benaiteau?= Date: Mon, 8 Jun 2020 22:42:39 +0200 Subject: [PATCH 1/9] Revert "Version bumped" d7e76787c6b4775a0216c69d0d079b85a23872a8 --- lib/babelish/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/babelish/version.rb b/lib/babelish/version.rb index b6a0024..ac72cd7 100644 --- a/lib/babelish/version.rb +++ b/lib/babelish/version.rb @@ -1,3 +1,3 @@ module Babelish - VERSION = "0.6.5" + VERSION = "0.6.4" end From 5e9087ce8d3b3b5b60ac35385f2355d4f6a42d46 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Mon, 26 Nov 2018 15:53:58 +0100 Subject: [PATCH 2/9] Extend configuration file with pretty_json parameter --- lib/babelish/commandline.rb | 1 + lib/babelish/csv2base.rb | 1 + lib/babelish/csv2json.rb | 2 +- test/babelish/test_csv2json.rb | 30 ++++++++++++++++++++++++++++++ test/data/test_pretty_json.json | 4 ++++ test/data/test_unpretty_json.json | 1 + 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/data/test_pretty_json.json create mode 100644 test/data/test_unpretty_json.json diff --git a/lib/babelish/commandline.rb b/lib/babelish/commandline.rb index 29ce582..6fe0ebc 100644 --- a/lib/babelish/commandline.rb +++ b/lib/babelish/commandline.rb @@ -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, :default => false, :desc => "Prettify your json output files" if klass[:name] == "CSV2Strings" method_option :macros_filename, :type => :boolean, :aliases => "-m", :lazy_default => false, :desc => "Filename containing defines of localized keys" end diff --git a/lib/babelish/csv2base.rb b/lib/babelish/csv2base.rb index 35df277..5419811 100644 --- a/lib/babelish/csv2base.rb +++ b/lib/babelish/csv2base.rb @@ -39,6 +39,7 @@ def initialize(filename, langs, args = {}) @csv_separator = args[:csv_separator] @ignore_lang_path = args[:ignore_lang_path] @stripping = args[:stripping] + @pretty_json = args[:pretty_json] @languages = [] @comments = {} end diff --git a/lib/babelish/csv2json.rb b/lib/babelish/csv2json.rb index 4f10130..87e107d 100644 --- a/lib/babelish/csv2json.rb +++ b/lib/babelish/csv2json.rb @@ -11,7 +11,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 end def extension diff --git a/test/babelish/test_csv2json.rb b/test/babelish/test_csv2json.rb index 6038a4e..5217188 100644 --- a/test/babelish/test_csv2json.rb +++ b/test/babelish/test_csv2json.rb @@ -24,4 +24,34 @@ def test_converting_csv_to_dotstrings_one_output_option # clean up system("rm -rf ./" + single_file) end + + 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' + + expected_json = File.read('test/data/' + expected_json_filename) + converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, :output_basename => 'output', :pretty_json => false) + converter.convert + given_json = File.read(given_json_filename) + assert_equal(expected_json, given_json, "JSON file has incorrect format") + + # clean up + system("rm -rf ./" + given_json_filename) + end + + 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' + + expected_json = File.read('test/data/' + expected_json_filename) + converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, :output_basename => 'output', :pretty_json => true) + converter.convert + given_json = File.read(given_json_filename) + assert_equal(expected_json, given_json, "JSON file has incorrect format") + + # clean up + system("rm -rf ./" + given_json_filename) + end end diff --git a/test/data/test_pretty_json.json b/test/data/test_pretty_json.json new file mode 100644 index 0000000..81b4904 --- /dev/null +++ b/test/data/test_pretty_json.json @@ -0,0 +1,4 @@ +{ + "ERROR_HANDLER_WARNING_DISMISS": "OK", + "ANOTHER_STRING": "hello" +} \ No newline at end of file diff --git a/test/data/test_unpretty_json.json b/test/data/test_unpretty_json.json new file mode 100644 index 0000000..4bf8460 --- /dev/null +++ b/test/data/test_unpretty_json.json @@ -0,0 +1 @@ +{"ERROR_HANDLER_WARNING_DISMISS":"OK","ANOTHER_STRING":"hello"} \ No newline at end of file From b89754e21e2cfb5482300d5ec55bcb58822204ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Benaiteau?= Date: Mon, 8 Jun 2020 22:45:49 +0200 Subject: [PATCH 3/9] Update .babelish.sample --- .babelish.sample | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.babelish.sample b/.babelish.sample index 2e60716..9be3f1f 100644 --- a/.babelish.sample +++ b/.babelish.sample @@ -35,5 +35,8 @@ langs: # Languages to convert. i.e. English:en ###################################### General ###################################### +# csv_separator: ',' # CSV column separator character, uses ',' by default -# csv_separator: ',' # CSV column separator character, uses ',' by default \ No newline at end of file +###################################### JSON ###################################### + +# pretty_json: false # Prettify your json output files From 5d7b16b103131c596ad0b950c6b22e563a291927 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Mon, 26 Nov 2018 16:20:36 +0100 Subject: [PATCH 4/9] Add alias for pretty_json option --- lib/babelish/commandline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/babelish/commandline.rb b/lib/babelish/commandline.rb index 6fe0ebc..237628e 100644 --- a/lib/babelish/commandline.rb +++ b/lib/babelish/commandline.rb @@ -31,7 +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, :default => false, :desc => "Prettify your json output files" + method_option :pretty_json, :type => :boolean, :aliases => "-p", :default => false, :desc => "Prettify your json output files" if klass[:name] == "CSV2Strings" method_option :macros_filename, :type => :boolean, :aliases => "-m", :lazy_default => false, :desc => "Filename containing defines of localized keys" end From 28d320b82e61fbce194e1d5e49b6e02f8fa53be1 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Mon, 26 Nov 2018 16:35:52 +0100 Subject: [PATCH 5/9] Refactor csv2base --- lib/babelish/csv2base.rb | 1 - lib/babelish/csv2json.rb | 5 +++++ test/babelish/test_csv2json.rb | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/babelish/csv2base.rb b/lib/babelish/csv2base.rb index 5419811..35df277 100644 --- a/lib/babelish/csv2base.rb +++ b/lib/babelish/csv2base.rb @@ -39,7 +39,6 @@ def initialize(filename, langs, args = {}) @csv_separator = args[:csv_separator] @ignore_lang_path = args[:ignore_lang_path] @stripping = args[:stripping] - @pretty_json = args[:pretty_json] @languages = [] @comments = {} end diff --git a/lib/babelish/csv2json.rb b/lib/babelish/csv2json.rb index 87e107d..3c434fb 100644 --- a/lib/babelish/csv2json.rb +++ b/lib/babelish/csv2json.rb @@ -2,6 +2,11 @@ module Babelish require 'json' class CSV2JSON < Csv2Base + def initialize(filename, langs, args = {}) + super + @pretty_json = args[:pretty_json] + end + def language_filepaths(language) require 'pathname' filename = @output_basename || language.code diff --git a/test/babelish/test_csv2json.rb b/test/babelish/test_csv2json.rb index 5217188..1f64fff 100644 --- a/test/babelish/test_csv2json.rb +++ b/test/babelish/test_csv2json.rb @@ -31,7 +31,7 @@ def test_converting_csv_to_json_with_unpretty_json 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) + converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, :output_basename => 'output', pretty_json: false) converter.convert given_json = File.read(given_json_filename) assert_equal(expected_json, given_json, "JSON file has incorrect format") @@ -46,7 +46,7 @@ def test_converting_csv_to_json_with_pretty_json 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) + converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, :output_basename => 'output', pretty_json: true) converter.convert given_json = File.read(given_json_filename) assert_equal(expected_json, given_json, "JSON file has incorrect format") From c22ce9fdd6df240301ded53f2bb7700ae6e028dd Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Mon, 26 Nov 2018 17:10:16 +0100 Subject: [PATCH 6/9] Remove default parameter from commandline.rb --- lib/babelish/commandline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/babelish/commandline.rb b/lib/babelish/commandline.rb index 237628e..efb3329 100644 --- a/lib/babelish/commandline.rb +++ b/lib/babelish/commandline.rb @@ -31,7 +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", :default => false, :desc => "Prettify your json output files" + method_option :pretty_json, :type => :boolean, :aliases => "-p", :desc => "Prettify your json output files" if klass[:name] == "CSV2Strings" method_option :macros_filename, :type => :boolean, :aliases => "-m", :lazy_default => false, :desc => "Filename containing defines of localized keys" end From 9598e4e680f7cc688f52edd07f148c60b6aeeb85 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 27 Nov 2018 15:54:29 +0100 Subject: [PATCH 7/9] Apply fixes according to automatic code review --- lib/babelish/commandline.rb | 2 +- lib/babelish/csv2json.rb | 2 +- test/babelish/test_csv2json.rb | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/babelish/commandline.rb b/lib/babelish/commandline.rb index efb3329..8d8890b 100644 --- a/lib/babelish/commandline.rb +++ b/lib/babelish/commandline.rb @@ -31,7 +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" + method_option :pretty_json, :type => :boolean, aliases: "-p", desc: "Prettify your json output files" if klass[:name] == "CSV2Strings" method_option :macros_filename, :type => :boolean, :aliases => "-m", :lazy_default => false, :desc => "Filename containing defines of localized keys" end diff --git a/lib/babelish/csv2json.rb b/lib/babelish/csv2json.rb index 3c434fb..c2ff577 100644 --- a/lib/babelish/csv2json.rb +++ b/lib/babelish/csv2json.rb @@ -16,7 +16,7 @@ def language_filepaths(language) end def hash_to_output(content = {}) - return @pretty_json ? JSON.pretty_generate(content) : content.to_json + @pretty_json ? JSON.pretty_generate(content) : content.to_json end def extension diff --git a/test/babelish/test_csv2json.rb b/test/babelish/test_csv2json.rb index 1f64fff..63dce26 100644 --- a/test/babelish/test_csv2json.rb +++ b/test/babelish/test_csv2json.rb @@ -27,11 +27,11 @@ def test_converting_csv_to_dotstrings_one_output_option 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' + expected_json_filename = "test_unpretty_json.json" + 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) + expected_json = File.read("test/data/" + expected_json_filename) + converter = Babelish::CSV2JSON.new(csv_file, { "English" => "en" }, output_basename: "output", pretty_json: false) converter.convert given_json = File.read(given_json_filename) assert_equal(expected_json, given_json, "JSON file has incorrect format") @@ -42,11 +42,11 @@ def test_converting_csv_to_json_with_unpretty_json 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' + expected_json_filename = "test_pretty_json.json" + 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) + expected_json = File.read("test/data/" + expected_json_filename) + converter = Babelish::CSV2JSON.new(csv_file, { "English" => "en" }, output_basename: "output", pretty_json: true) converter.convert given_json = File.read(given_json_filename) assert_equal(expected_json, given_json, "JSON file has incorrect format") From fe4a47390c0aae402f03c2ed33a7e0b19fbac14f Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 27 Nov 2018 16:05:58 +0100 Subject: [PATCH 8/9] Fix formatting in test_csv2json.rb --- test/babelish/test_csv2json.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/babelish/test_csv2json.rb b/test/babelish/test_csv2json.rb index 63dce26..8cd965b 100644 --- a/test/babelish/test_csv2json.rb +++ b/test/babelish/test_csv2json.rb @@ -31,7 +31,10 @@ def test_converting_csv_to_json_with_unpretty_json 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) + converter = Babelish::CSV2JSON.new(csv_file, + { "English" => "en" }, + output_basename: "output", + pretty_json: false) converter.convert given_json = File.read(given_json_filename) assert_equal(expected_json, given_json, "JSON file has incorrect format") @@ -46,7 +49,10 @@ def test_converting_csv_to_json_with_pretty_json 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) + converter = Babelish::CSV2JSON.new(csv_file, + { "English" => "en" }, + output_basename: "output", + pretty_json: true) converter.convert given_json = File.read(given_json_filename) assert_equal(expected_json, given_json, "JSON file has incorrect format") From 9fa208cfd27d85e41717ec32d4311d40fccf5f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Benaiteau?= Date: Mon, 8 Jun 2020 23:21:08 +0200 Subject: [PATCH 9/9] Fixes rule about Ruby19 hash syntax --- lib/babelish/android2csv.rb | 2 +- lib/babelish/base2csv.rb | 2 +- lib/babelish/commandline.rb | 68 +++++++++---------- lib/babelish/csv2base.rb | 10 +-- lib/babelish/json2csv.rb | 2 +- lib/babelish/php2csv.rb | 2 +- lib/babelish/strings2csv.rb | 2 +- .../commands/test_command_android2csv.rb | 14 ++-- .../commands/test_command_csv2android.rb | 14 ++-- .../commands/test_command_csv2strings.rb | 46 ++++++------- .../commands/test_command_strings2csv.rb | 24 +++---- test/babelish/test_android2csv.rb | 12 ++-- test/babelish/test_base2csv.rb | 8 +-- test/babelish/test_commandline.rb | 12 ++-- test/babelish/test_csv2android.rb | 8 +-- test/babelish/test_csv2base.rb | 8 +-- test/babelish/test_csv2json.rb | 4 +- test/babelish/test_csv2php.rb | 4 +- test/babelish/test_csv2strings.rb | 14 ++-- test/babelish/test_json2csv.rb | 6 +- test/babelish/test_php2csv.rb | 6 +- test/babelish/test_strings2csv.rb | 10 +-- 22 files changed, 139 insertions(+), 139 deletions(-) diff --git a/lib/babelish/android2csv.rb b/lib/babelish/android2csv.rb index b6e6ffd..07630fc 100644 --- a/lib/babelish/android2csv.rb +++ b/lib/babelish/android2csv.rb @@ -2,7 +2,7 @@ module Babelish require "nokogiri" class Android2CSV < Base2Csv - def initialize(args = {:filenames => []}) + def initialize(args = {filenames: []}) super(args) end diff --git a/lib/babelish/base2csv.rb b/lib/babelish/base2csv.rb index 0416639..175981c 100644 --- a/lib/babelish/base2csv.rb +++ b/lib/babelish/base2csv.rb @@ -2,7 +2,7 @@ module Babelish class Base2Csv attr_accessor :csv_filename, :headers, :filenames, :default_lang - def initialize(args = {:filenames => []}) + def initialize(args = {filenames: []}) raise ArgumentError.new("No filenames given") unless args[:filenames] if args[:headers] raise ArgumentError.new("number of headers and files don't match, don't forget the constant column") unless args[:headers].size == (args[:filenames].size + 1) diff --git a/lib/babelish/commandline.rb b/lib/babelish/commandline.rb index 8d8890b..e329e09 100644 --- a/lib/babelish/commandline.rb +++ b/lib/babelish/commandline.rb @@ -2,38 +2,38 @@ require 'yaml' class Commandline < Thor include Thor::Actions - class_option :verbose, :type => :boolean - class_option :config, :type => :string, :aliases => "-c", :desc => "Read configuration from given file", :default => ".babelish" + class_option :verbose, type: :boolean + class_option :config, type: :string, aliases: "-c", desc: "Read configuration from given file", default: ".babelish" map "-v" => :version CSVCLASSES = [ - {:name => "CSV2Strings", :ext => ".strings"}, - {:name => "CSV2Android", :ext => ".xml"}, - {:name => "CSV2JSON", :ext => ".json"}, - {:name => "CSV2Php", :ext => ".php"}, + {name: "CSV2Strings", ext: ".strings"}, + {name: "CSV2Android", ext: ".xml"}, + {name: "CSV2JSON", ext: ".json"}, + {name: "CSV2Php", ext: ".php"}, ] CSVCLASSES.each do |klass| desc "#{klass[:name].downcase}", "Convert CSV file to #{klass[:ext]}" - method_option :filename, :type => :string, :aliases => "-i", :desc => "CSV file to convert from or name of file in Google Drive" - method_option :langs, :type => :hash, :aliases => "-L", :desc => "Languages to convert. i.e. English:en" + method_option :filename, type: :string, aliases: "-i", desc: "CSV file to convert from or name of file in Google Drive" + method_option :langs, type: :hash, aliases: "-L", desc: "Languages to convert. i.e. English:en" # optional options - method_option :excluded_states, :type => :array, :aliases => "-x", :desc => "Exclude rows with given state" - method_option :state_column, :type => :numeric, :aliases => "-s", :desc => "Position of column for state if any" - method_option :keys_column, :type => :numeric, :aliases => "-k", :desc => "Position of column for keys" - method_option :comments_column, :type => :numeric, :aliases => "-C", :desc => "Position of column for comments if any" - method_option :default_lang, :type => :string, :aliases => "-l", :desc => "Default language to use for empty values if any" - method_option :csv_separator, :type => :string, :aliases => "-S", :desc => "CSV column separator character, uses ',' by default" - method_option :output_dir, :type => :string, :aliases => "-d", :desc => "Path of output files" - method_option :output_basenames, :type => :array, :aliases => "-o", :desc => "Basename of output files" - method_option :stripping, :type => :boolean, :aliases => "-N", :default => false, :desc => "Strips values of spreadsheet" - 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" + method_option :excluded_states, type: :array, aliases: "-x", desc: "Exclude rows with given state" + method_option :state_column, type: :numeric, aliases: "-s", desc: "Position of column for state if any" + method_option :keys_column, type: :numeric, aliases: "-k", desc: "Position of column for keys" + method_option :comments_column, type: :numeric, aliases: "-C", desc: "Position of column for comments if any" + method_option :default_lang, type: :string, aliases: "-l", desc: "Default language to use for empty values if any" + method_option :csv_separator, type: :string, aliases: "-S", desc: "CSV column separator character, uses ',' by default" + method_option :output_dir, type: :string, aliases: "-d", desc: "Path of output files" + method_option :output_basenames, type: :array, aliases: "-o", desc: "Basename of output files" + method_option :stripping, type: :boolean, aliases: "-N", default: false, desc: "Strips values of spreadsheet" + 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" if klass[:name] == "CSV2Strings" - method_option :macros_filename, :type => :boolean, :aliases => "-m", :lazy_default => false, :desc => "Filename containing defines of localized keys" + method_option :macros_filename, type: :boolean, aliases: "-m", lazy_default: false, desc: "Filename containing defines of localized keys" end define_method("#{klass[:name].downcase}") do csv2base(klass[:name]) @@ -41,20 +41,20 @@ class Commandline < Thor end BASECLASSES = [ - {:name => "Strings2CSV", :ext => ".strings"}, - {:name => "Android2CSV", :ext => ".xml"}, - {:name => "JSON2CSV", :ext => ".json"}, - {:name => "Php2CSV", :ext => ".php"}, + {name: "Strings2CSV", ext: ".strings"}, + {name: "Android2CSV", ext: ".xml"}, + {name: "JSON2CSV", ext: ".json"}, + {name: "Php2CSV", ext: ".php"}, ] BASECLASSES.each do |klass| desc "#{klass[:name].downcase}", "Convert #{klass[:ext]} files to CSV file" - method_option :filenames, :type => :array, :aliases => "-i", :desc => "location of strings files (FILENAMES)" + method_option :filenames, type: :array, aliases: "-i", desc: "location of strings files (FILENAMES)" # optional options - method_option :csv_filename, :type => :string, :aliases => "-o", :desc => "location of output file" - method_option :headers, :type => :array, :aliases => "-h", :desc => "override headers of columns, default is name of input files and 'Variables' for reference" - method_option :dryrun, :type => :boolean, :aliases => "-n", :desc => "prints out content of hash without writing file" + method_option :csv_filename, type: :string, aliases: "-o", desc: "location of output file" + method_option :headers, type: :array, aliases: "-h", desc: "override headers of columns, default is name of input files and 'Variables' for reference" + method_option :dryrun, type: :boolean, aliases: "-n", desc: "prints out content of hash without writing file" define_method("#{klass[:name].downcase}") do begin base2csv(klass[:name]) @@ -65,10 +65,10 @@ class Commandline < Thor end desc "csv_download", "Download Google Spreadsheet containing translations" - method_option :gd_filename, :type => :string, :desc => "File to download from Google Drive." - method_option :sheet, :type => :numeric, :desc => "Index of worksheet to download. First index is 0." - method_option :all, :type => :boolean, :lazy_default => true, :desc => "Download all worksheets to individual csv files." - method_option :output_filename, :type => :string, :desc => "Filepath of downloaded file." + method_option :gd_filename, type: :string, desc: "File to download from Google Drive." + method_option :sheet, type: :numeric, desc: "Index of worksheet to download. First index is 0." + method_option :all, type: :boolean, lazy_default: true, desc: "Download all worksheets to individual csv files." + method_option :output_filename, type: :string, desc: "Filepath of downloaded file." def csv_download all = options[:sheet] ? false : options[:all] filename = options['gd_filename'] diff --git a/lib/babelish/csv2base.rb b/lib/babelish/csv2base.rb index 35df277..d210968 100644 --- a/lib/babelish/csv2base.rb +++ b/lib/babelish/csv2base.rb @@ -12,10 +12,10 @@ class Csv2Base def initialize(filename, langs, args = {}) default_args = { - :excluded_states => [], - :state_column => nil, - :keys_column => 0, - :csv_separator => "," + excluded_states: [], + state_column: nil, + keys_column: 0, + csv_separator: "," } args = default_args.merge!(args) @@ -99,7 +99,7 @@ def convert(name = @csv_filename) excludedCols = [] defaultCol = 0 - CSV.foreach(name, :quote_char => '"', :col_sep => @csv_separator, :row_sep => :auto) do |row| + CSV.foreach(name, quote_char: '"', col_sep: @csv_separator, row_sep: :auto) do |row| if rowIndex == 0 #check there's at least two columns diff --git a/lib/babelish/json2csv.rb b/lib/babelish/json2csv.rb index 351ab9b..f48e7bb 100644 --- a/lib/babelish/json2csv.rb +++ b/lib/babelish/json2csv.rb @@ -2,7 +2,7 @@ module Babelish require 'json' class JSON2CSV < Base2Csv - def initialize(args = {:filenames => []}) + def initialize(args = {filenames: []}) super(args) end diff --git a/lib/babelish/php2csv.rb b/lib/babelish/php2csv.rb index 418d34b..af89a86 100644 --- a/lib/babelish/php2csv.rb +++ b/lib/babelish/php2csv.rb @@ -1,7 +1,7 @@ module Babelish class Php2CSV < Base2Csv - def initialize(args = {:filenames => []}) + def initialize(args = {filenames: []}) super(args) end diff --git a/lib/babelish/strings2csv.rb b/lib/babelish/strings2csv.rb index 5e783fa..818b656 100644 --- a/lib/babelish/strings2csv.rb +++ b/lib/babelish/strings2csv.rb @@ -4,7 +4,7 @@ class Strings2CSV < Base2Csv # actually default_lang = default_filename attr_accessor :csv_filename, :headers, :filenames, :default_lang - def initialize(args = {:filenames => []}) + def initialize(args = {filenames: []}) super(args) end diff --git a/test/babelish/commands/test_command_android2csv.rb b/test/babelish/commands/test_command_android2csv.rb index 0254dbc..716da12 100644 --- a/test/babelish/commands/test_command_android2csv.rb +++ b/test/babelish/commands/test_command_android2csv.rb @@ -1,7 +1,7 @@ require 'test_helper' class TestAndroid2CSVCommand < Test::Unit::TestCase def test_android2csv - options = {:filenames => ["test/data/android.xml"]} + options = {filenames: ["test/data/android.xml"]} Commandline.new([], options).android2csv assert File.exist?("translations.csv") @@ -11,7 +11,7 @@ def test_android2csv end def test_android2csv_with_dryrun_option - options = {:filenames => ["test/data/android.xml"], :dryrun => true} + options = {filenames: ["test/data/android.xml"], dryrun: true} Commandline.new([], options).android2csv assert !File.exist?("translations.csv") @@ -21,7 +21,7 @@ def test_android2csv_with_dryrun_option end def test_android2csv_with_output_file - options = {:filenames => ["test/data/android.xml"], :csv_filename => "myfile.csv"} + options = {filenames: ["test/data/android.xml"], csv_filename: "myfile.csv"} # -i, -o Commandline.new([], options).android2csv @@ -32,7 +32,7 @@ def test_android2csv_with_output_file end def test_android2csv_with_headers - options = {:filenames => ["test/data/android.xml"], :headers => ["constants", "english"]} + options = {filenames: ["test/data/android.xml"], headers: ["constants", "english"]} # -i, -h Commandline.new([], options).android2csv @@ -44,9 +44,9 @@ def test_android2csv_with_headers def test_android2csv_with_two_files options = { - :filenames => ["test/data/android-en.xml", "test/data/android-fr.xml"], - :headers => %w{Constants English French}, - :csv_filename => "enfr.csv" + filenames: ["test/data/android-en.xml", "test/data/android-fr.xml"], + headers: %w{Constants English French}, + csv_filename: "enfr.csv" } # --filenames, --headers, -o Commandline.new([], options).android2csv diff --git a/test/babelish/commands/test_command_csv2android.rb b/test/babelish/commands/test_command_csv2android.rb index f76108c..a97c0c8 100644 --- a/test/babelish/commands/test_command_csv2android.rb +++ b/test/babelish/commands/test_command_csv2android.rb @@ -3,8 +3,8 @@ class TestCSV2AndroidCommand < Test::Unit::TestCase def test_csv2android_with_multiple_2_languages options = { - :filename => "test/data/test_data_multiple_langs.csv", - :langs => {"English" => "en", "French" => "fr"} + filename: "test/data/test_data_multiple_langs.csv", + langs: {"English" => "en", "French" => "fr"} } Commandline.new([], options).csv2android @@ -18,8 +18,8 @@ def test_csv2android_with_multiple_2_languages def test_csv2android_with_multiple_2_languages_with_region options = { - :filename => "test/data/test_data_multiple_langs.csv", - :langs => {"English" => "en-US", "French" => "fr"} + filename: "test/data/test_data_multiple_langs.csv", + langs: {"English" => "en-US", "French" => "fr"} } Commandline.new([], options).csv2android @@ -33,9 +33,9 @@ def test_csv2android_with_multiple_2_languages_with_region def test_csv2android_with_output_dir options = { - :filename => "test/data/test_data_multiple_langs.csv", - :langs => {"English" => "en", "French" => "fr"}, - :output_dir => "mynewlocation" + filename: "test/data/test_data_multiple_langs.csv", + langs: {"English" => "en", "French" => "fr"}, + output_dir: "mynewlocation" } Commandline.new([], options).csv2android diff --git a/test/babelish/commands/test_command_csv2strings.rb b/test/babelish/commands/test_command_csv2strings.rb index ce76758..2adc50d 100644 --- a/test/babelish/commands/test_command_csv2strings.rb +++ b/test/babelish/commands/test_command_csv2strings.rb @@ -3,8 +3,8 @@ class TestCSV2StringsCommand < Test::Unit::TestCase def test_csv2strings_with_multiple_2_languages options = { - :filename => "test/data/test_data_multiple_langs.csv", - :langs => {"English" => "en", "French" => "fr"} + filename: "test/data/test_data_multiple_langs.csv", + langs: {"English" => "en", "French" => "fr"} } Commandline.new([], options).csv2strings @@ -18,9 +18,9 @@ def test_csv2strings_with_multiple_2_languages def test_csv2strings_with_output_dir options = { - :filename => "test/data/test_data_multiple_langs.csv", - :langs => {"English" => "en", "French" => "fr"}, - :output_dir => "mynewlocation" + filename: "test/data/test_data_multiple_langs.csv", + langs: {"English" => "en", "French" => "fr"}, + output_dir: "mynewlocation" } Commandline.new([], options).csv2strings @@ -35,9 +35,9 @@ def test_csv2strings_with_output_dir def test_csv2strings_with_fetch_google_doc omit if ENV['TRAVIS'] options = { - :filename => "my_strings", - :langs => {"English" => "en", "French" => "fr"}, - :fetch => true + filename: "my_strings", + langs: {"English" => "en", "French" => "fr"}, + fetch: true } assert_nothing_raised do Commandline.new([], options).csv2strings @@ -63,10 +63,10 @@ def test_csv2strings_with_config_file def test_csv2strings_with_output_basenames_option omit if ENV['TRAVIS'] options = { - :filename => "my_strings", - :langs => {"English" => "en", "French" => "fr"}, - :fetch => true, - :output_basenames => %w(sheet1 sheet2), + filename: "my_strings", + langs: {"English" => "en", "French" => "fr"}, + fetch: true, + output_basenames: %w(sheet1 sheet2), } Commandline.new([], options).csv2strings @@ -84,11 +84,11 @@ def test_csv2strings_with_output_basenames_option def test_csv2strings_with_ignore_lang_path_option omit if ENV['TRAVIS'] options = { - :filename => "my_strings", - :langs => {"English" => "en"}, - :fetch => true, - :ignore_lang_path => true, - :output_basenames => %w(sheet1 sheet2), + filename: "my_strings", + langs: {"English" => "en"}, + fetch: true, + ignore_lang_path: true, + output_basenames: %w(sheet1 sheet2), } Commandline.new([], options).csv2strings @@ -103,9 +103,9 @@ def test_csv2strings_with_ignore_lang_path_option def test_csv2strings_with_ignore_lang_path_option_local options = { - :filename => "test/data/test_data.csv", - :langs => {"English" => "en"}, - :ignore_lang_path => true, + filename: "test/data/test_data.csv", + langs: {"English" => "en"}, + ignore_lang_path: true, } Commandline.new([], options).csv2strings @@ -118,9 +118,9 @@ def test_csv2strings_with_ignore_lang_path_option_local def test_csv2string_with_macros_filename options = { - :filename => "test/data/test_data.csv", - :macros_filename => "Babelish.h", - :langs => { "English" => "en" } + filename: "test/data/test_data.csv", + macros_filename: "Babelish.h", + langs: { "English" => "en" } } Commandline.new([], options).csv2strings diff --git a/test/babelish/commands/test_command_strings2csv.rb b/test/babelish/commands/test_command_strings2csv.rb index d910df7..7d8df54 100644 --- a/test/babelish/commands/test_command_strings2csv.rb +++ b/test/babelish/commands/test_command_strings2csv.rb @@ -2,7 +2,7 @@ class TestStrings2CSVCommand < Test::Unit::TestCase def test_strings2csv - options = {:filenames => ["test/data/test_data.strings"]} + options = {filenames: ["test/data/test_data.strings"]} Commandline.new([], options).strings2csv assert File.exist?("translations.csv") @@ -12,7 +12,7 @@ def test_strings2csv end def test_strings2csv_with_dryrun_option - options = {:filenames => ["test/data/test_data.strings"], :dryrun => true} + options = {filenames: ["test/data/test_data.strings"], dryrun: true} Commandline.new([], options).strings2csv assert !File.exist?("translations.csv") @@ -22,7 +22,7 @@ def test_strings2csv_with_dryrun_option end def test_strings2csv_with_output_file - options = {:filenames => ["test/data/test_data.strings"], :csv_filename => "myfile.csv"} + options = {filenames: ["test/data/test_data.strings"], csv_filename: "myfile.csv"} # -i, -o Commandline.new([], options).strings2csv @@ -33,7 +33,7 @@ def test_strings2csv_with_output_file end def test_strings2csv_with_headers - options = {:filenames => ["test/data/test_data.strings"], :headers => ["constants", "english"]} + options = {filenames: ["test/data/test_data.strings"], headers: ["constants", "english"]} # -i, -h Commandline.new([], options).strings2csv @@ -45,9 +45,9 @@ def test_strings2csv_with_headers def test_strings2csv_with_two_files options = { - :filenames => ["test/data/test_en.strings", "test/data/test_fr.strings"], - :headers => %w{Constants English French}, - :csv_filename => "enfr.csv" + filenames: ["test/data/test_en.strings", "test/data/test_fr.strings"], + headers: %w{Constants English French}, + csv_filename: "enfr.csv" } # --filenames, --headers, -o Commandline.new([], options).strings2csv @@ -60,8 +60,8 @@ def test_strings2csv_with_two_files def test_strings2csv_with_empty_lines options = { - :filenames => ["test/data/test_with_nil.strings"], - :csv_filename => "test_with_nil.csv" + filenames: ["test/data/test_with_nil.strings"], + csv_filename: "test_with_nil.csv" } # -i, -o @@ -77,8 +77,8 @@ def test_strings2csv_with_empty_lines def test_strings2csv_utf16 options = { - :filenames => ["test/data/test_utf16.strings"], - :csv_filename => "test_utf16.csv" + filenames: ["test/data/test_utf16.strings"], + csv_filename: "test_utf16.csv" } # -i, -o @@ -98,7 +98,7 @@ def test_strings2csv_with_comments_outputs_right_headers MY_CONSTANT,This 'is' ok,this is a comment EOF - options = { :filenames => ["test/data/test_comments.strings"] } + options = { filenames: ["test/data/test_comments.strings"] } Commandline.new([], options).strings2csv csv_content = `cat translations.csv` diff --git a/test/babelish/test_android2csv.rb b/test/babelish/test_android2csv.rb index d38a43e..1025161 100644 --- a/test/babelish/test_android2csv.rb +++ b/test/babelish/test_android2csv.rb @@ -18,9 +18,9 @@ def test_initialize filenames = %w{french.strings english.strings} headers = %w{constants french english} converter = Babelish::Android2CSV.new( - :csv_filename => csv_filename, - :headers => headers, - :filenames => filenames) + csv_filename: csv_filename, + headers: headers, + filenames: filenames) assert_equal csv_filename, converter.csv_filename assert_equal headers, converter.headers @@ -38,9 +38,9 @@ def test_special_chars headers = %w{variables german} converter = Babelish::Android2CSV.new( - :csv_filename => csv_filename, - :headers => headers, - :filenames => [filenames]) + csv_filename: csv_filename, + headers: headers, + filenames: [filenames]) converter.convert diff --git a/test/babelish/test_base2csv.rb b/test/babelish/test_base2csv.rb index 9932d8a..266287c 100644 --- a/test/babelish/test_base2csv.rb +++ b/test/babelish/test_base2csv.rb @@ -12,7 +12,7 @@ def test_create_csv_file filename = "test_data" strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}} - converter = Babelish::Base2Csv.new(:headers => %w{variables english}, :filenames => [filename]) + converter = Babelish::Base2Csv.new(headers: %w{variables english}, filenames: [filename]) converter.send :create_csv_file, keys, strings assert File.exist?(converter.csv_filename) @@ -26,9 +26,9 @@ def test_initialize filenames = %w{"french.strings english.strings"} headers = %w{"constants french english"} converter = Babelish::Base2Csv.new({ - :csv_filename => csv_filename, - :headers => headers, - :filenames => filenames + csv_filename: csv_filename, + headers: headers, + filenames: filenames }) assert_equal csv_filename, converter.csv_filename diff --git a/test/babelish/test_commandline.rb b/test/babelish/test_commandline.rb index 6f3b44c..4f4da69 100644 --- a/test/babelish/test_commandline.rb +++ b/test/babelish/test_commandline.rb @@ -11,8 +11,8 @@ def test_init def test_csv2base_with_config_file_all_required_options options = { - :filename => "test/data/test_data_multiple_langs.csv", - :langs => {"English" => "en", "French" => "fr"} + filename: "test/data/test_data_multiple_langs.csv", + langs: {"English" => "en", "French" => "fr"} } config_file = File.new(".babelish", "w") config_file.write options.to_yaml @@ -31,7 +31,7 @@ def test_csv2base_with_config_file_all_required_options def test_csv2base_without_filename_fails options = { - :langs => {"English" => "en", "French" => "fr"} + langs: {"English" => "en", "French" => "fr"} } config_file = File.new(".babelish", "w") config_file.write options.to_yaml @@ -49,7 +49,7 @@ def test_csv2base_without_filename_fails def test_base2csv_with_config_file_all_required_options options = { - :filenames => ["test/data/test_en.strings", "test/data/test_fr.strings"], + filenames: ["test/data/test_en.strings", "test/data/test_fr.strings"], } config_file = File.new(".babelish", "w") config_file.write options.to_yaml @@ -79,7 +79,7 @@ def test_base2csv_with_config_without_filenames_fails end def test_base2csv_with_config_with_non_existent_filenames_fails - options = {:filenames => ['foo']} + options = {filenames: ['foo']} config_file = File.new(".babelish", "w") config_file.write options.to_yaml config_file.close @@ -111,7 +111,7 @@ def test_csv_download_without_gd_filename_fails def test_csv_download_with_required_params omit if ENV['TRAVIS'] - options = {:gd_filename => "my_strings"} + options = {gd_filename: "my_strings"} config_file = File.new(".babelish", "w") config_file.write options.to_yaml config_file.close diff --git a/test/babelish/test_csv2android.rb b/test/babelish/test_csv2android.rb index f9f7d4a..9e886db 100644 --- a/test/babelish/test_csv2android.rb +++ b/test/babelish/test_csv2android.rb @@ -28,8 +28,8 @@ def test_converting_csv_to_dotstrings_one_output_option converter = Babelish::CSV2Android.new( csv_file, { "English" => "en" }, - :output_basename => "myApp", - :ignore_lang_path => true + output_basename: "myApp", + ignore_lang_path: true ) converter.convert assert File.exist?(single_file), "the ouptut file does not exist" @@ -45,8 +45,8 @@ def test_converting_with_comments converter = Babelish::CSV2Android.new( csv_file, { "French" => "fr" }, - :default_lang => "English", - :comments_column => 5 + default_lang: "English", + comments_column: 5 ) converter.convert assert File.exist?(french_file), "the ouptut file does not exist" diff --git a/test/babelish/test_csv2base.rb b/test/babelish/test_csv2base.rb index 17a2b37..62282b2 100644 --- a/test/babelish/test_csv2base.rb +++ b/test/babelish/test_csv2base.rb @@ -7,9 +7,9 @@ def test_initialize state_column = "Local" keys_column = 23 converter = Babelish::Csv2Base.new(csv_filename, {"English" => ["en"]}, { - :excluded_states => excluded_states, - :state_column => state_column, - :keys_column => keys_column }) + excluded_states: excluded_states, + state_column: state_column, + keys_column: keys_column }) assert_equal csv_filename, converter.csv_filename assert_equal excluded_states, converter.excluded_states @@ -23,7 +23,7 @@ def test_initialize_with_default_values end def test_initialize_with_custom_separator - converter = Babelish::Csv2Base.new("file.csv", { "English" => ["en"] }, { :csv_separator => ";" }) + converter = Babelish::Csv2Base.new("file.csv", { "English" => ["en"] }, { csv_separator: ";" }) assert_not_nil converter.csv_filename end diff --git a/test/babelish/test_csv2json.rb b/test/babelish/test_csv2json.rb index 8cd965b..e9261f5 100644 --- a/test/babelish/test_csv2json.rb +++ b/test/babelish/test_csv2json.rb @@ -16,8 +16,8 @@ def test_converting_csv_to_dotstrings_one_output_option single_file = 'myfile.json' converter = Babelish::CSV2JSON.new(csv_file, {'English' => "en"}, - :output_basename => 'myfile', - :ignore_lang_path => true) + output_basename: 'myfile', + ignore_lang_path: true) converter.convert assert File.exist?(single_file), "the ouptut file does not exist" diff --git a/test/babelish/test_csv2php.rb b/test/babelish/test_csv2php.rb index 26db4ee..abc376e 100644 --- a/test/babelish/test_csv2php.rb +++ b/test/babelish/test_csv2php.rb @@ -16,8 +16,8 @@ def test_converting_csv_to_dotstrings_one_output_option single_file = 'myApp.php' converter = Babelish::CSV2Php.new(csv_file, {'English' => "en"}, - :output_basename => 'myApp', - :ignore_lang_path => true) + output_basename: 'myApp', + ignore_lang_path: true) converter.convert assert File.exist?(single_file), "the ouptut file does not exist" diff --git a/test/babelish/test_csv2strings.rb b/test/babelish/test_csv2strings.rb index 0f4e1f1..eb69459 100644 --- a/test/babelish/test_csv2strings.rb +++ b/test/babelish/test_csv2strings.rb @@ -14,8 +14,8 @@ def test_converting_csv_to_dotstrings_one_output_option single_file = 'myApp.strings' converter = Babelish::CSV2Strings.new(csv_file, {'English' => [:en]}, - :output_basename => 'myApp', - :ignore_lang_path => true) + output_basename: 'myApp', + ignore_lang_path: true) converter.convert assert File.exist?(single_file), "the ouptut file does not exist" system("rm -f #{single_file}") @@ -30,7 +30,7 @@ def test_converting_csv_to_dotstrings_default_lang spanish_file = "es.lproj/Localizable.strings" converter = Babelish::CSV2Strings.new(csv_file, {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"}, - :default_lang => "English") + default_lang: "English") converter.convert assert File.exist?(spanish_file), "the ouptut file does not exist" result = File.read(spanish_file) @@ -63,7 +63,7 @@ def test_converting_csv_to_dotstrings_default_lang_to_key spanish_file = "es.lproj/Localizable.strings" converter = Babelish::CSV2Strings.new(csv_file, {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"}, - :default_lang => "variables") + default_lang: "variables") converter.convert assert File.exist?(spanish_file), "the ouptut file does not exist" result = File.read(spanish_file) @@ -79,7 +79,7 @@ def test_converting_csv_to_dotstrings_keys csv_file = "test/data/test_data_multiple_langs.csv" converter = Babelish::CSV2Strings.new(csv_file, {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"}, - :default_lang => "variables") + default_lang: "variables") converter.convert assert !converter.keys.empty? system("rm -rf *.lproj") @@ -131,7 +131,7 @@ def test_converting_csv_to_dotstrings_with_stripping_option "ANOTHER_STRING" = "my other string with space at begin"; EOS csv_file = "test/data/test_data_with_spaces.csv" - converter = Babelish::CSV2Strings.new(csv_file, {"English" => [:en]}, :stripping => true) + converter = Babelish::CSV2Strings.new(csv_file, {"English" => [:en]}, stripping: true) converter.convert result = File.read("en.lproj/Localizable.strings") assert_equal expected_output, result @@ -144,7 +144,7 @@ def test_converting_with_comments expected_output = File.read("test/data/test_data_fr_with_comments.strings") converter = Babelish::CSV2Strings.new(csv_file, {"French" => "fr"}, - :default_lang => "English", :comments_column => 5) + default_lang: "English", comments_column: 5) converter.convert assert File.exist?(spanish_file), "the ouptut file does not exist" result = File.read(spanish_file) diff --git a/test/babelish/test_json2csv.rb b/test/babelish/test_json2csv.rb index ca32ea7..d234a36 100644 --- a/test/babelish/test_json2csv.rb +++ b/test/babelish/test_json2csv.rb @@ -18,9 +18,9 @@ def test_initialize filenames = %w{"french.strings english.strings"} headers = %w{"constants french english"} converter = Babelish::JSON2CSV.new({ - :csv_filename => csv_filename, - :headers => headers, - :filenames => filenames }) + csv_filename: csv_filename, + headers: headers, + filenames: filenames }) assert_equal csv_filename, converter.csv_filename assert_equal headers, converter.headers diff --git a/test/babelish/test_php2csv.rb b/test/babelish/test_php2csv.rb index a772e7c..0da4d7d 100644 --- a/test/babelish/test_php2csv.rb +++ b/test/babelish/test_php2csv.rb @@ -57,9 +57,9 @@ def test_initialize filenames = %w{"french.php english.php"} headers = %w{"constants french english"} converter = Babelish::Php2CSV.new({ - :csv_filename => csv_filename, - :headers => headers, - :filenames => filenames }) + csv_filename: csv_filename, + headers: headers, + filenames: filenames }) assert_equal csv_filename, converter.csv_filename assert_equal headers, converter.headers diff --git a/test/babelish/test_strings2csv.rb b/test/babelish/test_strings2csv.rb index 1682855..6c2ee4b 100644 --- a/test/babelish/test_strings2csv.rb +++ b/test/babelish/test_strings2csv.rb @@ -105,7 +105,7 @@ def test_load_strings_with_genstrings_file end def test_dotstrings_to_csv - converter = Babelish::Strings2CSV.new(:filenames => ["test/data/test_data.strings"]) + converter = Babelish::Strings2CSV.new(filenames: ["test/data/test_data.strings"]) keys, strings = converter.convert(false) assert_equal ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"], keys @@ -116,7 +116,7 @@ def test_create_csv_file filename = "test_data" strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}} - converter = Babelish::Strings2CSV.new(:headers => %w{variables english}, :filenames => [filename]) + converter = Babelish::Strings2CSV.new(headers: %w{variables english}, filenames: [filename]) converter.send :create_csv_file, keys, strings assert File.exist?(converter.csv_filename) @@ -130,9 +130,9 @@ def test_initialize filenames = %w{french.strings english.strings} headers = %w{constants french english} converter = Babelish::Strings2CSV.new({ - :csv_filename => csv_filename, - :headers => headers, - :filenames => filenames }) + csv_filename: csv_filename, + headers: headers, + filenames: filenames }) assert_equal csv_filename, converter.csv_filename assert_equal headers, converter.headers