aigu 0.3.1 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Aigu::Exporter do
4
4
  describe :flattenize_content_values do
5
- let(:exporter) { described_class.new }
5
+ let(:exporter) { Aigu::Exporter.new }
6
6
  let(:flattenized_content) { exporter.send(:flattenize_content_values, content) }
7
7
 
8
8
  let(:content) do
@@ -37,7 +37,7 @@ describe Aigu::Exporter do
37
37
  end
38
38
 
39
39
  describe :globalize_content_keys do
40
- let(:exporter) { described_class.new }
40
+ let(:exporter) { Aigu::Exporter.new }
41
41
  let(:globalized_keys) { exporter.send(:globalize_content_keys, content).keys }
42
42
  before { exporter.instance_variable_set(:@locale, 'fr') }
43
43
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Aigu::Importer do
4
4
  describe :build_blob do
5
- let(:importer) { described_class.new }
5
+ let(:importer) { Aigu::Importer.new }
6
6
  let(:expanded_content) { importer.send(:expand_content_values, content) }
7
7
 
8
8
  let(:content) do
@@ -37,7 +37,7 @@ describe Aigu::Importer do
37
37
  end
38
38
 
39
39
  describe :localize_content_keys do
40
- let(:exporter) { described_class.new }
40
+ let(:exporter) { Aigu::Importer.new }
41
41
  let(:localized_keys) { exporter.send(:localize_content_keys, content).keys }
42
42
  before { exporter.instance_variable_set(:@locale, 'fr') }
