github_status_notifier 0.1.0 → 0.1.1

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: 335237a1a0833c5e40823e4901090f34bbe65721
4
- data.tar.gz: 48b915442452a5ea83ff251d7fc199db83a3f9ba
3
+ metadata.gz: b0fc8a546451c9fe69cc6fd17d98a21a5ee9e0ed
4
+ data.tar.gz: d026f96c690d4633eba50be50410e9e5999e794b
5
5
  SHA512:
6
- metadata.gz: 1508635fde07fd2b0f902ad535c7ed95cb0fa6fef817b0b2a02debbc6f5a6f00476cf21fe5f328ee5b61dfc505877b784244722eb3ce27922a9b05c63bce1fc5
7
- data.tar.gz: 706a9adce5fe43ce6c00b164031dc91066ffe334378486500d3a779f75923ad636999d0cc54e644984cfb586ba8d663b6374f17435c2ff308782b6ee5ec551d0
6
+ metadata.gz: 231c867ad4f0f81116a665ed5185345eec1f3d210a7ccf650c932924dc045a2cae9f818760704f605174b24a82ee3d86e998f6e88967351116df51513d767c9f
7
+ data.tar.gz: d7b7af9cd8e888ff66b399e571a62409552fab768cc6bf239688386ff36350f343569d7196321b82c66131265f4cae554d605cd4dad1446cfbd2341a95c2a337
data/README.md CHANGED
@@ -15,6 +15,8 @@ $ SOME_YOUR_COMMAND
15
15
  $ github-status-notifier notify --exit-status $?
16
16
  ```
17
17
 
18
+ ![GitHub Status](https://cloud.githubusercontent.com/assets/75448/6426125/d4bd4bb8-bf8c-11e4-829e-79b02bb7d6f2.png)
19
+
18
20
  ## Commands
19
21
 
20
22
  ```
@@ -32,6 +34,7 @@ Options:
32
34
  [--debug], [--no-debug]
33
35
  [--verbose], [--no-verbose]
34
36
  [--state=STATE]
37
+ # Possible values: pending, success, error, failure
35
38
  [--target-url=TARGET_URL]
36
39
  [--description=DESCRIPTION]
37
40
  [--context=CONTEXT]
@@ -18,7 +18,7 @@ module GithubStatusNotifier
18
18
  option :keep_exit_status, type: :boolean, default: false
19
19
  option :debug, type: :boolean, default: false
20
20
  option :verbose, type: :boolean, default: false
21
- option :state, type: :string
21
+ option :state, type: :string, enum: %w(pending success error failure)
22
22
  option :target_url, type: :string
23
23
  option :description, type: :string
24
24
  option :context, type: :string
@@ -13,7 +13,7 @@ module GithubStatusNotifier
13
13
  repo = Repository.new(repo_path)
14
14
  client = Client.new(repo)
15
15
  pass_params = {
16
- target_url: params[:target_url],
16
+ target_url: decide_target_url(params[:target_url]),
17
17
  description: params[:description],
18
18
  context: decide_context(params[:context])
19
19
  }
@@ -23,6 +23,35 @@ module GithubStatusNotifier
23
23
  logger.error e.backtrace
24
24
  end
25
25
 
26
+ def decide_target_url(url)
27
+ url || env_target_url
28
+ end
29
+
30
+ def env_target_url
31
+ if ENV['TARGET_URL']
32
+ ENV['TARGET_URL']
33
+ elsif ENV['TRAVIS']
34
+ build_travis_target_url
35
+ elsif ENV['CIRCLECI']
36
+ build_circle_target_url
37
+ end
38
+ end
39
+
40
+ def build_circle_target_url
41
+ host = ENV['CIRCLE_HOST'] || 'circleci.com'
42
+ link = ENV['CIRCLE_LINK'] || 'gh'
43
+ slug = ENV['CIRCLE_PROJECT_USERNAME'] + '/' + ENV['CIRCLE_PROJECT_REPONAME']
44
+ job_id = ENV['CIRCLE_BUILD_NUM']
45
+ "https://#{host}/#{link}/#{slug}/#{job_id}"
46
+ end
47
+
48
+ def build_travis_target_url
49
+ host = ENV['TRAVIS_HOST'] || 'travis-ci.org'
50
+ slug = ENV['TRAVIS_REPO_SLUG']
51
+ job_id = ENV['TRAVIS_JOB_ID']
52
+ "https://#{host}/#{slug}/jobs/#{job_id}"
53
+ end
54
+
26
55
  def decide_context(text)
27
56
  text || CONTEXT
28
57
  end
@@ -1,3 +1,3 @@
1
1
  module GithubStatusNotifier
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_status_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat