babelish 0.6.0 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/lib/babelish.rb +1 -0
  4. data/lib/babelish/google_doc.rb +5 -2
  5. data/lib/babelish/keys.rb +6 -0
  6. data/lib/babelish/version.rb +1 -1
  7. metadata +5 -59
  8. data/.babelish.sample +0 -35
  9. data/.gitignore +0 -31
  10. data/.hound.yml +0 -4
  11. data/.travis.yml +0 -15
  12. data/CONTRIBUTING.md +0 -12
  13. data/Dockerfile +0 -6
  14. data/Gemfile +0 -8
  15. data/Rakefile +0 -17
  16. data/babelish.gemspec +0 -42
  17. data/test/babelish/commands/test_command_android2csv.rb +0 -60
  18. data/test/babelish/commands/test_command_csv2android.rb +0 -50
  19. data/test/babelish/commands/test_command_csv2strings.rb +0 -139
  20. data/test/babelish/commands/test_command_strings2csv.rb +0 -110
  21. data/test/babelish/test_android2csv.rb +0 -53
  22. data/test/babelish/test_base2csv.rb +0 -43
  23. data/test/babelish/test_bins.rb +0 -32
  24. data/test/babelish/test_commandline.rb +0 -127
  25. data/test/babelish/test_csv2android.rb +0 -72
  26. data/test/babelish/test_csv2base.rb +0 -44
  27. data/test/babelish/test_csv2json.rb +0 -27
  28. data/test/babelish/test_csv2php.rb +0 -27
  29. data/test/babelish/test_csv2strings.rb +0 -154
  30. data/test/babelish/test_fastlane.rb +0 -19
  31. data/test/babelish/test_json2csv.rb +0 -34
  32. data/test/babelish/test_php2csv.rb +0 -73
  33. data/test/babelish/test_strings2csv.rb +0 -147
  34. data/test/babelish/test_xcode_macros.rb +0 -112
  35. data/test/data/android-en.xml +0 -9
  36. data/test/data/android-fr.xml +0 -9
  37. data/test/data/android.xml +0 -9
  38. data/test/data/android_special_chars.csv +0 -8
  39. data/test/data/android_special_chars.xml +0 -12
  40. data/test/data/android_special_chars_test_result.xml +0 -10
  41. data/test/data/genstrings.strings +0 -0
  42. data/test/data/json.json +0 -6
  43. data/test/data/php_lang.php +0 -8
  44. data/test/data/test_comments.strings +0 -2
  45. data/test/data/test_data.csv +0 -3
  46. data/test/data/test_data.strings +0 -2
  47. data/test/data/test_data_fr_with_comments.strings +0 -6
  48. data/test/data/test_data_fr_with_comments.xml +0 -9
  49. data/test/data/test_data_multiple_langs.csv +0 -3
  50. data/test/data/test_data_with_comments.csv +0 -3
  51. data/test/data/test_data_with_percent.csv +0 -3
  52. data/test/data/test_data_with_percent_space.csv +0 -4
  53. data/test/data/test_data_with_semicolon.csv +0 -3
  54. data/test/data/test_data_with_spaces.csv +0 -3
  55. data/test/data/test_en.strings +0 -2
  56. data/test/data/test_fr.strings +0 -2
  57. data/test/data/test_space.strings +0 -10
  58. data/test/data/test_utf16.strings +0 -0
  59. data/test/data/test_with_nil.csv +0 -3
  60. data/test/data/test_with_nil.strings +0 -4
  61. data/test/data/xcode_empty.strings +0 -7
  62. data/test/test_helper.rb +0 -17