43
43
 
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aigu::IosExporter do
4
+ describe :parse_strings_file do
5
+ let(:exporter) { Aigu::IosExporter.new }
6
+ let(:parse_strings_file) { exporter.send(:parse_strings_file, content) }
7
+
8
+ let(:content) do
9
+ <<-EOS.unindent
10
+ "STRING_1" = "Value of string #1";
11
+ "STRING_2" = "Value of string #2";
12
+ "STRING_3" = "Value with special chars (%ld) %@\\n = abc";
13
+ "STRING_4" = "Value with an interpolation %s.";
14
+ "STRING_5" = "Value with %s interpolations %s.";
15
+ "STRING_6" = "Value with an interpolation with an identifier %1$s.";
16
+ "STRING_7" = "Value with %1$s interpolations with an identifier %2$s.";
17
+ EOS
18
+ end
19
+
20
+ let(:expected_content) do
21
+ {
22
+ 'STRING_1' => 'Value of string #1',
23
+ 'STRING_2' => 'Value of string #2',
24
+ 'STRING_3' => 'Value with special chars (%ld) %@\n = abc',
25
+ 'STRING_4' => 'Value with an interpolation %@.',
26
+ 'STRING_5' => 'Value with %@ interpolations %@.',
27
+ 'STRING_6' => 'Value with an interpolation with an identifier %1$@.',
28
+ 'STRING_7' => 'Value with %1$@ interpolations with an identifier %2$@.'
29
+ }
30
+ end
31
+
32
+ it { expect(parse_strings_file).to eql expected_content }
33
+ end
34
+
35
+ describe :parse_stringsdict_file do
36
+ let(:exporter) { Aigu::IosExporter.new }
37
+ let(:parse_stringsdict_file) { exporter.send(:parse_stringsdict_file, content) }
38
+
39
+ let(:content) do
40
+ <<-EOS.unindent
41
+ <?xml version="1.0" encoding="UTF-8"?>
42
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
43
+ <plist version="1.0">
44
+ <dict>
45
+ <key>BUNDLE_1</key>
46
+ <dict>
47
+ <key>NSStringLocalizedFormatKey</key>
48
+ <string>%1$\#@string1@</string>
49
+ <key>string1</key>
50
+ <dict>
51
+ <key>NSStringFormatSpecTypeKey</key>
52
+ <string>NSStringPluralRuleType</string>
53
+ <key>NSStringFormatValueTypeKey</key>
54
+ <string>d</string>
55
+ <key>zero</key>
56
+ <string>%d value #1 zero</string>
57
+ <key>one</key>
58
+ <string>%d value #1 one</string>
59
+ <key>other</key>
60
+ <string>%d value #1 other</string>
61
+ </dict>
62
+ <key>string2</key>
63
+ <dict>
64
+ <key>NSStringFormatSpecTypeKey</key>
65
+ <string>NSStringPluralRuleType</string>
66
+ <key>NSStringFormatValueTypeKey</key>
67
+ <string>d</string>
68
+ <key>zero</key>
69
+ <string>%d value #2 &amp; zero</string>
70
+ <key>one</key>
71
+ <string>%d value #2 one</string>
72
+ <key>other</key>
73
+ <string>%d value #2 other</string>
74
+ </dict>
75
+ </dict>
76
+ <key>BUNDLE_2</key>
77
+ <dict>
78
+ <key>NSStringLocalizedFormatKey</key>
79
+ <string>%1$\#@string1@</string>
80
+ <key>string1</key>
81
+ <dict>
82
+ <key>NSStringFormatSpecTypeKey</key>
83
+ <string>NSStringPluralRuleType</string>
84
+ <key>NSStringFormatValueTypeKey</key>
85
+ <string>d</string>
86
+ <key>zero</key>
87
+ <string>%d value #1 zero</string>
88
+ <key>one</key>
89
+ <string>%d value #1 one</string>
90
+ <key>other</key>
91
+ <string>%d value #1 other</string>
92
+ </dict>
93
+ </dict>
94
+ </dict>
95
+ </plist>
96
+ EOS
97
+ end
98
+
99
+ let(:expected_content) do
100
+ {
101
+ '__@DICT__BUNDLE_1__@STRING__string1__@ZERO' => '%d value #1 zero',
102
+ '__@DICT__BUNDLE_1__@STRING__string1__@ONE' => '%d value #1 one',
103
+ '__@DICT__BUNDLE_1__@STRING__string1__@OTHER' => '%d value #1 other',
104
+ '__@DICT__BUNDLE_1__@STRING__string2__@ZERO' => '%d value #2 & zero',
105
+ '__@DICT__BUNDLE_1__@STRING__string2__@ONE' => '%d value #2 one',
106
+ '__@DICT__BUNDLE_1__@STRING__string2__@OTHER' => '%d value #2 other',
107
+ '__@DICT__BUNDLE_2__@STRING__string1__@ZERO' => '%d value #1 zero',
108
+ '__@DICT__BUNDLE_2__@STRING__string1__@ONE' => '%d value #1 one',
109
+ '__@DICT__BUNDLE_2__@STRING__string1__@OTHER' => '%d value #1 other'
110
+ }
111
+ end
112
+
113
+ it { expect(parse_stringsdict_file).to eql expected_content }
114
+ end
115
+ end
@@ -0,0 +1,175 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aigu::IosImporter do
4
+ describe :format_strings_file do
5
+ let(:importer) { Aigu::IosImporter.new }
6
+ let(:format_strings_file) { importer.send(:format_strings_file, content) }
7
+
8
+ let(:content) do
9
+ {
10
+ 'STRING_1' => 'Value of string #1',
11
+ 'STRING_2' => 'Value of string #2',
12
+ 'STRING_3' => 'Value with special chars (%ld) %@\n " = " abc',
13
+ 'STRING_4' => 'Value with an interpolation %@.',
14
+ 'STRING_5' => 'Value with %@ interpolations %@.',
15
+ 'STRING_6' => 'Value with an interpolation with an identifier %1$@.',
16
+ 'STRING_7' => 'Value with %1$@ interpolations with an identifier %2$@.'
17
+ }
18
+ end
19
+
20
+ let(:expected_content) do
21
+ <<-EOS.unindent
22
+ "STRING_1" = "Value of string #1";
23
+ "STRING_2" = "Value of string #2";
24
+ "STRING_3" = "Value with special chars (%ld) %s\\n " = " abc";
25
+ "STRING_4" = "Value with an interpolation %s.";
26
+ "STRING_5" = "Value with %s interpolations %s.";
27
+ "STRING_6" = "Value with an interpolation with an identifier %1$s.";
28
+ "STRING_7" = "Value with %1$s interpolations with an identifier %2$s.";
29
+ EOS
30
+ end
31
+
32
+ it { expect(format_strings_file).to eql expected_content }
33
+ end
34
+
35
+ describe :update_stringsdict_content do
36
+ let(:exporter) { Aigu::IosImporter.new }
37
+ let(:update_stringsdict_content) { exporter.send(:update_stringsdict_content, file_content, new_hash) }
38
+
39
+ let(:file_content) do
40
+ <<-EOS.unindent
41
+ <?xml version="1.0" encoding="UTF-8"?>
42
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
43
+ <plist version="1.0">
44
+ <dict>
45
+ <key>BUNDLE_1</key>
46
+ <dict>
47
+ <key>NSStringLocalizedFormatKey</key>
48
+ <string>%1$\#@string1@</string>
49
+ <key>string1</key>
50
+ <dict>
51
+ <key>NSStringFormatSpecTypeKey</key>
52
+ <string>NSStringPluralRuleType</string>
53
+ <key>NSStringFormatValueTypeKey</key>
54
+ <string>d</string>
55
+ <key>zero</key>
56
+ <string>%d value #1 zero</string>
57
+ <key>one</key>
58
+ <string>%d value #1 one</string>
59
+ <key>other</key>
60
+ <string>%d value #1 other</string>
61
+ </dict>
62
+ <key>string2</key>
63
+ <dict>
64
+ <key>NSStringFormatSpecTypeKey</key>
65
+ <string>NSStringPluralRuleType</string>
66
+ <key>NSStringFormatValueTypeKey</key>
67
+ <string>d</string>
68
+ <key>zero</key>
69
+ <string>%d value #2 &amp; zero</string>
70
+ <key>one</key>
71
+ <string>%d value #2 one</string>
72
+ <key>other</key>
73
+ <string>%d value #2 other</string>
74
+ </dict>
75
+ </dict>
76
+ <key>BUNDLE_2</key>
77
+ <dict>
78
+ <key>NSStringLocalizedFormatKey</key>
79
+ <string>%1$\#@string1@</string>
80
+ <key>string1</key>
81
+ <dict>
82
+ <key>NSStringFormatSpecTypeKey</key>
83
+ <string>NSStringPluralRuleType</string>
84
+ <key>NSStringFormatValueTypeKey</key>
85
+ <string>d</string>
86
+ <key>zero</key>
87
+ <string>%d value #1 zero</string>
88
+ <key>one</key>
89
+ <string>%d value #1 one</string>
90
+ <key>other</key>
91
+ <string>%d value #1 other</string>
92
+ </dict>
93
+ </dict>
94
+ </dict>
95
+ </plist>
96
+ EOS
97
+ end
98
+
99
+ let(:new_hash) do
100
+ {
101
+ '__@DICT__BUNDLE_1__@STRING__string1__@ZERO' => '%d value #1 zero new',
102
+ '__@DICT__BUNDLE_1__@STRING__string1__@ONE' => '%d value #1 one new',
103
+ '__@DICT__BUNDLE_1__@STRING__string1__@OTHER' => '%d value #1 other new',
104
+ '__@DICT__BUNDLE_1__@STRING__string2__@ZERO' => '%d value #2 & zero new',
105
+ '__@DICT__BUNDLE_1__@STRING__string2__@ONE' => '%d value #2 one new',
106
+ '__@DICT__BUNDLE_1__@STRING__string2__@OTHER' => '%d value #2 other new',
107
+ '__@DICT__BUNDLE_2__@STRING__string1__@ZERO' => '%d value #1 zero new',
108
+ '__@DICT__BUNDLE_2__@STRING__string1__@ONE' => '%d value #1 one new',
109
+ '__@DICT__BUNDLE_2__@STRING__string1__@OTHER' => '%d value #1 other new'
110
+ }
111
+ end
112
+
113
+ let(:expected_content) do
114
+ <<-EOS.unindent
115
+ <?xml version="1.0" encoding="UTF-8"?>
116
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
117
+ <plist version="1.0">
118
+ <dict>
119
+ <key>BUNDLE_1</key>
120
+ <dict>
121
+ <key>NSStringLocalizedFormatKey</key>
122
+ <string>%1$\#@string1@</string>
123
+ <key>string1</key>
124
+ <dict>
125
+ <key>NSStringFormatSpecTypeKey</key>
126
+ <string>NSStringPluralRuleType</string>
127
+ <key>NSStringFormatValueTypeKey</key>
128
+ <string>d</string>
129
+ <key>zero</key>
130
+ <string>%d value #1 zero new</string>
131
+ <key>one</key>
132
+ <string>%d value #1 one new</string>
133
+ <key>other</key>
134
+ <string>%d value #1 other new</string>
135
+ </dict>
136
+ <key>string2</key>
137
+ <dict>
138
+ <key>NSStringFormatSpecTypeKey</key>
139
+ <string>NSStringPluralRuleType</string>
140
+ <key>NSStringFormatValueTypeKey</key>
141
+ <string>d</string>
142
+ <key>zero</key>
143
+ <string>%d value #2 &amp; zero new</string>
144
+ <key>one</key>
145
+ <string>%d value #2 one new</string>
146
+ <key>other</key>
147
+ <string>%d value #2 other new</string>
148
+ </dict>
149
+ </dict>
150
+ <key>BUNDLE_2</key>
151
+ <dict>
152
+ <key>NSStringLocalizedFormatKey</key>
153
+ <string>%1$\#@string1@</string>
154
+ <key>string1</key>
155
+ <dict>
156
+ <key>NSStringFormatSpecTypeKey</key>
157
+ <string>NSStringPluralRuleType</string>
158
+ <key>NSStringFormatValueTypeKey</key>
159
+ <string>d</string>
160
+ <key>zero</key>
161
+ <string>%d value #1 zero new</string>
162
+ <key>one</key>
163
+ <string>%d value #1 one new</string>
164
+ <key>other</key>
165
+ <string>%d value #1 other new</string>
166
+ </dict>
167
+ </dict>
168
+ </dict>
169
+ </plist>
170
+ EOS
171
+ end
172
+
173
+ it { expect(update_stringsdict_content).to eql expected_content }
174
+ end
175
+ end
@@ -3,5 +3,11 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
  require 'rspec'
