csv2strings 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+ class TestCommand < 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
+ CSV2StringsCommand.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_default_path
20
+ options = {
21
+ :filename => "test/data/test_data_multiple_langs.csv",
22
+ :langs => {"English" => "en", "French" => "fr"},
23
+ :default_path => "mynewlocation"
24
+ }
25
+ CSV2StringsCommand.new([], options).csv2strings
26
+
27
+ # testing
28
+ assert File.exist?("./mynewlocation/en.lproj/Localizable.strings"), "can't find output file for English"
29
+ assert File.exist?("./mynewlocation/fr.lproj/Localizable.strings"), "can't find output file for French"
30
+
31
+ #clean up
32
+ system("rm -rf ./mynewlocation")
33
+ end
34
+
35
+ end
36
+
@@ -0,0 +1,77 @@
1
+ require 'test_helper'
2
+ class TestCommand < Test::Unit::TestCase
3
+
4
+ def test_strings2csv
5
+ options = {:filenames => ["test/data/test_data.strings"]}
6
+ Strings2CSVCommand.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
+ Strings2CSVCommand.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
+ Strings2CSVCommand.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
+ Strings2CSVCommand.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
+ Strings2CSVCommand.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
+ Strings2CSVCommand.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
+ end
@@ -1,11 +1,9 @@
1
- require File.expand_path('../../../lib/csv2strings/converter', __FILE__)
2
- require File.expand_path('../../test_helper', __FILE__)
1
+ require 'test_helper'
2
+ class TestCSV2Strings < Test::Unit::TestCase
3
3
 
4
- class CSV2Strings::ConverterTest < Test::Unit::TestCase
5
-
6
4
  def test_converting_csv_to_dotstrings
7
5
  csv_file = "test/data/test_data.csv"
8
- converter = CSV2Strings::Converter.new(csv_file, 'English' => [:en])
6
+ converter = CSV2Strings.new(csv_file, 'English' => [:en])
9
7
  converter.csv_to_dotstrings
10
8
  assert File.exists?("en.lproj/Localizable.strings"), "the ouptut file does not exist"
11
9
  end
@@ -13,10 +11,10 @@ class CSV2Strings::ConverterTest < Test::Unit::TestCase
13
11
  def test_converting_csv_to_dotstrings_one_output_option
14
12
  csv_file = "test/data/test_data.csv"
15
13
  single_file = 'myApp.strings'
