txgh 5.4.0 → 5.4.1

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: eb6e3463432f659922924f0e8772d52ff629d56e
4
- data.tar.gz: b2ae04fce6e467c3e288f4719fa6b21428e21458
3
+ metadata.gz: a0183e2c5a596ebda16f7775a5cf078900068634
4
+ data.tar.gz: 0c2cc582d83d942c939c755bcf3e64d29d395dcc
5
5
  SHA512:
6
- metadata.gz: ea6b213e8f7b13a610324114f192542f22ab018697373b12d5299d590f680c6cf25da29fe699a21ae8d4c391980c04ecbe89c6e97bfb615ecbaffa95a74fce4b
7
- data.tar.gz: 00e05c87d887ce50b9fd26f252950bc7acde5511e73b29065f09197838e4d74468feebd9d2568e98771b4890df652b32543c17c49887cd6c283c3cbbd47616d7
6
+ metadata.gz: 05cb4253942683db1635da27f416ceb9b7ff7c9d48ebc0cb60164f845b091d6e2c78071581f15ccb5de1633fa382b41ac9f726c9be8d59ec00462746a9b927ef
7
+ data.tar.gz: 917ccf68a9992cb89782b8cf95ce71f6635a1945dcba1b232a1f2b90ded84c83a8a3f25df217523dec87c6c11b4c183ec2bf5d8ccdf21e485008782f1d0837ea
@@ -37,7 +37,7 @@ module Txgh
37
37
 
38
38
  def phrases
39
39
  @phrases ||= extractor.from_string(raw) do |extractor|
40
- extractor.extract_each.map do |key, value|
40
+ extractor.extract_each(preserve_arrays: true).map do |key, value|
41
41
  { 'key' => key, 'string' => value }
42
42
  end
43
43
  end
@@ -56,7 +56,7 @@ module Txgh
56
56
  serializer.from_stream(stream, language) do |serializer|
57
57
  phrases.each do |phrase|
58
58
  serializer.write_key_value(
59
- phrase['key'], (phrase['string'] || '').to_s
59
+ phrase['key'], str(phrase['string'] || '')
60
60
  )
61
61
  end
62
62
  end
@@ -95,6 +95,15 @@ module Txgh
95
95
 
96
96
  attr_reader :raw
97
97
 
98
+ def str(obj)
99
+ case obj
100
+ when Array
101
+ obj
102
+ else
103
+ obj.to_s
104
+ end
105
+ end
106
+
98
107
  def extractor
99
108
  id = EXTRACTOR_MAP.fetch(tx_resource.type) do
100
109
  raise TxghInternalError,
data/lib/txgh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '5.4.0'
2
+ VERSION = '5.4.1'
3
3
  end
@@ -35,6 +35,29 @@ describe DiffCalculator do
35
35
  end
36
36
  end
37
37
 
38
+ context 'with an array added to HEAD' do
39
+ let(:head_phrases) do
40
+ diff_point_phrases + [
41
+ phrase('villains', %w(Khan Chang Valeris Shinzon))
42
+ ]
43
+ end
44
+
45
+ let(:diff_point_phrases) do
46
+ [
47
+ phrase('Bajor', 'Bajoran'),
48
+ phrase('Cardassia', 'Cardassian')
49
+ ]
50
+ end
51
+
52
+ it 'includes the new array' do
53
+ expect(diff[:added].size).to eq(1)
54
+ expect(diff[:modified].size).to eq(0)
55
+ phrase = diff[:added].first
56
+ expect(phrase['key']).to eq('villains')
57
+ expect(phrase['string']).to eq(%w(Khan Chang Valeris Shinzon))
58
+ end
59
+ end
60
+
38
61
  context 'with phrases removed from HEAD' do
39
62
  let(:head_phrases) do
40
63
  []
@@ -50,6 +73,21 @@ describe DiffCalculator do
50
73
  end
51
74
  end
52
75
 
76
+ context 'with an array removed from HEAD' do
77
+ let(:head_phrases) do
78
+ []
79
+ end
80
+
81
+ let(:diff_point_phrases) do
82
+ phrase('villains', %w(Khan Chang Valeris Shinzon))
83
+ end
84
+
85
+ it 'does not include the array' do
86
+ expect(diff[:added].size).to eq(0)
87
+ expect(diff[:modified].size).to eq(0)
88
+ end
89
+ end
90
+
53
91
  context 'with phrases modified in HEAD' do
54
92
  let(:head_phrases) do
55
93
  [phrase('TheNextGeneration', 'Jean Luc Picard (rocks)')]
@@ -68,6 +106,24 @@ describe DiffCalculator do
68
106
  end
69
107
  end
70
108
 
109
+ context 'with an array modified in HEAD' do
110
+ let(:head_phrases) do
111
+ [phrase('villains', %w(Khan Chang Valeris Shinzon))]
112
+ end
113
+
114
+ let(:diff_point_phrases) do
115
+ [phrase('villains', %w(Khan Chang Valeris))]
116
+ end
117
+
118
+ it 'includes the entire array' do
119
+ expect(diff[:added].size).to eq(0)
120
+ expect(diff[:modified].size).to eq(1)
121
+ phrase = diff[:modified].first
122
+ expect(phrase['key']).to eq('villains')
123
+ expect(phrase['string']).to eq(%w(Khan Chang Valeris Shinzon))
124
+ end
125
+ end
126
+
71
127
  context 'with no phrases modified, added, or removed' do
72
128
  let(:head_phrases) do
73
129
  [
@@ -46,6 +46,22 @@ describe MergeCalculator do
46
46
  end
47
47
  end
48
48
 
49
+ context 'with an array added in HEAD' do
50
+ let(:diff_point_phrases) do
51
+ [phrase('planet.earth', 'Human')]
52
+ end
53
+
54
+ let(:head_phrases) do
55
+ diff_point_phrases + [
56
+ phrase('villains', %w(Kahn Chang Valeris Shinzon))
57
+ ]
58
+ end
59
+
60
+ it 'includes the added array' do
61
+ expect(merge_result.phrases).to eq(head_phrases)
62
+ end
63
+ end
64
+
49
65
  context 'with phrases removed from HEAD' do
50
66
  let(:diff_point_phrases) do
51
67
  head_phrases + [
@@ -62,6 +78,22 @@ describe MergeCalculator do
62
78
  end
63
79
  end
64
80
 
81
+ context 'with an array removed from HEAD' do
82
+ let(:diff_point_phrases) do
83
+ head_phrases + [
84
+ phrase('villains', %w(Kahn Chang Valeris Shinzon))
85
+ ]
86
+ end
87
+
88
+ let(:head_phrases) do
89
+ [phrase('planet.earth', 'Human')]
90
+ end
91
+
92
+ it 'does not include the removed array' do
93
+ expect(merge_result.phrases).to eq(head_phrases)
94
+ end
95
+ end
96
+
65
97
  context 'with phrases modified in HEAD' do
66
98
  let(:diff_point_phrases) do
67
99
  [phrase('planet.bajor', 'Cardassian')]
@@ -76,6 +108,20 @@ describe MergeCalculator do
76
108
  end
77
109
  end
78
110
 
111
+ context 'with an array modified in HEAD' do
112
+ let(:diff_point_phrases) do
113
+ [phrase('villains', %w(Kahn Chang Valeris))]
114
+ end
115
+
116
+ let(:head_phrases) do
117
+ [phrase('villains', %w(Kahn Chang Valeris Shinzon))]
118
+ end
119
+
120
+ it 'includes the modified phrase' do
121
+ expect(merge_result.phrases).to eq(head_phrases)
122
+ end
123
+ end
124
+
79
125
  context 'with no phrases modified, added, or removed' do
80
126
  let(:diff_point_phrases) do
81
127
  [phrase('planet.bajor', 'Bajoran')]
@@ -11,18 +11,29 @@ describe ResourceContents do
11
11
  )
12
12
  end
13
13
 
14
- let(:raw_contents) do
14
+ let(:default_contents) do
15
15
  outdent(%Q(
16
16
  en:
17
17
  welcome:
18
- message: Hello!
18
+ message: "Hello!"
19
19
  goodbye:
20
- message: Goodbye!
20
+ message: "Goodbye!"
21
+ ))
22
+ end
23
+
24
+ let(:array_contents) do
25
+ outdent(%Q(
26
+ en:
27
+ captains:
28
+ - "Janeway"
29
+ - "Picard"
30
+ - "Sisko"
31
+ - "Kirk"
21
32
  ))
22
33
  end
23
34
 
24
35
  let(:contents) do
25
- ResourceContents.from_string(tx_resource, raw_contents)
36
+ ResourceContents.from_string(tx_resource, default_contents)
26
37
  end
27
38
 
28
39
  describe '#phrases' do
@@ -32,6 +43,13 @@ describe ResourceContents do
32
43
  { 'key' => 'goodbye.message', 'string' => 'Goodbye!' }
33
44
  ])
34
45
  end
46
+
47
+ it 'preserves arrays' do
48
+ rsrc_contents = ResourceContents.from_string(tx_resource, array_contents)
49
+ expect(rsrc_contents.phrases).to eq([
50
+ { 'key' => 'captains', 'string' => %w(Janeway Picard Sisko Kirk) }
51
+ ])
52
+ end
35
53
  end
36
54
 
37
55
  describe '#add' do
@@ -47,13 +65,14 @@ describe ResourceContents do
47
65
  it 'serializes the phrases to the given stream' do
48
66
  stream = StringIO.new
49
67
  contents.write_to(stream)
50
- expect(stream.string).to eq(outdent(%Q(
51
- en:
52
- welcome:
53
- message: "Hello!"
54
- goodbye:
55
- message: "Goodbye!"
56
- )))
68
+ expect(stream.string).to eq(default_contents)
69
+ end
70
+
71
+ it 'serializes arrays correctly' do
72
+ stream = StringIO.new
73
+ rsrc_contents = ResourceContents.from_string(tx_resource, array_contents)
74
+ rsrc_contents.write_to(stream)
75
+ expect(stream.string).to eq(array_contents)
57
76
  end
58
77
 
59
78
  it 'includes phrases that were added after the fact' do
data/txgh.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.platform = Gem::Platform::RUBY
14
14
  s.has_rdoc = true
15
15
 
16
- s.add_dependency 'abroad', '~> 4.0'
16
+ s.add_dependency 'abroad', '~> 4.1'
17
17
  s.add_dependency 'faraday', '~> 0.9'
18
18
  s.add_dependency 'faraday_middleware', '~> 0.10'
19
19
  s.add_dependency 'json', '~> 1.8'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txgh
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Jackowski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-03 00:00:00.000000000 Z
12
+ date: 2016-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abroad
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '4.0'
20
+ version: '4.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '4.0'
27
+ version: '4.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: faraday
30
30
  requirement: !ruby/object:Gem::Requirement