4
4
  require 'aigu'
5
5
 
6
- RSpec.configure do |config|
6
+ RSpec.configure do |*|
7
+ end
8
+
9
+ class String
10
+ def unindent
11
+ gsub(/^#{scan(/^\s*/).min_by(&:length)}/, '')
12
+ end
7
13
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aigu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
8
+ - William Jobin
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
12
+ date: 2014-11-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -44,18 +45,61 @@ dependencies:
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: 3.0.0.beta2
48
+ version: '3.0'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: 3.0.0.beta2
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: phare
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.6'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.6'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.27.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.27.0
84
+ - !ruby/object:Gem::Dependency
85
+ name: nokogiri
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 1.6.3
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 1.6.3
55
98
  description: Aigu converts a directory of Rails localization files into a single JSON
56
99
  file to import in Accent.
57
100
  email:
58
101
  - rprevost@mirego.com
102
+ - wjobin@mirego.com
59
103
  executables:
60
104
  - aigu
61
105
  extensions: []
@@ -63,6 +107,7 @@ extra_rdoc_files: []
63
107
  files:
64
108
  - ".gitignore"
65
109
  - ".rspec"
110
+ - ".rubocop.yml"
66
111
  - Gemfile
67
112
  - LICENSE.md
68
113
  - README.md
@@ -70,14 +115,31 @@ files:
70
115
  - SPEC.md
71
116
  - aigu.gemspec
72
117
  - bin/aigu
118
+ - bin/phare
73
119
  - lib/aigu.rb
120
+ - lib/aigu/android_exporter.rb
121
+ - lib/aigu/android_importer.rb
74
122
  - lib/aigu/cli.rb
123
+ - lib/aigu/core_exporter.rb
124
+ - lib/aigu/core_importer.rb
75
125
  - lib/aigu/exporter.rb
76
126
  - lib/aigu/extensions/hash.rb
77
127
  - lib/aigu/importer.rb
128
+ - lib/aigu/ios_exporter.rb
129
+ - lib/aigu/ios_importer.rb
130
+ - lib/aigu/mergeer.rb
131
+ - lib/aigu/puller.rb
132
+ - lib/aigu/pusher.rb
133
+ - lib/aigu/unmergeer.rb
78
134
  - lib/aigu/version.rb
135
+ - spec/aigu/android_exporter_spec.rb
136
+ - spec/aigu/android_importer_spec.rb
137
+ - spec/aigu/core_exporter_spec.rb
138
+ - spec/aigu/core_importer_spec.rb
79
139
  - spec/aigu/exporter_spec.rb
80
140
  - spec/aigu/importer_spec.rb
141
+ - spec/aigu/ios_exporter_spec.rb
142
+ - spec/aigu/ios_importer_spec.rb
81
143
  - spec/spec_helper.rb
82
144
  homepage: https://github.com/mirego/aigu
83
145
  licenses:
@@ -105,6 +167,12 @@ specification_version: 4
105
167
  summary: Aigu converts a directory of Rails localization files into a single JSON
106
168
  file to import in Accent.
107
169
  test_files:
170
+ - spec/aigu/android_exporter_spec.rb
171
+ - spec/aigu/android_importer_spec.rb
172
+ - spec/aigu/core_exporter_spec.rb
173
+ - spec/aigu/core_importer_spec.rb
108
174
  - spec/aigu/exporter_spec.rb
109
175
  - spec/aigu/importer_spec.rb
176
+ - spec/aigu/ios_exporter_spec.rb
177
+ - spec/aigu/ios_importer_spec.rb
110
178
  - spec/spec_helper.rb