txgh 6.1.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4214fc0aed73a268ba39c70ddc665ddee94b3be2
4
- data.tar.gz: 20ffbec32c8d965b1380a89de2bc8f40bfba3a55
3
+ metadata.gz: 4bb912342a3ab872d5d346aa7d5aaf772028e579
4
+ data.tar.gz: e75989c9cd6bf3ae01d72d6aee86a060ba5ce177
5
5
  SHA512:
6
- metadata.gz: c4164c9d888d4b3af5c9d5f3b91f2a3d0ae688cd19b422119dfef2003ff57ba0817afa69cacbcc2bb00d126704d8807b29a38a1593073520d09d960391052483
7
- data.tar.gz: d0faaa542a3c471f2f61b7e93ca31f208a89d155d169202f581c283c70407771d000f93438fd824d2e3db55b5f7c78a956f0298fcdfe55144f185e1994cb9c24
6
+ metadata.gz: d2182c6060eee76d2935b1d897a695bdc619ed5c4abb48a0dc065daae06fe50e670fb5fb74a61de4ec3d677d9ae1c0183bf926f396019234c273e89543355178
7
+ data.tar.gz: b59b80fd0d0960cfadcbd67d6a003d5aaea27a576269b46e87818a71057914558be39cfe33648ada16da33197c9e86ab6504a23b53978b4c4a93d3113e915ff3
@@ -1,3 +1,5 @@
1
+ require 'octokit'
2
+
1
3
  module Txgh
2
4
  class ResourceDownloader
3
5
  include Enumerable
@@ -97,11 +99,15 @@ module Txgh
97
99
  def transifex_download(resource, language)
98
100
  transifex_api.download(resource, language)
99
101
  rescue TransifexNotFoundError
102
+ # return nil here so wrap() will return an instance of EmptyResourceContents
100
103
  nil
101
104
  end
102
105
 
103
106
  def git_download(resource, branch)
104
107
  repo.api.download(resource.source_file, branch)[:content]
108
+ rescue Octokit::NotFound
109
+ # return nil here so wrap() will return an instance of EmptyResourceContents
110
+ nil
105
111
  end
106
112
 
107
113
  def transifex_api
@@ -123,13 +129,7 @@ module Txgh
123
129
  return to_enum(__method__) unless block_given?
124
130
  return @languages.each(&block) if @languages
125
131
 
126
- raw_languages.each(&block)
127
- end
128
-
129
- def raw_languages
130
- @raw_languages ||= transifex_api.get_languages(project.name).map do |lang|
131
- lang['language_code']
132
- end
132
+ project.languages.each(&block)
133
133
  end
134
134
 
135
135
  def tx_config
data/lib/txgh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '6.1.1'
2
+ VERSION = '6.1.2'
3
3
  end
@@ -7,7 +7,7 @@ include Txgh
7
7
  describe ResourceDownloader do
8
8
  include StandardTxghSetup
9
9
 
10
- let(:api_languages) { %w(es de ja) }
10
+ let(:supported_languages) { %w(es de ja) }
11
11
  let(:format) { '.zip' }
12
12
 
13
13
  let(:downloader) do
@@ -15,14 +15,6 @@ describe ResourceDownloader do
15
15
  end
16
16
 
17
17
  before(:each) do
