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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1053ba18e7cb566323eac1abe07004895dc151c2
4
- data.tar.gz: 50059beacd2a364ee3913309497d11d1fd028d29
3
+ metadata.gz: 99faf117fe5620cfbc1a2a638aae913a2356a2a3
4
+ data.tar.gz: a1770fba3f4b541d8d3d67e4998d49f2e6be23ed
5
5
  SHA512:
6
- metadata.gz: a22619cc53d74193888d7d57f1727e1525dc868d863f38834f6ec6ca8684cd293aaa48033a09ffb05c7676d2093606c5990bbaa7647bc35441a18147c61717ef
7
- data.tar.gz: ce6aed9c3b358dc67c912052ae7195e364aacb4c3afdde73eddc6d2bfedbc470f2a6859d8d27fb1608cc28592338f3881f63ca18edb216edb5d9f684c323bebc
6
+ metadata.gz: ba8a1e2c61446c03503125f3113eae77d8d20b7fb23eaf336e58c53ebf23fef6b8cc417cdbe0aa313f1c351f7c5106a96afeb98131934a8bd075bb61dffbb933
7
+ data.tar.gz: 667cbd4e8a81521a1bb2607cd83f8c3161c85cd71ec809f3066f496a8a0b55acf39ca6b58b9c7a1465570d0b9a90cadc1b1594095352e23cf560b0ccbd64d72e
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '6.2.2'
2
+ VERSION = '6.3.0'
3
3
  end
@@ -6,12 +6,22 @@ include Txgh
6
6
  describe GithubStatus do
7
7
  include StandardTxghSetup
8
8
 
9
- describe '#update' do
10
- let(:status) { GithubStatus.new(transifex_project, github_repo, branch) }
11
- let(:resource) { tx_config.resource(resource_slug) }
12
- let(:branch) { 'heads/master' }
13
- let(:sha) { 'abc123shashasha' }
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
@@ -8,5 +8,6 @@ class TestEvents < Txgh::Events
8
8
 
9
9
  def publish(channel, options = {})
10
10
  published << { channel: channel, options: options }
11
+ super
11
12
  end
12
13
  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.2.2
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-16 00:00:00.000000000 Z
12
+ date: 2016-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abroad