babelish 0.5.6 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -3
  3. data/lib/babelish.rb +1 -0
  4. data/lib/babelish/csv2android.rb +2 -1
  5. data/lib/babelish/google_doc.rb +8 -4
  6. data/lib/babelish/keys.rb +6 -0
  7. data/lib/babelish/version.rb +1 -1
  8. metadata +10 -65
  9. data/.babelish.sample +0 -35
  10. data/.gitignore +0 -31
  11. data/.hound.yml +0 -4
  12. data/.travis.yml +0 -15
  13. data/CONTRIBUTING.md +0 -12
  14. data/Dockerfile +0 -6
  15. data/Gemfile +0 -8
  16. data/Rakefile +0 -17
  17. data/babelish.gemspec +0 -42
  18. data/test/babelish/commands/test_command_android2csv.rb +0 -60
  19. data/test/babelish/commands/test_command_csv2android.rb +0 -35
  20. data/test/babelish/commands/test_command_csv2strings.rb +0 -139
  21. data/test/babelish/commands/test_command_strings2csv.rb +0 -110
  22. data/test/babelish/test_android2csv.rb +0 -53
  23. data/test/babelish/test_base2csv.rb +0 -43
  24. data/test/babelish/test_bins.rb +0 -32
  25. data/test/babelish/test_commandline.rb +0 -127
  26. data/test/babelish/test_csv2android.rb +0 -72
  27. data/test/babelish/test_csv2base.rb +0 -44
  28. data/test/babelish/test_csv2json.rb +0 -27
  29. data/test/babelish/test_csv2php.rb +0 -27
  30. data/test/babelish/test_csv2strings.rb +0 -154
  31. data/test/babelish/test_fastlane.rb +0 -19
  32. data/test/babelish/test_json2csv.rb +0 -34
  33. data/test/babelish/test_php2csv.rb +0 -73
  34. data/test/babelish/test_strings2csv.rb +0 -147
  35. data/test/babelish/test_xcode_macros.rb +0 -112
  36. data/test/data/android-en.xml +0 -9
  37. data/test/data/android-fr.xml +0 -9
  38. data/test/data/android.xml +0 -9
  39. data/test/data/android_special_chars.csv +0 -8
  40. data/test/data/android_special_chars.xml +0 -12
  41. data/test/data/android_special_chars_test_result.xml +0 -10
  42. data/test/data/genstrings.strings +0 -0
  43. data/test/data/json.json +0 -6
  44. data/test/data/php_lang.php +0 -8
  45. data/test/data/test_comments.strings +0 -2
  46. data/test/data/test_data.csv +0 -3
  47. data/test/data/test_data.strings +0 -2
  48. data/test/data/test_data_fr_with_comments.strings +0 -6
  49. data/test/data/test_data_fr_with_comments.xml +0 -9
  50. data/test/data/test_data_multiple_langs.csv +0 -3
  51. data/test/data/test_data_with_comments.csv +0 -3
  52. data/test/data/test_data_with_percent.csv +0 -3
  53. data/test/data/test_data_with_percent_space.csv +0 -4
  54. data/test/data/test_data_with_semicolon.csv +0 -3
  55. data/test/data/test_data_with_spaces.csv +0 -3
  56. data/test/data/test_en.strings +0 -2
  57. data/test/data/test_fr.strings +0 -2
  58. data/test/data/test_space.strings +0 -10
  59. data/test/data/test_utf16.strings +0 -0
  60. data/test/data/test_with_nil.csv +0 -3
  61. data/test/data/test_with_nil.strings +0 -4
  62. data/test/data/xcode_empty.strings +0 -7
  63. data/test/test_helper.rb +0 -17
