aigu 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eac535ebe6faefec0c2da69698309d5f2a98f6f6
4
- data.tar.gz: 2746a44b55270cbf60a67edf5f9370a008da918f
3
+ metadata.gz: cc22719006732fb891db0d44fa2d4ea812f3d123
4
+ data.tar.gz: 5ce1de8334206be7681ff5a55edcf522e495b488
5
5
  SHA512:
6
- metadata.gz: bbf11e1e3214c658c24f897ddb223a2710b508331e3f5198ff17952262eb19141021a4b56aa31633344e9f3638858fa49115de7e924e479ce9197cbcaec85065
7
- data.tar.gz: ba28a3484fd6e84abd5b3b92add340ea64baba68e9aabb4017b3117ecf4b67fca79a666fc145006d88dd63b1ec0025eb13c0d8072e111b88666f1da06a7bdfcb
6
+ metadata.gz: 020f7cd1063e9afb54266ea4c112d17e3d2b29c54fd27edec62e0fab257202d97b6ac74c981020f344e749e1730583b23c14ffaa8080a44803734d86d5dab6cd
7
+ data.tar.gz: b63fa05a19d32d4a753e2d5784317cf4c87317285b09d4192071ba3718f6a6e843181fb2a510a1de76cf83b03d2a8b4b8f16627fc2d72c0d9426e48b8e02ce64
@@ -50,3 +50,6 @@ Metrics/AbcSize:
50
50
 
51
51
  ClassLength:
52
52
  Enabled: false
53
+
54
+ Style/GuardClause:
55
+ Enabled: false
@@ -49,6 +49,7 @@ module Aigu
49
49
  end
50
50
  end
51
51
 
52
+ @output = remove_special_characters_escape(@output)
52
53
  @output
53
54
  end
54
55
 
@@ -161,5 +162,12 @@ module Aigu
161
162
  _, locale = get_resource_type(filepath)
162
163
  !(@locale == locale)
163
164
  end
165
+
166
+ def remove_special_characters_escape(content)
167
+ content.each_with_object({}) do |(key, value), memo|
168
+ # Remove single quotes escape "\'" -> "'"
169
+ memo[key] = value.gsub("\\'", "'")
170
+ end
171
+ end
164
172
  end
165
173
  end
@@ -27,6 +27,7 @@ module Aigu
27
27
  json = File.read(@input_file)
28
28
  @object = JSON.parse(json)
29
29
  @object = expand_content_values(@object)
30
+ @object = escape_special_characters(@object)
30
31
  end
31
32
 
32
33
  def write_xml_files
@@ -95,6 +96,20 @@ module Aigu
95
96
  end
96
97
  end
97
98
 
99
+ def escape_special_characters(content)
100
+ content.each_with_object({}) do |(key, value), memo|
101
+ if value.is_a?(Array)
102
+ memo[key] = value.map { |s| escape_string_special_characters(s) }
103
+ else
104
+ memo[key] = escape_string_special_characters(value)
105
+ end
106
+ end
107
+ end
108
+
109
+ def escape_string_special_characters(string)
110
+ string.gsub("'", "\\\\'")
111
+ end
112
+
98
113
  def split_res_types(content)
99
114
  res_types = {}
100
115
 
@@ -34,6 +34,11 @@ module Aigu
34
34
  response = http.request(request)
35
35
  puts 'Response code: ' + response.code
36
36
 
37
+ if response.code != '200'
38
+ puts 'Error pulling string revision from Accent'
39
+ exit 1
40
+ end
41
+
37
42
  puts "Generating #{@output_file}"
38
43
 
39
44
  File.open(@output_file, 'w+') do |file|
@@ -39,6 +39,11 @@ module Aigu
39
39
  response = http.request(request)
40
40
 
41
41
  puts 'Response: ' + response.code
42
+
43
+ if response.code != '201'
44
+ puts 'Error pushing string update to Accent'
45
+ exit 1
46
+ end
42
47
  end
43
48
  end
44
49
  end
@@ -1,3 +1,3 @@
1
1
  module Aigu
2
- VERSION = '0.4.3'
2
+ VERSION = '0.4.4'
3
3
  end