18
- allow(transifex_api).to(
19
- receive(:get_languages).with(project_name).and_return(
20
- api_languages.map do |language_code|
21
- { 'language_code' => language_code }
22
- end
23
- )
24
- )
25
-
26
18
  allow(transifex_api).to(
27
19
  receive(:download) do |resource, language|
28
20
  translations_for(resource, language)
@@ -44,7 +36,7 @@ describe ResourceDownloader do
44
36
 
45
37
  it 'downloads the resource in all languages' do
46
38
  expect(downloader.each.to_a).to eq(
47
- api_languages.map do |language|
39
+ supported_languages.map do |language|
48
40
  [
49
41
  "translations/#{language}/sample.yml",
50
42
  translations_for(resource, language)
@@ -73,14 +65,14 @@ describe ResourceDownloader do
73
65
  resource = tx_config.resource(resource_slug)
74
66
  actual_results = downloader.each.to_a
75
67
 
76
- expected_results = api_languages.map do |language|
68
+ expected_results = supported_languages.map do |language|
77
69
  [
78
70
  "translations/#{language}/sample.yml",
79
71
  translations_for(resource, language)
80
72
  ]
81
73
  end
82
74
 
83
- expected_results += api_languages.map do |language|
75
+ expected_results += supported_languages.map do |language|
84
76
  [
85
77
  "translations/#{language}/sample2.yml",
86
78
  translations_for(resource, language)
@@ -130,7 +122,7 @@ describe ResourceDownloader do
130
122
  end
131
123
 
132
124
  def translations_for(resource, language)
133
- branch = resource.respond_to?(:branch) ? resource.branch : nil
125
+ branch = resource.has_branch? ? resource.branch : nil
134
126
 
135
127
  if branch == diff_point
136
128
  diff_point_translations_for(language)
@@ -162,7 +154,7 @@ describe ResourceDownloader do
162
154
  it 'merges the head and diff point strings together' do
163
155
  # picard unmodified, janeway modified, sisko added, sulu removed
164
156
  expect(downloader.each.to_a).to eq(
165
- api_languages.map do |language|
157
+ supported_languages.map do |language|
166
158
  [
167
159
  "translations/#{language}/sample.yml",
168
160
  outdent(%Q{
@@ -189,7 +181,7 @@ describe ResourceDownloader do
189
181
 
190
182
  results = downloader.each.to_a
191
183
  expect(results).to eq(
192
- api_languages.map do |language|
184
+ supported_languages.map do |language|
193
185
  [
194
186
  "translations/#{language}/sample.yml",
195
187
  outdent(%Q{
@@ -201,5 +193,33 @@ describe ResourceDownloader do
201
193
  end
202
194
  )
203
195
  end
196
+
197
+ it "works even if the file doesn't exist in the git repo" do
198
+ allow(github_api).to(
199
+ receive(:download) do |path, branch|
200
+ if branch == 'heads/master'
201
+ raise Octokit::NotFound
202
+ else
203
+ { content: head_source_for(branch) }
204
+ end
205
+ end
206
+ )
207
+
208
+ results = downloader.each.to_a
209
+ expect(results).to eq(
210
+ supported_languages.map do |language|
211
+ [
212
+ "translations/#{language}/sample.yml",
213
+ outdent(%Q{
214
+ #{language}:
215
+ picard: "enterprise (head trans)"
216
+ janeway: "uss voyager (head trans)"
217
+ sulu: "excelsior (dp trans)"
218
+ sisko: "deep space nine (head trans)"
219
+ })
220
+ ]
221
+ end
222
+ )
223
+ end
204
224
  end
205
225
  end
data/spec/utils_spec.rb CHANGED
@@ -98,48 +98,4 @@ describe Utils do
98
98
  expect(Utils.booleanize(false)).to eq(false)
99
99
  end
100
100
  end
101
-
102
- describe '.deep_symbolize_keys' do
103
- it 'symbolizes keys in a hash with depth 1' do
104
- hash = { 'abc' => 'def', ghi: 'jkl' }
105
- expect(Utils.deep_symbolize_keys(hash)).to eq(
106
- { abc: 'def', ghi: 'jkl' }
107
- )
108
- end
109
-
110
- it 'symbolizes keys in a hash with depth 2' do
111
- hash = { 'abc' => { 'def' => 'ghi' } }
112
- expect(Utils.deep_symbolize_keys(hash)).to eq(
113
- { abc: { def: 'ghi' } }
114
- )
115
- end
116
-
117
- it 'symbolizes keys in a hash with depth 3' do
118
- hash = { 'abc' => { 'def' => { 'ghi' => 'jkl' }, 'mno' => 'pqr' } }
119
- expect(Utils.deep_symbolize_keys(hash)).to eq(
120
- { abc: { def: { ghi: 'jkl' }, mno: 'pqr' } }
121
- )
122
- end
123
-
124
- it 'symbolizes hash keys in an array' do
125
- array = [{ 'def' => 'ghi' }]
126
- expect(Utils.deep_symbolize_keys(array)).to eq(
127
- [{ def: 'ghi' }]
128
- )
129
- end
130
-
131
- it 'symbolizes keys nested inside arrays' do
132
- hash = { 'abc' => [{ 'def' => 'ghi' }] }
133
- expect(Utils.deep_symbolize_keys(hash)).to eq(
134
- { abc: [{ def: 'ghi' }] }
135
- )
136
- end
137
-
138
- it "doesn't modify objects that aren't hashes" do
139
- hash = { 'abc' => Set.new(%w(a b c)) }
140
- expect(Utils.deep_symbolize_keys(hash)).to eq(
141
- { abc: hash['abc'] }
142
- )
143
- end
144
- end
145
101
  end
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.1.1
4
+ version: 6.1.2
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-10-08 00:00:00.000000000 Z
12
+ date: 2016-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abroad