@@ -1,72 +0,0 @@
1
- require "test_helper"
2
- class TestCSV2Android < Test::Unit::TestCase
3
-
4
- def test_converting_csv_to_xml
5
- csv_file = "test/data/test_data.csv"
6
- converter = Babelish::CSV2Android.new(csv_file, "English" => "en")
7
- converter.convert
8
- assert File.exist?("values-en/strings.xml"), "the ouptut file does not exist"
9
-
10
- # clean up
11
- system("rm -rf ./values-en")
12
- end
13
-
14
- def test_converting_csv_with_special_chars
15
- csv_file = "test/data/android_special_chars.csv"
16
- converter = Babelish::CSV2Android.new(csv_file, "german" => "de")
17
- converter.convert
18
- assert File.exist?("values-de/strings.xml"), "the ouptut file does not exist"
19
- assert_equal File.read("test/data/android_special_chars_test_result.xml"), File.read("values-de/strings.xml")
20
-
21
- # clean up
22
- system("rm -rf ./values-de")
23
- end
24
-
25
- def test_converting_csv_to_dotstrings_one_output_option
26
- csv_file = "test/data/test_data.csv"
27
- single_file = "myApp.xml"
28
- converter = Babelish::CSV2Android.new(
29
- csv_file,
30
- { "English" => "en" },
31
- :output_basename => "myApp",
32
- :ignore_lang_path => true
33
- )
34
- converter.convert
35
- assert File.exist?(single_file), "the ouptut file does not exist"
36
-
37
- # clean up
38
- system("rm -rf ./" + single_file)
39
- end
40
-
41
- def test_converting_with_comments
42
- csv_file = "test/data/test_data_with_comments.csv"
43
- french_file = "values-fr/strings.xml"
44
- expected_output = File.read("test/data/test_data_fr_with_comments.xml")
45
- converter = Babelish::CSV2Android.new(
46
- csv_file,
47
- { "French" => "fr" },
48
- :default_lang => "English",
49
- :comments_column => 5
50
- )
51
- converter.convert
52
- assert File.exist?(french_file), "the ouptut file does not exist"
53
- result = File.read(french_file)
54
- assert_equal expected_output, result
55
-
56
- # clean up
57
- system("rm -rf values-fr")
58
- end
59
-
60
- def test_converting_with_basename
61
- csv_file = "test/data/test_data.csv"
62
- converter = Babelish::CSV2Android.new(csv_file,
63
- { "English" => "en" },
64
- { output_basename: "super_strings" })
65
- converter.convert
66
- exist = File.exist?("values-en/super_strings.xml")
67
- assert exist, "the ouptut file does not exist"
68
-
69
- # clean up
70
- system("rm -rf ./values-en")
71
- end
72
- end
@@ -1,44 +0,0 @@
1
- require 'test_helper'
2
- class TestCsv2Base < Test::Unit::TestCase
3
-
4
- def test_initialize
5
- csv_filename = "file.csv"
6
- excluded_states = ["German"]
7
- state_column = "Local"
8
- keys_column = 23
9
- converter = Babelish::Csv2Base.new(csv_filename, {"English" => ["en"]}, {
10
- :excluded_states => excluded_states,
11
- :state_column => state_column,
12
- :keys_column => keys_column })
13
-
14
- assert_equal csv_filename, converter.csv_filename
15
- assert_equal excluded_states, converter.excluded_states
16
- assert_equal state_column, converter.state_column
17
- assert_equal keys_column, converter.keys_column
18
- end
19
-
20
- def test_initialize_with_default_values
21
- converter = Babelish::Csv2Base.new("file.csv", "English" => ["en"])
22
- assert_not_nil converter.csv_filename
23
- end
24
-
25
- def test_initialize_with_custom_separator
26
- converter = Babelish::Csv2Base.new("file.csv", { "English" => ["en"] }, { :csv_separator => ";" })
27
- assert_not_nil converter.csv_filename
28
- end
29
-
30
- def test_create_file_from_path
31
- test_file = "test_file.txt"
32
- Babelish::Csv2Base.new("file.csv", "English" => ["en"]).create_file_from_path test_file
33
- assert File.exist?(test_file)
34
-
35
- # clean up
36
- system("rm -rf ./" + test_file)
37
- end
38
-
39
- def test_get_row_format
40
- expected_output = "\"test_key\" = \"test_value\""
41
- output = Babelish::Csv2Base.new("file.csv", "English" => ["en"]).get_row_format("test_key", "test_value")
42
- assert_equal expected_output, output
43
- end
44
- end
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
- class TestCSV2JSON < Test::Unit::TestCase
3
-
4
- def test_converting_csv_to_dotstrings
5
- csv_file = "test/data/test_data.csv"
6
- converter = Babelish::CSV2JSON.new(csv_file, 'English' => "en")
7
- converter.convert
8
- assert File.exist?("en.json"), "the ouptut file does not exist"
9
-
10
- # clean up
11
- system("rm -rf en.json")
12
- end
13
-
14
- def test_converting_csv_to_dotstrings_one_output_option
15
- csv_file = "test/data/test_data.csv"
16
- single_file = 'myfile.json'
17
- converter = Babelish::CSV2JSON.new(csv_file,
18
- {'English' => "en"},
19
- :output_basename => 'myfile',
20
- :ignore_lang_path => true)
21
- converter.convert
22
- assert File.exist?(single_file), "the ouptut file does not exist"
23
-
24
- # clean up
25
- system("rm -rf ./" + single_file)
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- require "test_helper"
2
- class TestCSV2Php < Test::Unit::TestCase
3
-
4
- def test_converting_csv_to_dotstrings
5
- csv_file = "test/data/test_data.csv"
6
- converter = Babelish::CSV2Php.new(csv_file, 'English' => "en")
7
- converter.convert
8
- assert File.exist?("en/lang.php"), "the ouptut file does not exist"
9
-
10
- # clean up
11
- system("rm -rf ./en")
12
- end
13
-
14
- def test_converting_csv_to_dotstrings_one_output_option
15
- csv_file = "test/data/test_data.csv"
16
- single_file = 'myApp.php'
17
- converter = Babelish::CSV2Php.new(csv_file,
18
- {'English' => "en"},
19
- :output_basename => 'myApp',
20
- :ignore_lang_path => true)
21
- converter.convert
22
- assert File.exist?(single_file), "the ouptut file does not exist"
23
-
24
- # clean up
25
- system("rm -rf ./" + single_file)
26
- end
27
- end
@@ -1,154 +0,0 @@
1
- require 'test_helper'
2
- class TestCSV2Strings < Test::Unit::TestCase
3
-
4
- def test_converting_csv_to_dotstrings
5
- csv_file = "test/data/test_data.csv"
6
- converter = Babelish::CSV2Strings.new(csv_file, 'English' => [:en])
7
- converter.convert
8
- assert File.exist?("en.lproj/Localizable.strings"), "the ouptut file does not exist"
9
- system("rm -rf en.lproj/")
10
- end
11
-
12
- def test_converting_csv_to_dotstrings_one_output_option
13
- csv_file = "test/data/test_data.csv"
14
- single_file = 'myApp.strings'
15
- converter = Babelish::CSV2Strings.new(csv_file,
16
- {'English' => [:en]},
17
- :output_basename => 'myApp',
18
- :ignore_lang_path => true)
19
- converter.convert
20
- assert File.exist?(single_file), "the ouptut file does not exist"
21
- system("rm -f #{single_file}")
22
- end
23
-
24
- def test_converting_csv_to_dotstrings_default_lang
25
- expected_output = String.new(<<-EOS)
26
- "GREETINGS" = "Buenos dias";
27
- "ANOTHER_STRING" = "testEN";
28
- EOS
29
- csv_file = "test/data/test_data_multiple_langs.csv"
30
- spanish_file = "es.lproj/Localizable.strings"
31
- converter = Babelish::CSV2Strings.new(csv_file,
32
- {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"},
33
- :default_lang => "English")
34
- converter.convert
35
- assert File.exist?(spanish_file), "the ouptut file does not exist"
36
- result = File.read(spanish_file)
37
- assert_equal expected_output, result
38
- system("rm -rf *.lproj")
39
- end
40
-
41
- def test_converting_csv_to_dotstrings_with_no_default_lang_is_empty
42
- expected_output = String.new(<<-EOS)
43
- "GREETINGS" = "Buenos dias";
44
- "ANOTHER_STRING" = "";
45
- EOS
46
- csv_file = "test/data/test_data_multiple_langs.csv"
47
- spanish_file = "es.lproj/Localizable.strings"
48
- converter = Babelish::CSV2Strings.new(csv_file,
49
- {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"})
50
- converter.convert
51
- assert File.exist?(spanish_file), "the ouptut file does not exist"
52
- result = File.read(spanish_file)
53
- assert_equal expected_output, result
54
- system("rm -rf *.lproj")
55
- end
56
-
57
- def test_converting_csv_to_dotstrings_default_lang_to_key
58
- expected_output = String.new(<<-EOS)
59
- "GREETINGS" = "Buenos dias";
60
- "ANOTHER_STRING" = "ANOTHER_STRING";
61
- EOS
62
- csv_file = "test/data/test_data_multiple_langs.csv"
63
- spanish_file = "es.lproj/Localizable.strings"
64
- converter = Babelish::CSV2Strings.new(csv_file,
65
- {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"},
66
- :default_lang => "variables")
67
- converter.convert
68
- assert File.exist?(spanish_file), "the ouptut file does not exist"
69
- result = File.read(spanish_file)
70
- assert_equal expected_output, result
71
- system("rm -rf *.lproj")
72
- end
73
-
74
- def test_converting_csv_to_dotstrings_keys
75
- expected_output = String.new(<<-EOS)
76
- "GREETINGS" = "Buenos dias";
77
- "ANOTHER_STRING" = "ANOTHER_STRING";
78
- EOS
79
- csv_file = "test/data/test_data_multiple_langs.csv"
80
- converter = Babelish::CSV2Strings.new(csv_file,
81
- {'English' => [:en], "French" => "fr", "German" => "de", "Spanish" => "es"},
82
- :default_lang => "variables")
83
- converter.convert
84
- assert !converter.keys.empty?
85
- system("rm -rf *.lproj")
86
- end
87
-
88
- def test_converting_csv_to_dotstrings_with_percent
89
- expected_output = String.new(<<-EOS)
90
- "GREETINGS" = "hello_%@";
91
- "ANOTHER_STRING" = "hello";
92
- EOS
93
- csv_file = "test/data/test_data_with_percent.csv"
94
- converter = Babelish::CSV2Strings.new(csv_file, "English" => [:en])
95
- converter.convert
96
- result = File.read("en.lproj/Localizable.strings")
97
- assert_equal expected_output, result
98
- system("rm -rf *.lproj")
99
- end
100
-
101
- def test_converting_csv_to_dotstrings_with_spaces
102
- expected_output = String.new(<<-EOS)
103
- "GREETINGS " = "hello ";
104
- "ANOTHER_STRING" = " my other string with space at begin";
105
- EOS
106
- csv_file = "test/data/test_data_with_spaces.csv"
107
- converter = Babelish::CSV2Strings.new(csv_file, "English" => [:en])
108
- converter.convert
109
- result = File.read("en.lproj/Localizable.strings")
110
- assert_equal expected_output, result
111
- system("rm -rf *.lproj")
112
- end
113
-
114
- def test_converting_csv_to_dotstrings_with_percent_space
115
- expected_output = String.new(<<-EOS)
116
- "GREETINGS" = "you have %d points";
117
- "ANOTHER_STRING" = "this is a string with 10% of juice";
118
- "ANOTHER_EXAMPLE" = "tu as fait 10% d'efforts";
119
- EOS
120
- csv_file = "test/data/test_data_with_percent_space.csv"
121
- converter = Babelish::CSV2Strings.new(csv_file, "English" => [:en])
122
- converter.convert
123
- result = File.read("en.lproj/Localizable.strings")
124
- assert_equal expected_output, result
125
- system("rm -rf *.lproj")
126
- end
127
-
128
- def test_converting_csv_to_dotstrings_with_stripping_option
129
- expected_output = String.new(<<-EOS)
130
- "GREETINGS" = "hello";
131
- "ANOTHER_STRING" = "my other string with space at begin";
132
- EOS
133
- csv_file = "test/data/test_data_with_spaces.csv"
134
- converter = Babelish::CSV2Strings.new(csv_file, {"English" => [:en]}, :stripping => true)
135
- converter.convert
136
- result = File.read("en.lproj/Localizable.strings")
137
- assert_equal expected_output, result
138
- system("rm -rf *.lproj")
139
- end
140
-
141
- def test_converting_with_comments
142
- csv_file = "test/data/test_data_with_comments.csv"
143
- spanish_file = "fr.lproj/Localizable.strings"
144
- expected_output = File.read("test/data/test_data_fr_with_comments.strings")
145
- converter = Babelish::CSV2Strings.new(csv_file,
146
- {"French" => "fr"},
147
- :default_lang => "English", :comments_column => 5)
148
- converter.convert
149
- assert File.exist?(spanish_file), "the ouptut file does not exist"
150
- result = File.read(spanish_file)
151
- assert_equal expected_output, result
152
- system("rm -rf *.lproj")
153
- end
154
- end
@@ -1,19 +0,0 @@
1
- require "test_helper"
2
- class TestFastlane < Test::Unit::TestCase
3
- def test_current_fastlane_compatibility
4
- system("mkdir tmp_fastlane")
5
- gemfile_content = <<-HEREDOC
6
- source "http://rubygems.org"
7
- gem 'fastlane', '2.126.0'
8
- gem 'babelish', path: '../..'
9
- HEREDOC
10
-
11
- gemfile_fullpath = "tmp_fastlane/Gemfile"
12
- File.write(gemfile_fullpath, gemfile_content, mode: "a")
13
- Dir.chdir("tmp_fastlane") do
14
- successful = system("bundle install")
15
- assert successful == true, "fastlane current version is not compatible"
16
- end
17
- system("rm -rf tmp_fastlane")
18
- end
19
- end
@@ -1,34 +0,0 @@
1
- require 'test_helper'
2
- class JSON2CSVTest < Test::Unit::TestCase
3
-
4
- def test_load_strings_with_wrong_file
5
- assert_raise(Errno::ENOENT) do
6
- output = Babelish::JSON2CSV.new.load_strings "file that does not exist.strings"
7
- end
8
- end
9
-
10
- def test_load_strings
11
- expected_output = {"app_name" => "json2csv", "action_greetings" => "hello", "ANOTHER_STRING" => "testEN", "empty" => ""}
12
- output = Babelish::JSON2CSV.new.load_strings "test/data/json.json"
13
- assert_equal expected_output, output
14
- end
15
-
16
- def test_initialize
17
- csv_filename = "file.csv"
18
- filenames = %w{"french.strings english.strings"}
19
- headers = %w{"constants french english"}
20
- converter = Babelish::JSON2CSV.new({
21
- :csv_filename => csv_filename,
22
- :headers => headers,
23
- :filenames => filenames })
24
-
25
- assert_equal csv_filename, converter.csv_filename
26
- assert_equal headers, converter.headers
27
- assert_equal filenames, converter.filenames
28
- end
29
-
30
- def test_initialize_with_default_values
31
- converter = Babelish::JSON2CSV.new
32
- assert_not_nil converter.csv_filename
33
- end
34
- end
@@ -1,73 +0,0 @@
1
- require 'test_helper'
2
- class TestPhp2CSV < Test::Unit::TestCase
3
-
4
- def test_parse_dotstrings_line_with_good_string
5
- input = String.new(<<-EOS)
6
- $lang['MY_CONSTANT'] = "This is ok";
7
- EOS
8
- expected_output = {"MY_CONSTANT" => "This is ok"}
9
-
10
- output = Babelish::Php2CSV.new.parse_dotstrings_line input
11
- assert_equal output, expected_output
12
- end
13
-
14
- def test_parse_dotstrings_line_with_single_quote
15
- input = String.new(<<-EOS)
16
- $lang['MY_CONSTANT'] = "This 'is' ok";
17
- EOS
18
- expected_output = {"MY_CONSTANT" => "This 'is' ok"}
19
-
20
- output = Babelish::Php2CSV.new.parse_dotstrings_line input
21
- assert_equal output, expected_output
22
- end
23
-
24
- def test_parse_dotstrings_line_with_double_quotes
25
- input = String.new(<<-EOS)
26
- $lang['MY_CONSTANT'] = "This "is" ok";
27
- EOS
28
- expected_output = {"MY_CONSTANT" => "This \"is\" ok"}
29
-
30
- output = Babelish::Php2CSV.new.parse_dotstrings_line input
31
- assert_equal output, expected_output
32
- end
33
-
34
- def test_parse_dotstrings_line_with_wrong_string
35
- input = String.new(<<-EOS)
36
- $lang['MY_CONSTANT'] = "wrong syntax"
37
- EOS
38
-
39
- output = Babelish::Php2CSV.new.parse_dotstrings_line input
40
- assert_nil output, "output should be nil with wrong syntax"
41
- end
42
-
43
- def test_load_strings_with_wrong_file
44
- assert_raise(Errno::ENOENT) do
45
- output = Babelish::Php2CSV.new.load_strings "file that does not exist.strings"
46
- end
47
- end
48
-
49
- def test_load_strings
50
- expected_output = {"app_name" => "php2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""}
51
- output = Babelish::Php2CSV.new.load_strings "test/data/php_lang.php"
52
- assert_equal expected_output, output
53
- end
54
-
55
- def test_initialize
56
- csv_filename = "file.csv"
57
- filenames = %w{"french.php english.php"}
58
- headers = %w{"constants french english"}
59
- converter = Babelish::Php2CSV.new({
60
- :csv_filename => csv_filename,
61
- :headers => headers,
62
- :filenames => filenames })
63
-
64
- assert_equal csv_filename, converter.csv_filename
65
- assert_equal headers, converter.headers
66
- assert_equal filenames, converter.filenames
67
- end
68
-
69
- def test_initialize_with_default_values
70
- converter = Babelish::Php2CSV.new
71
- assert_not_nil converter.csv_filename
72
- end
73
- end