16
- converter = CSV2Strings::Converter.new(csv_file,
14
+ converter = CSV2Strings.new(csv_file,
17
15
  {'English' => [:en]},
18
16
  :output_file => single_file)
19
17
  converter.csv_to_dotstrings
20
18
  assert File.exists?(single_file), "the ouptut file does not exist"
21
19
  end
22
- end
20
+ end
@@ -1,15 +1,13 @@
1
- require File.expand_path('../../../lib/strings2csv/converter', __FILE__)
2
- require File.expand_path('../../test_helper', __FILE__)
1
+ require 'test_helper'
2
+ class TestStrings2CSV < Test::Unit::TestCase
3
3
 
4
- class Strings2CSV::ConverterTest < Test::Unit::TestCase
5
-
6
4
  def test_parse_dotstrings_line_with_good_string
7
5
  input = String.new(<<-EOS)
8
6
  "MY_CONSTANT" = "This is ok";
9
7
  EOS
10
8
  expected_output = {"MY_CONSTANT"=>"This is ok"}
11
9
 
12
- output = Strings2CSV::Converter.new.parse_dotstrings_line input
10
+ output = Strings2CSV.new.parse_dotstrings_line input
13
11
  assert_equal output, expected_output
14
12
  end
15
13
 
@@ -19,7 +17,7 @@ class Strings2CSV::ConverterTest < Test::Unit::TestCase
19
17
  EOS
20
18
  expected_output = {"MY_CONSTANT"=>"This 'is' ok"}
21
19
 
22
- output = Strings2CSV::Converter.new.parse_dotstrings_line input
20
+ output = Strings2CSV.new.parse_dotstrings_line input
23
21
  assert_equal output, expected_output
24
22
  end
25
23
 
@@ -29,7 +27,7 @@ class Strings2CSV::ConverterTest < Test::Unit::TestCase
29
27
  EOS
30
28
  expected_output = {"MY_CONSTANT"=>"This \"is\" ok"}
31
29
 
32
- output = Strings2CSV::Converter.new.parse_dotstrings_line input
30
+ output = Strings2CSV.new.parse_dotstrings_line input
33
31
  assert_equal output, expected_output
34
32
  end
35
33
 
@@ -38,39 +36,44 @@ class Strings2CSV::ConverterTest < Test::Unit::TestCase
38
36
  "MY_CONSTANT" = "wrong syntax"
39
37
  EOS
40
38
 
41
- output = Strings2CSV::Converter.new.parse_dotstrings_line input
39
+ output = Strings2CSV.new.parse_dotstrings_line input
42
40
  assert_nil output, "output should be nil with wrong syntax"
43
41
  end
44
42
 
45
43
  def test_load_strings_with_wrong_file
46
44
  assert_raise(Errno::ENOENT) do
47
- output = Strings2CSV::Converter.new.load_strings "file that does not exist.strings"
45
+ output = Strings2CSV.new.load_strings "file that does not exist.strings"
48
46
  end
49
47
  end
50
48
 
51
49
  def test_load_strings
52
50
  expected_output = {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}
53
- output = Strings2CSV::Converter.new.load_strings "test/data/test_data.strings"
51
+ output = Strings2CSV.new.load_strings "test/data/test_data.strings"
54
52
  assert_equal expected_output, output
55
53
  end
56
54
 
55
+ def test_load_strings_with_empty_lines
56
+ assert_nothing_raised do
57
+ output = Strings2CSV.new.load_strings "test/data/test_with_nil.strings"
58
+ end
59
+ end
60
+
57
61
  def test_dotstrings_to_csv
58
- converter = Strings2CSV::Converter.new(:filenames => ["test/data/test_data.strings"])
59
- keys, lang_order, strings = converter.dotstrings_to_csv(false)
60
- assert_equal ["test_data".to_sym], lang_order
62
+ converter = Strings2CSV.new(:filenames => ["test/data/test_data.strings"])
63
+ keys, strings = converter.dotstrings_to_csv(false)
61
64
  assert_equal ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"], keys
62
- expected_strings = {lang_order[0] => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
65
+ expected_strings = {"test/data/test_data.strings" => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
63
66
  assert_equal expected_strings, strings
64
67
  end
65
68
 
66
69
  def test_create_csv_file
67
70
  keys = ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"]
68
- lang_order = [:"test_data"]
69
- strings = {lang_order[0] => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
70
-
71
- converter = Strings2CSV::Converter.new(:headers => %w{variables english})
71
+ filename = "test_data"
72
+ strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
72
73
 
73
- converter.create_csv_file(keys, lang_order, strings)
74
+ converter = Strings2CSV.new(:headers => %w{variables english}, :filenames => [filename])
75
+
76
+ converter.create_csv_file(keys, strings)
74
77
  assert File.exist?(converter.csv_filename)
75
78
  end
76
79
 
@@ -78,7 +81,7 @@ class Strings2CSV::ConverterTest < Test::Unit::TestCase
78
81
  csv_filename = "file.csv"
79
82
  filenames = %w{"french.strings english.strings"}
80
83
  headers = %w{"constants french english"}
81
- converter = Strings2CSV::Converter.new({
84
+ converter = Strings2CSV.new({
82
85
  :csv_filename => csv_filename,
83
86
  :headers => headers,
84
87
  :filenames => filenames
@@ -90,7 +93,8 @@ class Strings2CSV::ConverterTest < Test::Unit::TestCase
90
93
  end
91
94
 
92
95
  def test_initialize_with_default_values
93
- converter = Strings2CSV::Converter.new
96
+ converter = Strings2CSV.new
94
97
  assert_not_nil converter.csv_filename
95
98
  end
96
- end
99
+
100
+ end
@@ -0,0 +1,3 @@
1
+ Variables,test/data/test_with_nil.strings
2
+ GREETINGS,Hello
3
+ ANOTHER_STRING,testEN
@@ -0,0 +1,4 @@
1
+ "GREETINGS" = "Hello";
2
+
3
+ "ANOTHER_STRING" = "testEN";
4
+
data/test/test_helper.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  begin
2
2
  require 'simplecov'
3
- SimpleCov.start do
4
- add_filter "test"
3
+ require 'coveralls'
4
+
5
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
6
+ SimpleCov.start do
7
+ add_filter '/test/'
5
8
  end
6
9
  rescue LoadError
7
10
  puts 'Coverage disabled, enable by installing simplecov'
@@ -9,3 +12,6 @@ end
9
12
 
10
13
  require 'test/unit'
11
14
 
15
+ require 'csvconverter'
16
+ require "csvconverter/commands/strings2csv_command"
17
+ require "csvconverter/commands/csv2strings_command"
metadata CHANGED
@@ -1,183 +1,222 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: csv2strings
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 2
10
+ version: 0.2.2
6
11
  platform: ruby
7
- authors:
8
- - François Benaiteau
12
+ authors:
13
+ - "Fran\xC3\xA7ois Benaiteau"
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-10-15 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-10-30 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: thor
16
- requirement: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
22
33
  type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: fastercsv
23
37
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
25
39
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
31
50
  name: nokogiri
32
- requirement: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
33
53
  none: false
34
- requirements:
35
- - - '='
36
- - !ruby/object:Gem::Version
54
+ requirements:
55
+ - - "="
56
+ - !ruby/object:Gem::Version
57
+ hash: 23
58
+ segments:
59
+ - 1
60
+ - 5
61
+ - 10
37
62
  version: 1.5.10
38
63
  type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: orderedhash
39
67
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
41
69
  none: false
42
- requirements:
43
- - - '='
44
- - !ruby/object:Gem::Version
45
- version: 1.5.10
46
- - !ruby/object:Gem::Dependency
47
- name: google_drive
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - '='
52
- - !ruby/object:Gem::Version
53
- version: 0.3.6
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
54
77
  type: :runtime
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: google_drive
55
81
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
82
+ requirement: &id005 !ruby/object:Gem::Requirement
57
83
  none: false
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
84
+ requirements:
85
+ - - "="
86
+ - !ruby/object:Gem::Version
87
+ hash: 31
88
+ segments:
89
+ - 0
90
+ - 3
91
+ - 6
61
92
  version: 0.3.6
62
- - !ruby/object:Gem::Dependency
93
+ type: :runtime
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
63
96
  name: rake
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
97
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
98
+ requirement: &id006 !ruby/object:Gem::Requirement
73
99
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: test-unit
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
86
107
  type: :development
108
+ version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ name: test-unit
87
111
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
112
+ requirement: &id007 !ruby/object:Gem::Requirement
89
113
  none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: simplecov
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
102
121
  type: :development
122
+ version_requirements: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ name: simplecov
103
125
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
126
+ requirement: &id008 !ruby/object:Gem::Requirement
105
127
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- description: ruby script converts a CSV file of translations to Localizable.strings
111
- files and vice-versa
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ type: :development
136
+ version_requirements: *id008
137
+ description: ruby script converts a CSV file of translations to Localizable.strings files and vice-versa
112
138
  email: francois.benaiteau@gmail.com
113
- executables:
139
+ executables:
114
140
  - csv2strings
115
141
  - strings2csv
116
142
  extensions: []
143
+
117
144
  extra_rdoc_files: []
118
- files:
145
+
146
+ files:
119
147
  - .csvconverter.sample
120
148
  - .gitignore
121
149
  - .travis.yml
122
150
  - Gemfile
123
- - Gemfile.lock
124
151
  - LICENSE.txt
125
152
  - README.md
126
153
  - Rakefile
127
154
  - bin/csv2strings
128
155
  - bin/strings2csv
129
156
  - csv2strings.gemspec
130
- - lib/command.rb
131
- - lib/csv2strings/converter.rb
132
- - lib/csv2strings_command.rb
133
157
  - lib/csvconverter.rb
134
- - lib/google_doc.rb
135
- - lib/strings2csv/converter.rb
136
- - lib/strings2csv_command.rb
137
- - test/command_test.rb
138
- - test/csv2strings/converter_test.rb
158
+ - lib/csvconverter/command.rb
159
+ - lib/csvconverter/commands/csv2strings_command.rb
160
+ - lib/csvconverter/commands/strings2csv_command.rb
161
+ - lib/csvconverter/csv2strings.rb
162
+ - lib/csvconverter/google_doc.rb
163
+ - lib/csvconverter/strings2csv.rb
164
+ - test/csvconverter/commands/test_command_csv2strings.rb
165
+ - test/csvconverter/commands/test_command_strings2csv.rb
166
+ - test/csvconverter/test_csv2strings.rb
167
+ - test/csvconverter/test_strings2csv.rb
139
168
  - test/data/test_data.csv
140
169
  - test/data/test_data.strings
141
170
  - test/data/test_data_multiple_langs.csv
142
171
  - test/data/test_en.strings
143
172
  - test/data/test_fr.strings
144
- - test/google_doc_test.rb
145
- - test/strings2csv/converter_test.rb
173
+ - test/data/test_with_nil.csv
174
+ - test/data/test_with_nil.strings
146
175
  - test/test_helper.rb
176
+ has_rdoc: true
147
177
  homepage: https://github.com/netbe/CSV-to-iOS-Localizable.strings-converter
148
- licenses:
178
+ licenses:
149
179
  - MIT
150
180
  post_install_message:
151
181
  rdoc_options: []
152
- require_paths:
182
+
183
+ require_paths:
153
184
  - - lib
154
- required_ruby_version: !ruby/object:Gem::Requirement
185
+ required_ruby_version: !ruby/object:Gem::Requirement
155
186
  none: false
156
- requirements:
157
- - - ! '>='
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ hash: 3
191
+ segments:
192
+ - 0
193
+ version: "0"
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
195
  none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
166
203
  requirements: []
204
+
167
205
  rubyforge_project:
168
- rubygems_version: 1.8.23
206
+ rubygems_version: 1.6.2
169
207
  signing_key:
170
208
  specification_version: 3
171
209
  summary: CSV to iOS Localizable.strings converter
172
- test_files:
173
- - test/command_test.rb
174
- - test/csv2strings/converter_test.rb
210
+ test_files:
211
+ - test/csvconverter/commands/test_command_csv2strings.rb
212
+ - test/csvconverter/commands/test_command_strings2csv.rb
213
+ - test/csvconverter/test_csv2strings.rb
214
+ - test/csvconverter/test_strings2csv.rb
175
215
  - test/data/test_data.csv
176
216
  - test/data/test_data.strings
177
217
  - test/data/test_data_multiple_langs.csv
178
218
  - test/data/test_en.strings
179
219
  - test/data/test_fr.strings
180
- - test/google_doc_test.rb
181
- - test/strings2csv/converter_test.rb
220
+ - test/data/test_with_nil.csv
221
+ - test/data/test_with_nil.strings
182
222
  - test/test_helper.rb
183
- has_rdoc: