txgh 1.1.0 → 2.0.0
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 +4 -4
- data/lib/txgh/handlers/download_handler.rb +4 -1
- data/lib/txgh/handlers/transifex/hook_handler.rb +29 -12
- data/lib/txgh/handlers/triggers/pull_handler.rb +2 -0
- data/lib/txgh/transifex_project.rb +8 -0
- data/lib/txgh/version.rb +1 -1
- data/spec/app_spec.rb +1 -0
- data/spec/handlers/download_handler_spec.rb +10 -0
- data/spec/handlers/transifex/hook_handler_spec.rb +13 -0
- data/spec/helpers/standard_txgh_setup.rb +3 -1
- data/spec/integration/hooks_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 083d15ac3686b54241f76f3cf7da05783ed9b189
|
|
4
|
+
data.tar.gz: 42bbf8c31844b25f9c05a74701a6625980d3e7ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4117c59c816d16878946db1cc5451dfd822c7386c8347d11b952c8e68c620cf88d98ed5360f04752c781621dece4bcb9507debef086a682f38cb31baca14c391
|
|
7
|
+
data.tar.gz: d24d9cad4af2d0d8ee8bdf3f8a93f681650e535184d1f25a8d0e29818f7de86cc41751ab9927243de2ab04dd0406a14abc514e691c4059aab116c710690ebc5e
|
|
@@ -54,7 +54,10 @@ module Txgh
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def execute
|
|
57
|
-
downloader = ResourceDownloader.new(
|
|
57
|
+
downloader = ResourceDownloader.new(
|
|
58
|
+
project, repo, params['branch'], languages: project.languages
|
|
59
|
+
)
|
|
60
|
+
|
|
58
61
|
response_class.new(attachment, downloader.each)
|
|
59
62
|
end
|
|
60
63
|
|
|
@@ -20,25 +20,38 @@ module Txgh
|
|
|
20
20
|
def execute
|
|
21
21
|
logger.info(resource_slug)
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
check_error_response || begin
|
|
24
|
+
committer = ResourceCommitter.new(project, repo, logger)
|
|
25
|
+
committer.commit_resource(tx_resource, branch, language)
|
|
26
|
+
respond_with(200, true)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def check_error_response
|
|
33
|
+
check_supported_language || check_tx_config || check_tx_resource
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def check_supported_language
|
|
37
|
+
respond_with(304, true) unless supported_language?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def check_tx_config
|
|
41
|
+
unless tx_config
|
|
35
42
|
respond_with_error(
|
|
36
43
|
404, "Could not find configuration for branch '#{branch}'"
|
|
37
44
|
)
|
|
38
45
|
end
|
|
39
46
|
end
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
def check_tx_resource
|
|
49
|
+
unless tx_resource
|
|
50
|
+
respond_with_error(
|
|
51
|
+
404, "Could not find resource '#{resource_slug}' in config"
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
42
55
|
|
|
43
56
|
def tx_config
|
|
44
57
|
@tx_config ||= Txgh::Config::TxManager.tx_config(project, repo, branch)
|
|
@@ -71,6 +84,10 @@ module Txgh
|
|
|
71
84
|
def process_all_branches?
|
|
72
85
|
repo.process_all_branches?
|
|
73
86
|
end
|
|
87
|
+
|
|
88
|
+
def supported_language?
|
|
89
|
+
project.supported_language?(language)
|
|
90
|
+
end
|
|
74
91
|
end
|
|
75
92
|
end
|
|
76
93
|
end
|
data/lib/txgh/version.rb
CHANGED
data/spec/app_spec.rb
CHANGED
|
@@ -310,6 +310,7 @@ describe Txgh::Triggers do
|
|
|
310
310
|
it 'updates translations (in all locales) in the expected repo' do
|
|
311
311
|
committer = double(:committer)
|
|
312
312
|
languages = [{ 'language_code' => 'pt' }, { 'language_code' => 'ja' }]
|
|
313
|
+
project_config['languages'] = %w(pt ja)
|
|
313
314
|
expect(Txgh::ResourceCommitter).to receive(:new).and_return(committer)
|
|
314
315
|
expect(Txgh::TransifexApi).to receive(:new).and_return(transifex_api)
|
|
315
316
|
expect(transifex_api).to receive(:get_languages).and_return(languages)
|
|
@@ -77,5 +77,15 @@ describe DownloadHandler do
|
|
|
77
77
|
expect(handler.execute).to be_a(TgzStreamResponse)
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
|
+
|
|
81
|
+
context 'with a set of languages' do
|
|
82
|
+
let(:supported_languages) { %w(is fr) }
|
|
83
|
+
|
|
84
|
+
it "downloads translations for the project's supported languages" do
|
|
85
|
+
allow(transifex_api).to receive(:download)
|
|
86
|
+
files = handler.execute.enum.to_a.map(&:first)
|
|
87
|
+
expect(files).to eq(%w(translations/is/sample.yml translations/fr/sample.yml))
|
|
88
|
+
end
|
|
89
|
+
end
|
|
80
90
|
end
|
|
81
91
|
end
|
|
@@ -112,4 +112,17 @@ describe HookHandler do
|
|
|
112
112
|
expect(response.body).to eq(true)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
|
+
|
|
116
|
+
context 'with an unsupported language' do
|
|
117
|
+
let(:language) { 'pt' }
|
|
118
|
+
let(:supported_languages) { ['ja'] }
|
|
119
|
+
|
|
120
|
+
it "doesn't make a commit" do
|
|
121
|
+
expect(github_api).to_not receive(:commit)
|
|
122
|
+
|
|
123
|
+
response = handler.execute
|
|
124
|
+
expect(response.status).to eq(304)
|
|
125
|
+
expect(response.body).to eq(true)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
115
128
|
end
|
|
@@ -15,6 +15,7 @@ module StandardTxghSetup
|
|
|
15
15
|
let(:tag) { 'all' }
|
|
16
16
|
let(:ref) { 'heads/master' }
|
|
17
17
|
let(:language) { 'ko_KR' }
|
|
18
|
+
let(:supported_languages) { [language] }
|
|
18
19
|
let(:translations) { 'translation file contents' }
|
|
19
20
|
let(:diff_point) { nil }
|
|
20
21
|
|
|
@@ -26,7 +27,8 @@ module StandardTxghSetup
|
|
|
26
27
|
'name' => project_name,
|
|
27
28
|
'tx_config' => "raw://#{tx_config_raw}",
|
|
28
29
|
'webhook_secret' => 'abc123',
|
|
29
|
-
'auto_delete_resources' => 'true'
|
|
30
|
+
'auto_delete_resources' => 'true',
|
|
31
|
+
'languages' => supported_languages
|
|
30
32
|
}
|
|
31
33
|
end
|
|
32
34
|
|
|
@@ -45,7 +45,8 @@ describe 'hook integration tests', integration: true do
|
|
|
45
45
|
'api_username' => 'txgh.bot',
|
|
46
46
|
'api_password' => '2aqFGW99fPRKWvXBPjbrxkdiR',
|
|
47
47
|
'push_translations_to' => 'txgh-bot/txgh-test-resources',
|
|
48
|
-
'webhook_secret' => 'fce95b1748fd638c22174d34200f10cf'
|
|
48
|
+
'webhook_secret' => 'fce95b1748fd638c22174d34200f10cf',
|
|
49
|
+
'languages' => ['el_GR']
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
}
|
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:
|
|
4
|
+
version: 2.0.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: 2016-04-
|
|
12
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: abroad
|