txgh 6.6.0 → 6.7.0

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
- SHA1:
3
- metadata.gz: 65977e1c05affd675121705335cd6f2953760620
4
- data.tar.gz: 41dfe7023a6b6ba8a0b61837bf9ada4bd53c58ff
2
+ SHA256:
3
+ metadata.gz: 8fe1d35205ac159f9e86e855a5184386547a2df3a845e37d57c61b9d96bfb0e9
4
+ data.tar.gz: c12c616d8e4b06afecefe52ac9f7ecec3a9b985e61487ce700a1b4683fd54ef1
5
5
  SHA512:
6
- metadata.gz: ee73e9f783884a37fbf3a095f99a389e6a00e802f40126a270d64659ee2e540a245b98c7f0aca49f9eb8400346d7aceec551a46e42b52a122f543eb593481480
7
- data.tar.gz: 0fbd8d7e317674ebf2a13d1f4ded8f77ccb0ab05b4f1291bc30f80bdc48fd42a29015b2c0ea5ab335dd58eecc1553ff5fc889668d098841de7e6ae36abcf2a1f
6
+ metadata.gz: 93788fa04952a8b003772ab23778ab64b54b98b49b19733fd6419b7976c8cd7e850832293e2f8798666bfeb7655e596f471c24224f009d94976ad549a67aa52e
7
+ data.tar.gz: d3118d46bb01cb2293403894269de15d50890a9fc0edf8a525d1e2400561a1ba8d0b5356cffadfba52bd192f42b7cfdb45de4d809d7ff47f5ce6811cc6c8f09a
@@ -6,18 +6,24 @@ module Txgh
6
6
  EXTRACTOR_MAP = {
7
7
  'YML' => 'yaml/rails',
8
8
  'YAML' => 'yaml/rails',
9
- 'KEYVALUEJSON' => 'json/key-value',
9
+ 'KEYVALUEJSON' => 'json/dotted-key',
10
10
  'ANDROID' => 'xml/android',
11
11
  'TXT' => 'txt/lines'
12
- }
12
+ }.freeze
13
13
 
14
14
  SERIALIZER_MAP = {
15
15
  'YML' => 'yaml/rails',
16
16
  'YAML' => 'yaml/rails',
17
- 'KEYVALUEJSON' => 'json/key-value',
17
+ 'KEYVALUEJSON' => 'json/dotted-key',
18
18
  'ANDROID' => 'xml/android',
19
19
  'TXT' => 'txt/lines'
20
- }
20
+ }.freeze
21
+
22
+ DEFAULT_OPTIONS_MAP = {
23
+ 'json/dotted-key' => {
24
+ pretty: true, indent_size: 4
25
+ }.freeze
26
+ }.freeze
21
27
 
22
28
  class << self
23
29
  def from_phrase_list(tx_resource, phrases)
@@ -30,6 +36,7 @@ module Txgh
30
36
  end
31
37
 
32
38
  attr_reader :tx_resource
39
+ attr_writer :serialization_options
33
40
 
34
41
  def initialize(tx_resource, options)
35
42
  @tx_resource = tx_resource
@@ -37,6 +44,10 @@ module Txgh
37
44
  @raw = options[:raw]
38
45
  end
39
46
 
47
+ def serialization_options
48
+ @serialization_options || DEFAULT_OPTIONS_MAP.fetch(serializer_id, {})
49
+ end
50
+
40
51
  def phrases
41
52
  @phrases ||= extractor.from_string(raw) do |extractor|
42
53
  extractor.extract_each(preserve_arrays: true).map do |key, value|
@@ -55,7 +66,7 @@ module Txgh
55
66
  # want to override the resource's source language using the second
56
67
  # parameter here.
57
68
  def write_to(stream, language = tx_resource.source_lang)
58
- serializer.from_stream(stream, language) do |serializer|
69
+ serializer.from_stream(stream, language, serialization_options) do |serializer|
59
70
  phrases.each do |phrase|
60
71
  serializer.write_key_value(
61
72
  phrase['key'], str(phrase['string'] || '')
@@ -106,24 +117,28 @@ module Txgh
106
117
  end
107
118
  end
108
119
 
109
- def extractor
110
- id = EXTRACTOR_MAP.fetch(tx_resource.type) do
120
+ def extractor_id
121
+ EXTRACTOR_MAP.fetch(tx_resource.type) do
111
122
  raise TxghInternalError,
112
123
  "'#{tx_resource.type}' is not a file type that is supported when "\
113
124
  "uploading diffs."
114
125
  end
126
+ end
115
127
 
116
- Abroad.extractor(id)
128
+ def extractor
129
+ Abroad.extractor(extractor_id)
117
130
  end
118
131
 
119
- def serializer
120
- id = SERIALIZER_MAP.fetch(tx_resource.type) do
132
+ def serializer_id
133
+ SERIALIZER_MAP.fetch(tx_resource.type) do
121
134
  raise TxghInternalError,
122
135
  "'#{tx_resource.type}' is not a file type that is supported when "\
123
136
  "uploading diffs."
124
137
  end
138
+ end
125
139
 
126
- Abroad.serializer(id)
140
+ def serializer
141
+ Abroad.serializer(serializer_id)
127
142
  end
128
143
  end
129
144
  end
@@ -43,6 +43,7 @@ module Txgh
43
43
  head_content = wrap(transifex_download(head_resource, language_code), head_resource)
44
44
  diff_point_content = wrap(transifex_download(diff_point_resource, language_code), diff_point_resource)
45
45
  contents = diff_point_content.merge(head_content, source_diff)
46
+ contents.serialization_options = Txgh::Utils.deep_symbolize_keys(project.serialization_options)
46
47
 
47
48
  yield file_name, contents.to_s(language_code)
48
49
  end
@@ -42,6 +42,10 @@ module Txgh
42
42
  config.fetch('languages', [])
43
43
  end
44
44
 
45
+ def serialization_options
46
+ config.fetch('serialization_options', {})
47
+ end
48
+
45
49
  def supported_language?(language)
46
50
  languages.include?(language)
47
51
  end
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '6.6.0'
2
+ VERSION = '6.7.0'
3
3
  end
@@ -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.4'
16
+ s.add_dependency 'abroad', '~> 4.6'
17
17
  s.add_dependency 'celluloid'
18
18
  s.add_dependency 'faraday', '~> 0.9'
19
19
  s.add_dependency 'faraday_middleware', '~> 0.10'
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: 6.6.0
4
+ version: 6.7.0
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: 2018-05-21 00:00:00.000000000 Z
12
+ date: 2019-01-31 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.4'
20
+ version: '4.6'
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.4'
27
+ version: '4.6'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: celluloid
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  requirements: []
206
206
  rubyforge_project:
207
- rubygems_version: 2.4.5.5
207
+ rubygems_version: 2.7.6
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: A library for syncing translation resources between Github and Transifex.