txgh 6.2.1 → 6.2.2

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: 489ac4e3bc92e1b84207c831c966a268a948c76c
4
- data.tar.gz: d131ab0a2d4280a5183719bec782e38220a7de20
3
+ metadata.gz: 1053ba18e7cb566323eac1abe07004895dc151c2
4
+ data.tar.gz: 50059beacd2a364ee3913309497d11d1fd028d29
5
5
  SHA512:
6
- metadata.gz: c46275dd6f305e225dcacedeed5663dff4f0b045936af210e0b5c353a805bfb5cfd4d311df2b034958cc9b74ef9b9c8b523b3452607b91bfc44544b9a57ac37d
7
- data.tar.gz: d105c4bcc2a8c5288ee5a229a7b0182b4790493466a6ebe21ce710db95c4a6538c373d783028c0f86c7eee90b71b1754fd033b93deddf171b1f88924babe4780
6
+ metadata.gz: a22619cc53d74193888d7d57f1727e1525dc868d863f38834f6ec6ca8684cd293aaa48033a09ffb05c7676d2093606c5990bbaa7647bc35441a18147c61717ef
7
+ data.tar.gz: ce6aed9c3b358dc67c912052ae7195e364aacb4c3afdde73eddc6d2bfedbc470f2a6859d8d27fb1608cc28592338f3881f63ca18edb216edb5d9f684c323bebc
@@ -4,35 +4,39 @@ module Txgh
4
4
  class << self
5
5
  def load_file(path)
6
6
  config = Txgh::ParseConfig.load_file(path)
7
- parse(config)
7
+ load_config(config)
8
8
  end
9
9
 
10
10
  def load(contents)
11
11
  config = Txgh::ParseConfig.load(contents)
12
- parse(config)
12
+ load_config(config)
13
13
  end
14
14
 
15
15
  private
16
16
 
17
- def parse(config)
18
- resources = []
19
- lang_map = {}
20
-
21
- config.get_groups.each do |group|
22
- if group == 'main'
23
- main = config[group]
17
+ def load_config(config)
18
+ lang_map = load_lang_map(config)
19
+ resources = load_resources(config, lang_map)
20
+ new(resources, lang_map)
21
+ end
24
22
 
25
- if main['lang_map']
26
- lang_map = parse_lang_map(main['lang_map'])
27
- end
28
- else
29
- resources.push(
30
- parse_resource(group, config[group])
31
- )
23
+ def load_lang_map(config)
24
+ lang_map = if main = config['main']
25
+ if map = main['lang_map']
26
+ parse_lang_map(map)
32
27
  end
33
28
  end
34
29
 
35
- new(resources, lang_map)
30
+ lang_map || {}
31
+ end
32
+
33
+ def load_resources(config, lang_map)
34
+ [].tap do |resources|
35
+ config.groups.each do |group|
36
+ next if group == 'main'
37
+ resources << load_resource(group, config[group], lang_map)
38
+ end
39
+ end
36
40
  end
37
41
 
38
42
  def parse_lang_map(lang_map)
@@ -42,12 +46,12 @@ module Txgh
42
46
  end
43
47
  end
44
48
 
45
- def parse_resource(name, resource)
49
+ def load_resource(name, resource, lang_map)
46
50
  id = name.split('.', 2)
47
51
  TxResource.new(
48
52
  id[0].strip, id[1].strip, resource['type'],
49
53
  resource['source_lang'], resource['source_file'],
50
- resource['lang_map'], resource['file_filter']
54
+ lang_map, resource['file_filter']
51
55
  )
52
56
  end
53
57
  end
@@ -43,7 +43,7 @@ module Txgh
43
43
  resource_hash['i18n_type'],
44
44
  resource_hash['source_language_code'],
45
45
  resource_hash['name'],
46
- '', nil
46
+ {}, nil
47
47
  )
48
48
  end
49
49
  end
@@ -12,18 +12,7 @@ module Txgh
12
12
  @type = type
13
13
  @source_lang = source_lang
14
14
  @source_file = source_file
15
- @lang_map = {}
16
-
17
- if lang_map
18
- result = {}
19
- lang_map.split(',').each do |m|
20
- key_value = m.split(':', 2)
21
- result[key_value[0].strip] = key_value[1].strip
22
- end
23
-
24
- @lang_map = result
25
- end
26
-
15
+ @lang_map = lang_map
27
16
  @translation_file = translation_file
28
17
  end
29
18
 
data/lib/txgh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '6.2.1'
2
+ VERSION = '6.2.2'
3
3
  end
@@ -10,7 +10,7 @@ describe MergeCalculator do
10
10
  let(:resource) do
11
11
  TxResource.new(
12
12
  'project_name', 'resource_slug', 'YAML',
13
- 'en', 'en.yml', '', 'translation_file'
13
+ 'en', 'en.yml', {}, 'translation_file'
14
14
  )
15
15
  end
16
16
 
@@ -7,7 +7,7 @@ describe ResourceContents do
7
7
  let(:tx_resource) do
8
8
  TxResource.new(
9
9
  'project_slug', 'resource_slug', 'YAML',
10
- 'en', 'source_file', '', 'translation_file'
10
+ 'en', 'source_file', {}, 'translation_file'
11
11
  )
12
12
  end
13
13
 
@@ -50,7 +50,7 @@ describe ResourceDownloader do
50
50
  before(:each) do
51
51
  tx_config.resources << Txgh::TxResource.new(
52
52
  project_name, "#{resource_slug}_second", 'YML',
53
- 'en', 'en.yml', '', 'translations/<lang>/sample2.yml'
53
+ 'en', 'en.yml', {}, 'translations/<lang>/sample2.yml'
54
54
  )
55
55
 
56
56
  allow(Txgh::Config::TxManager).to(
@@ -114,7 +114,7 @@ describe ResourceUpdater do
114
114
  TxBranchResource.new(
115
115
  TxResource.new(
116
116
  project_name, resource_slug, 'YAML',
117
- 'en', 'en.yml', '', 'translation_file'
117
+ 'en', 'en.yml', {}, 'translation_file'
118
118
  ),
119
119
  ref
120
120
  )
@@ -19,7 +19,7 @@ describe TxBranchResource do
19
19
  let(:base_resource) do
20
20
  TxResource.new(
21
21
  project_slug, resource_slug, 'type', 'source_lang', 'source_file',
22
- 'ko-KR:ko', 'translation_file'
22
+ { 'ko-KR' => 'ko' }, 'translation_file'
23
23
  )
24
24
  end
25
25
 
@@ -6,7 +6,7 @@ describe TxResource do
6
6
  let(:resource) do
7
7
  TxResource.new(
8
8
  'project_slug', 'resource_slug', 'type',
9
- 'source_lang', 'source_file', 'ko-KR:ko', 'translation_file/<lang>.foo'
9
+ 'source_lang', 'source_file', { 'ko-KR' => 'ko' }, 'translation_file/<lang>.foo'
10
10
  )
11
11
  end
12
12
 
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.2.1
4
+ version: 6.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Jackowski