@@ -1,35 +0,0 @@
1
- require 'test_helper'
2
- class TestCSV2AndroidCommand < Test::Unit::TestCase
3
-
4
- def test_csv2android_with_multiple_2_languages
5
- options = {
6
- :filename => "test/data/test_data_multiple_langs.csv",
7
- :langs => {"English" => "en", "French" => "fr"}
8
- }
9
- Commandline.new([], options).csv2android
10
-
11
- assert File.exist?("./values-en/strings.xml")
12
- assert File.exist?("./values-fr/strings.xml")
13
-
14
- # clean up
15
- system("rm -rf ./values-en/")
16
- system("rm -rf ./values-fr/")
17
- end
18
-
19
- def test_csv2android_with_output_dir
20
- options = {
21
- :filename => "test/data/test_data_multiple_langs.csv",
22
- :langs => {"English" => "en", "French" => "fr"},
23
- :output_dir => "mynewlocation"
24
- }
25
-
26
- Commandline.new([], options).csv2android
27
- # testing
28
- assert File.exist?("./mynewlocation/values-en/strings.xml"), "can't find output file for English"
29
- assert File.exist?("./mynewlocation/values-fr/strings.xml"), "can't find output file for French"
30
-
31
- # clean up
32
- system("rm -rf ./mynewlocation")
33
- end
34
-
35
- end
@@ -1,139 +0,0 @@
1
- require 'test_helper'
2
- class TestCSV2StringsCommand < Test::Unit::TestCase
3
-
4
- def test_csv2strings_with_multiple_2_languages
5
- options = {
6
- :filename => "test/data/test_data_multiple_langs.csv",
7
- :langs => {"English" => "en", "French" => "fr"}
8
- }
9
- Commandline.new([], options).csv2strings
10
-
11
- assert File.exist?("./en.lproj/Localizable.strings")
12
- assert File.exist?("./fr.lproj/Localizable.strings")
13
-
14
- # clean up
15
- system("rm -rf ./en.lproj/")
16
- system("rm -rf ./fr.lproj/")
17
- end
18
-
19
- def test_csv2strings_with_output_dir
20
- options = {
21
- :filename => "test/data/test_data_multiple_langs.csv",
22
- :langs => {"English" => "en", "French" => "fr"},
23
- :output_dir => "mynewlocation"
24
- }
25
- Commandline.new([], options).csv2strings
26
-
27
- # testing
28
- assert File.exist?("./mynewlocation/en.lproj/Localizable.strings"), "can't find output file for English in mynewlocation folder"
29
- assert File.exist?("./mynewlocation/fr.lproj/Localizable.strings"), "can't find output file for French in mynewlocation folder"
30
-
31
- # clean up
32
- system("rm -rf ./mynewlocation")
33
- end
34
-
35
- def test_csv2strings_with_fetch_google_doc
36
- omit if ENV['TRAVIS']
37
- options = {
38
- :filename => "my_strings",
39
- :langs => {"English" => "en", "French" => "fr"},
40
- :fetch => true
41
- }
42
- assert_nothing_raised do
43
- Commandline.new([], options).csv2strings
44
- end
45
-
46
- # clean up
47
- system("rm -rf ./en.lproj/")
48
- system("rm -rf ./fr.lproj/")
49
- end
50
-
51
- def test_csv2strings_with_config_file
52
- system("cp .babelish.sample .babelish")
53
-
54
- assert_nothing_raised do
55
- Commandline.new.csv2strings
56
- end
57
-
58
- # clean up
59
- system("rm -rf ./en.lproj/")
60
- system("rm -rf ./fr.lproj/")
61
- end
62
-
63
- def test_csv2strings_with_output_basenames_option
64
- omit if ENV['TRAVIS']
65
- options = {
66
- :filename => "my_strings",
67
- :langs => {"English" => "en", "French" => "fr"},
68
- :fetch => true,
69
- :output_basenames => %w(sheet1 sheet2),
70
- }
71
-
72
- Commandline.new([], options).csv2strings
73
- # testing
74
- assert File.exist?("./en.lproj/sheet1.strings"), "can't find output file for sheet1 English"
75
- assert File.exist?("./fr.lproj/sheet1.strings"), "can't find output file for sheet1 French"
76
- assert File.exist?("./en.lproj/sheet2.strings"), "can't find output file for sheet2 English"
77
- assert File.exist?("./fr.lproj/sheet2.strings"), "can't find output file for sheet2 French"
78
-
79
- # clean up
80
- system("rm -rf ./en.lproj/")
81
- system("rm -rf ./fr.lproj/")
82
- end
83
-
84
- def test_csv2strings_with_ignore_lang_path_option
85
- omit if ENV['TRAVIS']
86
- options = {
87
- :filename => "my_strings",
88
- :langs => {"English" => "en"},
89
- :fetch => true,
90
- :ignore_lang_path => true,
91
- :output_basenames => %w(sheet1 sheet2),
92
- }
93
-
94
- Commandline.new([], options).csv2strings
95
- # testing
96
- assert File.exist?("./sheet1.strings"), "can't find output file for sheet1 English with_ignore_lang_path_option"
97
- assert File.exist?("./sheet2.strings"), "can't find output file for sheet2 English with_ignore_lang_path_option"
98
-
99
- # clean up
100
- system("rm -f sheet1.strings")
101
- system("rm -f sheet2.strings")
102
- end
103
-
104
- def test_csv2strings_with_ignore_lang_path_option_local
105
- options = {
106
- :filename => "test/data/test_data.csv",
107
- :langs => {"English" => "en"},
108
- :ignore_lang_path => true,
109
- }
110
-
111
- Commandline.new([], options).csv2strings
112
- # testing
113
- assert File.exist?("./Localizable.strings"), "can't find output file for English with_ignore_lang_path_option"
114
-
115
- # clean up
116
- system("rm -f ./Localizable.strings")
117
- end
118
-
119
- def test_csv2string_with_macros_filename
120
- options = {
121
- :filename => "test/data/test_data.csv",
122
- :macros_filename => "Babelish.h",
123
- :langs => { "English" => "en" }
124
- }
125
-
126
- Commandline.new([], options).csv2strings
127
- # testing
128
- assert File.exist?("./Babelish.h"), "can't find macros file"
129
-
130
- # clean up
131
- system("rm -f ./Localizable.strings")
132
- system("rm -f ./Babelish.h")
133
- end
134
-
135
- def teardown
136
-
137
- system("rm -f .babelish")
138
- end
139
- end
@@ -1,110 +0,0 @@
1
- require 'test_helper'
2
- class TestStrings2CSVCommand < Test::Unit::TestCase
3
-
4
- def test_strings2csv
5
- options = {:filenames => ["test/data/test_data.strings"]}
6
- Commandline.new([], options).strings2csv
7
-
8
- assert File.exist?("translations.csv")
9
-
10
- # clean up
11
- system("rm -f translations.csv")
12
- end
13
-
14
- def test_strings2csv_with_dryrun_option
15
- options = {:filenames => ["test/data/test_data.strings"], :dryrun => true}
16
- Commandline.new([], options).strings2csv
17
-
18
- assert !File.exist?("translations.csv")
19
-
20
- # clean up
21
- system("rm -f translations.csv")
22
- end
23
-
24
- def test_strings2csv_with_output_file
25
- options = {:filenames => ["test/data/test_data.strings"], :csv_filename => "myfile.csv"}
26
- # -i, -o
27
- Commandline.new([], options).strings2csv
28
-
29
- assert File.exist?("myfile.csv")
30
-
31
- # clean up
32
- system("rm -f myfile.csv")
33
- end
34
-
35
- def test_strings2csv_with_headers
36
- options = {:filenames => ["test/data/test_data.strings"], :headers => ["constants", "english"]}
37
- # -i, -h
38
- Commandline.new([], options).strings2csv
39
-
40
- #TODO assertion or move test on at lib level
41
-
42
- # clean up
43
- system("rm -f translations.csv")
44
- end
45
-
46
- def test_strings2csv_with_two_files
47
- options = {
48
- :filenames => ["test/data/test_en.strings", "test/data/test_fr.strings"],
49
- :headers => %w{Constants English French},
50
- :csv_filename => "enfr.csv"
51
- }
52
- # --filenames, --headers, -o
53
- Commandline.new([], options).strings2csv
54
-
55
- #TODO assertion
56
-
57
- # clean up
58
- system("rm -f enfr.csv")
59
- end
60
-
61
- def test_strings2csv_with_empty_lines
62
- options = {
63
- :filenames => ["test/data/test_with_nil.strings"],
64
- :csv_filename => "test_with_nil.csv"
65
- }
66
- # -i, -o
67
-
68
-
69
- assert_nothing_raised do
70
- Commandline.new([], options).strings2csv
71
- end
72
- assert system("diff test_with_nil.csv test/data/test_with_nil.csv"), "no difference on output"
73
-
74
- # clean up
75
- system("rm -f test_with_nil.csv")
76
- end
77
-
78
- def test_strings2csv_utf16
79
- options = {
80
- :filenames => ["test/data/test_utf16.strings"],
81
- :csv_filename => "test_utf16.csv"
82
- }
83
- # -i, -o
84
-
85
-
86
- assert_nothing_raised do
87
- Commandline.new([], options).strings2csv
88
- end
89
-
90
- # clean up
91
- system("rm -f test_utf16.csv")
92
-
93
- end
94
-
95
- def test_strings2csv_with_comments_outputs_right_headers
96
- expected_content = <<-EOF
97
- Variables,test/data/test_comments.strings,Comments
98
- MY_CONSTANT,This 'is' ok,this is a comment
99
- EOF
100
-
101
- options = { :filenames => ["test/data/test_comments.strings"] }
102
- Commandline.new([], options).strings2csv
103
-
104
- csv_content = `cat translations.csv`
105
-
106
- assert_equal expected_content, csv_content, "Content of generated file differs from expected one"
107
- # clean up
108
- system("rm -f translations.csv")
109
- end
110
- end
@@ -1,53 +0,0 @@
1
- require 'test_helper'
2
- class TestAndroid2CSV < Test::Unit::TestCase
3
-
4
- def test_load_strings_with_wrong_file
5
- assert_raise(Errno::ENOENT) do
6
- output = Babelish::Android2CSV.new.load_strings "file that does not exist.strings"
7
- end
8
- end
9
-
10
- def test_load_strings
11
- expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""}, {}]
12
- output = Babelish::Android2CSV.new.load_strings "test/data/android.xml"
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::Android2CSV.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::Android2CSV.new
32
- assert_not_nil converter.csv_filename
33
- end
34
-
35
- def test_special_chars
36
- csv_filename = "./android_special_chars_output.csv"
37
- filenames = "test/data/android_special_chars.xml"
38
- headers = %w{variables german}
39
-
40
- converter = Babelish::Android2CSV.new(
41
- :csv_filename => csv_filename,
42
- :headers => headers,
43
- :filenames => [filenames])
44
-
45
- converter.convert
46
-
47
- assert File.exist?(converter.csv_filename)
48
- assert_equal File.read("test/data/android_special_chars.csv"), File.read(csv_filename)
49
-
50
- # clean up
51
- system("rm -rf ./" + csv_filename)
52
- end
53
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
- class TestBase2Csv < Test::Unit::TestCase
3
-
4
- def test_load_strings
5
- expected_output = [{}, {}]
6
- output = Babelish::Base2Csv.new.send :load_strings, nil
7
- assert_equal expected_output, output
8
- end
9
-
10
- def test_create_csv_file
11
- keys = ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"]
12
- filename = "test_data"
13
- strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
14
-
15
- converter = Babelish::Base2Csv.new(:headers => %w{variables english}, :filenames => [filename])
16
-
17
- converter.send :create_csv_file, keys, strings
18
- assert File.exist?(converter.csv_filename)
19
-
20
- # clean up
21
- system("rm -rf ./" + converter.csv_filename)
22
- end
23
-
24
- def test_initialize
25
- csv_filename = "file.csv"
26
- filenames = %w{"french.strings english.strings"}
27
- headers = %w{"constants french english"}
28
- converter = Babelish::Base2Csv.new({
29
- :csv_filename => csv_filename,
30
- :headers => headers,
31
- :filenames => filenames
32
- })
33
-
34
- assert_equal csv_filename, converter.csv_filename
35
- assert_equal headers, converter.headers
36
- assert_equal filenames, converter.filenames
37
- end
38
-
39
- def test_initialize_with_default_values
40
- converter = Babelish::Base2Csv.new
41
- assert_not_nil converter.csv_filename
42
- end
43
- end
@@ -1,32 +0,0 @@
1
- require 'test_helper'
2
- class TestBins < Test::Unit::TestCase
3
-
4
- def test_csv2strings_with_google_doc
5
- omit if ENV['TRAVIS']
6
- assert_nothing_raised do
7
- system("./bin/babelish csv2strings --fetch --filename my_strings --langs English:en")
8
- end
9
- assert_equal 0, $?.exitstatus
10
- end
11
-
12
- def test_csv2strings_with_google_doc_missing_langs
13
- omit if ENV['TRAVIS']
14
- assert_nothing_raised do
15
- system("./bin/babelish csv2strings --fetch --filename my_strings")
16
- end
17
- assert_equal 1, $?.exitstatus
18
- end
19
-
20
- def test_csv2strings_with_config_file
21
- system("cp .babelish.sample .babelish")
22
-
23
- assert_nothing_raised NameError do
24
- system("./bin/babelish csv2strings")
25
- end
26
- assert_equal 0, $?.exitstatus
27
- end
28
-
29
- def teardown
30
- system("rm -f .babelish")
31
- end
32
- end
@@ -1,127 +0,0 @@
1
- require 'test_helper'
2
- class TestCommandLine < Test::Unit::TestCase
3
-
4
- def test_init
5
- assert_nothing_raised do
6
- Commandline.new.init
7
- end
8
- # clean up
9
- system("rm -f .babelish")
10
- end
11
-
12
- def test_csv2base_with_config_file_all_required_options
13
- options = {
14
- :filename => "test/data/test_data_multiple_langs.csv",
15
- :langs => {"English" => "en", "French" => "fr"}
16
- }
17
- config_file = File.new(".babelish", "w")
18
- config_file.write options.to_yaml
19
- config_file.close
20
-
21
- assert_nothing_raised do
22
- Commandline.new.csv2strings
23
- end
24
-
25
- # clean up
26
- system("rm -rf ./en.lproj/")
27
- system("rm -rf ./fr.lproj/")
28
- system("rm -f .babelish")
29
- end
30
-
31
-
32
- def test_csv2base_without_filename_fails
33
- options = {
34
- :langs => {"English" => "en", "French" => "fr"}
35
- }
36
- config_file = File.new(".babelish", "w")
37
- config_file.write options.to_yaml
38
- config_file.close
39
-
40
- assert_raises do
41
- Commandline.new.csv2strings
42
- end
43
-
44
- # clean up
45
- system("rm -rf ./en.lproj/")
46
- system("rm -rf ./fr.lproj/")
47
- system("rm -f .babelish")
48
- end
49
-
50
- def test_base2csv_with_config_file_all_required_options
51
- options = {
52
- :filenames => ["test/data/test_en.strings", "test/data/test_fr.strings"],
53
- }
54
- config_file = File.new(".babelish", "w")
55
- config_file.write options.to_yaml
56
- config_file.close
57
-
58
- assert_nothing_raised do
59
- Commandline.new.strings2csv
60
- end
61
-
62
- # clean up
63
- system("rm -f translations.csv")
64
- system("rm -f .babelish")
65
- end
66
-
67
- def test_base2csv_with_config_without_filenames_fails
68
- options = {}
69
- config_file = File.new(".babelish", "w")
70
- config_file.write options.to_yaml
71
- config_file.close
72
-
73
- assert_raises do
74
- Commandline.new.strings2csv
75
- end
76
-
77
- # clean up
78
- system("rm -f .babelish")
79
- end
80
-
81
- def test_base2csv_with_config_with_non_existent_filenames_fails
82
- options = {:filenames => ['foo']}
83
- config_file = File.new(".babelish", "w")
84
- config_file.write options.to_yaml
85
- config_file.close
86
-
87
- _, stderr = capture_output do
88
- Commandline.new.strings2csv
89
- end
90
- assert_match(/No such file or directory/, stderr)
91
- assert_match(/foo/, stderr)
92
-
93
- # clean up
94
- system("rm -f .babelish")
95
- end
96
-
97
- def test_csv_download_without_gd_filename_fails
98
- options = {}
99
- config_file = File.new(".babelish", "w")
100
- config_file.write options.to_yaml
101
- config_file.close
102
-
103
- assert_raises do
104
- Commandline.new.csv_download
105
- end
106
-
107
- # clean up
108
- system("rm -f .babelish")
109
- end
110
-
111
-
112
- def test_csv_download_with_required_params
113
- omit if ENV['TRAVIS']
114
- options = {:gd_filename => "my_strings"}
115
- config_file = File.new(".babelish", "w")
116
- config_file.write options.to_yaml
117
- config_file.close
118
-
119
- assert_nothing_raised do
120
- Commandline.new.csv_download
121
- end
122
-
123
- # clean up
124
- system("rm -f .babelish")
125
- end
126
-
127
- end