txgh 6.2.2 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/txgh/events.rb +4 -1
- data/lib/txgh/github_status.rb +22 -2
- data/lib/txgh/version.rb +1 -1
- data/spec/github_status_spec.rb +32 -13
- data/spec/helpers/test_events.rb +1 -0
- 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: 99faf117fe5620cfbc1a2a638aae913a2356a2a3
|
4
|
+
data.tar.gz: a1770fba3f4b541d8d3d67e4998d49f2e6be23ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba8a1e2c61446c03503125f3113eae77d8d20b7fb23eaf336e58c53ebf23fef6b8cc417cdbe0aa313f1c351f7c5106a96afeb98131934a8bd075bb61dffbb933
|
7
|
+
data.tar.gz: 667cbd4e8a81521a1bb2607cd83f8c3161c85cd71ec809f3066f496a8a0b55acf39ca6b58b9c7a1465570d0b9a90cadc1b1594095352e23cf560b0ccbd64d72e
|
data/lib/txgh/events.rb
CHANGED
@@ -14,12 +14,15 @@ module Txgh
|
|
14
14
|
|
15
15
|
def publish(channel, options = {})
|
16
16
|
channel_hash.fetch(channel, []).each do |callback|
|
17
|
-
callback.call(options)
|
17
|
+
result = callback.call(options)
|
18
|
+
yield result if block_given?
|
18
19
|
end
|
19
20
|
rescue => e
|
20
21
|
publish_error!(e)
|
21
22
|
end
|
22
23
|
|
24
|
+
alias_method :publish_each, :publish
|
25
|
+
|
23
26
|
def channels
|
24
27
|
channel_hash.keys
|
25
28
|
end
|
data/lib/txgh/github_status.rb
CHANGED
@@ -25,6 +25,10 @@ module Txgh
|
|
25
25
|
def update(project, repo, branch)
|
26
26
|
new(project, repo, branch).update
|
27
27
|
end
|
28
|
+
|
29
|
+
def error(project, repo, branch, options = {})
|
30
|
+
new(project, repo, branch).error(options)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
attr_reader :project, :repo, :branch
|
@@ -38,8 +42,6 @@ module Txgh
|
|
38
42
|
def update
|
39
43
|
return if tx_resources.empty?
|
40
44
|
|
41
|
-
sha = repo.api.get_ref(branch)[:object][:sha]
|
42
|
-
|
43
45
|
repo.api.create_status(
|
44
46
|
sha, state, {
|
45
47
|
context: context, target_url: target_url, description: description
|
@@ -47,8 +49,26 @@ module Txgh
|
|
47
49
|
)
|
48
50
|
end
|
49
51
|
|
52
|
+
def error(options = {})
|
53
|
+
repo.api.create_status(
|
54
|
+
sha, State.error, {
|
55
|
+
context: context,
|
56
|
+
target_url: options.fetch(:target_url),
|
57
|
+
description: options.fetch(:description)
|
58
|
+
}
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
50
62
|
private
|
51
63
|
|
64
|
+
def sha
|
65
|
+
ref[:object][:sha]
|
66
|
+
end
|
67
|
+
|
68
|
+
def ref
|
69
|
+
@ref ||= repo.api.get_ref(branch)
|
70
|
+
end
|
71
|
+
|
52
72
|
def context
|
53
73
|
CONTEXT
|
54
74
|
end
|
data/lib/txgh/version.rb
CHANGED
data/spec/github_status_spec.rb
CHANGED
@@ -6,12 +6,22 @@ include Txgh
|
|
6
6
|
describe GithubStatus do
|
7
7
|
include StandardTxghSetup
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
let(:status) { GithubStatus.new(transifex_project, github_repo, branch) }
|
10
|
+
let(:resource) { tx_config.resource(resource_slug) }
|
11
|
+
let(:branch) { 'heads/master' }
|
12
|
+
let(:sha) { 'abc123shashasha' }
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
allow(transifex_api).to receive(:get_resources).and_return(
|
16
|
+
[{ 'slug' => resource.resource_slug }]
|
17
|
+
)
|
18
|
+
|
19
|
+
allow(github_api).to receive(:get_ref).and_return(
|
20
|
+
object: { sha: sha }
|
21
|
+
)
|
22
|
+
end
|
14
23
|
|
24
|
+
describe '#update' do
|
15
25
|
let(:stats) do
|
16
26
|
supported_languages.each_with_object({}) do |language, ret|
|
17
27
|
ret[language] = {
|
@@ -23,14 +33,6 @@ describe GithubStatus do
|
|
23
33
|
|
24
34
|
before(:each) do
|
25
35
|
allow(transifex_api).to receive(:get_stats).and_return(stats)
|
26
|
-
|
27
|
-
allow(transifex_api).to receive(:get_resources).and_return(
|
28
|
-
[{ 'slug' => resource.resource_slug }]
|
29
|
-
)
|
30
|
-
|
31
|
-
allow(github_api).to receive(:get_ref).and_return(
|
32
|
-
object: { sha: sha }
|
33
|
-
)
|
34
36
|
end
|
35
37
|
|
36
38
|
context 'with all resources at 100%' do
|
@@ -73,4 +75,21 @@ describe GithubStatus do
|
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
78
|
+
|
79
|
+
describe '#error' do
|
80
|
+
it 'reports status as error' do
|
81
|
+
target_url = 'http://abc.foo.com'
|
82
|
+
description = 'The green albatross flitters in the moonlight'
|
83
|
+
|
84
|
+
expect(github_api).to receive(:create_status) do |commit_sha, state, options|
|
85
|
+
expect(commit_sha).to eq(sha)
|
86
|
+
expect(state).to eq(GithubStatus::State.error)
|
87
|
+
expect(options[:description]).to eq(description)
|
88
|
+
expect(options[:context]).to eq('continuous-localization/txgh')
|
89
|
+
expect(options[:target_url]).to eq(target_url)
|
90
|
+
end
|
91
|
+
|
92
|
+
status.error(target_url: target_url, description: description)
|
93
|
+
end
|
94
|
+
end
|
76
95
|
end
|
data/spec/helpers/test_events.rb
CHANGED
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.
|
4
|
+
version: 6.3.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-11-
|
12
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abroad
|