@@ -18,6 +18,7 @@ describe Aigu::AndroidExporter do
18
18
  <item>Living Room</item>
19
19
  <item>Kitchen</item>
20
20
  <item>Bedroom</item>
21
+ <item>array item with special characters character escaped: \'</item>
21
22
  </string-array>
22
23
  </resources>
23
24
  EOS
@@ -31,10 +32,34 @@ describe Aigu::AndroidExporter do
31
32
  'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#0' => 'Custom',
32
33
  'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#1' => 'Living Room',
33
34
  'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#2' => 'Kitchen',
34
- 'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#3' => 'Bedroom'
35
+ 'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#3' => 'Bedroom',
36
+ 'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#4' => "array item with special characters character escaped: '"
35
37
  }
36
38
  end
37
39
 
38
40
  it { expect(parse_xml).to eql expected_content }
39
41
  end
42
+
43
+ describe :remove_special_characters_escape do
44
+ let(:exporter) { Aigu::AndroidExporter.new }
45
+ let(:remove_special_characters_escape) { exporter.send(:remove_special_characters_escape, content) }
46
+
47
+ let(:content) do
48
+ {
49
+ 'string1' => "I\\'m a pro",
50
+ 'string2' => 'I am a pro',
51
+ 'string3' => "J\\'aime l\\'avoir proche d\\'ici"
52
+ }
53
+ end
54
+
55
+ let(:expected_content) do
56
+ {
57
+ 'string1' => "I'm a pro",
58
+ 'string2' => 'I am a pro',
59
+ 'string3' => "J'aime l'avoir proche d'ici"
60
+ }
61
+ end
62
+
63
+ it { expect(remove_special_characters_escape).to eql expected_content }
64
+ end
40
65
  end
@@ -13,7 +13,8 @@ describe Aigu::AndroidImporter do
13
13
  'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#0' => 'Custom',
14
14
  'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#1' => 'Living Room',
15
15
  'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#2' => 'Kitchen',
16
- 'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#3' => 'Bedroom'
16
+ 'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#3' => 'Bedroom',
17
+ 'pairing_step_three_custom_nickname_array__ARRAY_ITEM__#4' => 'array item with special characters character escaped: \''
17
18
  }
18
19
  end
19
20
 
@@ -26,7 +27,8 @@ describe Aigu::AndroidImporter do
26
27
  'Custom',
27
28
  'Living Room',
28
29
  'Kitchen',
29
- 'Bedroom'
30
+ 'Bedroom',
31
+ 'array item with special characters character escaped: \''
30
32
  ]
31
33
  }
32
34
  end
@@ -128,4 +130,37 @@ describe Aigu::AndroidImporter do
128
130
 
129
131
  it { expect(res_xml).to eql expected_content }
130
132
  end
133
+
134
+ describe :escape_special_characters do
135
+ let(:importer) { Aigu::AndroidImporter.new }
136
+ let(:escape_special_characters) { importer.send(:escape_special_characters, content) }
137
+
138
+ let(:content) do
139
+ {
140
+ 'string1' => "I'm a pro",
141
+ 'string2' => 'I am a pro',
142
+ 'string3' => "J'aime l'avoir proche d'ici",
143
+ 'string_array' => [
144
+ 'value_a',
145
+ 'value_b',
146
+ 'value_c with special characters: & < > \''
147
+ ]
148
+ }
149
+ end
150
+
151
+ let(:expected_content) do
152
+ {
153
+ 'string1' => "I\\'m a pro",
154
+ 'string2' => 'I am a pro',
155
+ 'string3' => "J\\'aime l\\'avoir proche d\\'ici",
156
+ 'string_array' => [
157
+ 'value_a',
158
+ 'value_b',
159
+ 'value_c with special characters: & < > \\\''
160
+ ]
161
+ }
162
+ end
163
+
164
+ it { expect(escape_special_characters).to eql expected_content }
165
+ end
131
166
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aigu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-02 00:00:00.000000000 Z
12
+ date: 2015-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 2.2.2
164
+ rubygems_version: 2.4.5
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Aigu converts a directory of Rails localization files into a single JSON