babelish 0.5.5 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) 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 +6 -60
  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_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,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
@@ -1,147 +0,0 @@
1
- require 'test_helper'
2
- class TestStrings2CSV < Test::Unit::TestCase
3
-
4
- def test_parse_dotstrings_line_with_good_string
5
- input = String.new(<<-EOS)
6
- "MY_CONSTANT" = "This is ok";
7
- EOS
8
- expected_output = ["MY_CONSTANT","This is ok"]
9
-
10
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
11
- assert_equal expected_output, output
12
- end
13
-
14
- def test_parse_dotstrings_line_with_single_quote
15
- input = String.new(<<-EOS)
16
- "MY_CONSTANT" = "This 'is' ok";
17
- EOS
18
- expected_output = ["MY_CONSTANT","This 'is' ok"]
19
-
20
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
21
- assert_equal expected_output, output
22
- end
23
-
24
- def test_parse_dotstrings_line_with_double_quotes
25
- input = String.new(<<-EOS)
26
- "MY_CONSTANT" = "This "is" ok";
27
- EOS
28
- expected_output = ["MY_CONSTANT","This \"is\" ok"]
29
-
30
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
31
- assert_equal expected_output, output
32
- end
33
-
34
- def test_parse_dotstrings_line_with_wrong_string
35
- input = String.new(<<-EOS)
36
- "MY_CONSTANT" = "wrong syntax"
37
- EOS
38
-
39
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
40
- assert_nil output, "output should be nil with wrong syntax"
41
- end
42
-
43
- def test_parse_dotstrings_line_with_comment
44
- input = String.new(<<-EOS)
45
- /* Class = "IBUIButton"; normalTitle = "Wibble"; ObjectID = "xxx-xx-123"; */
46
- EOS
47
-
48
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
49
- assert_nil output, "output should be nil with comment"
50
- end
51
-
52
- def test_parse_comment
53
- comment= "/* this is a comment */"
54
- output = Babelish::Strings2CSV.new.parse_comment_line comment
55
- assert_equal "this is a comment", output
56
- end
57
-
58
- def test_load_strings_with_wrong_file
59
- assert_raise(Errno::ENOENT) do
60
- output = Babelish::Strings2CSV.new.load_strings "file that does not exist.strings"
61
- end
62
- end
63
-
64
- def test_load_strings
65
- expected_output = [{"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}, {}]
66
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_data.strings"
67
- assert_equal expected_output, output
68
- end
69
-
70
- def test_load_strings_with_spaces
71
- expected_output = [{ "name" => "definition",
72
- "name1" => "definition1",
73
- "name2" => "definition2",
74
- "name3" => "definition3",
75
- "name4" => "definition4",
76
- "this is a name" => "a definition"
77
- }, {}]
78
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_space.strings"
79
- assert_equal expected_output, output
80
- end
81
-
82
- def test_load_strings_with_comments
83
- expected_output = [{"MY_CONSTANT"=>"This 'is' ok"}, {"MY_CONSTANT"=> "this is a comment"}]
84
-
85
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_comments.strings"
86
- assert_equal expected_output, output
87
- end
88
-
89
- def test_load_strings_with_empty_lines
90
- assert_nothing_raised do
91
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_with_nil.strings"
92
- end
93
- end
94
-
95
- def test_load_strings_with_empty_lines_and_comments
96
- assert_nothing_raised do
97
- output = Babelish::Strings2CSV.new.load_strings "test/data/xcode_empty.strings"
98
- end
99
- end
100
-
101
- def test_load_strings_with_genstrings_file
102
- assert_nothing_raised do
103
- output = Babelish::Strings2CSV.new.load_strings "test/data/genstrings.strings"
104
- end
105
- end
106
-
107
- def test_dotstrings_to_csv
108
- converter = Babelish::Strings2CSV.new(:filenames => ["test/data/test_data.strings"])
109
- keys, strings = converter.convert(false)
110
- assert_equal ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"], keys
111
-
112
- end
113
-
114
- def test_create_csv_file
115
- keys = ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"]
116
- filename = "test_data"
117
- strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
118
-
119
- converter = Babelish::Strings2CSV.new(:headers => %w{variables english}, :filenames => [filename])
120
-
121
- converter.send :create_csv_file, keys, strings
122
- assert File.exist?(converter.csv_filename)
123
-
124
- # clean up
125
- system("rm -rf ./" + converter.csv_filename)
126
- end
127
-
128
- def test_initialize
129
- csv_filename = "file.csv"
130
- filenames = %w{french.strings english.strings}
131
- headers = %w{constants french english}
132
- converter = Babelish::Strings2CSV.new({
133
- :csv_filename => csv_filename,
134
- :headers => headers,
135
- :filenames => filenames })
136
-
137
- assert_equal csv_filename, converter.csv_filename
138
- assert_equal headers, converter.headers
139
- assert_equal filenames, converter.filenames
140
- end
141
-
142
- def test_initialize_with_default_values
143
- converter = Babelish::Strings2CSV.new
144
- assert_not_nil converter.csv_filename
145
- end
146
-
147
- end