drone-builds 0.5.1 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 471826d58d4efc00b44f8b74c43926caa0ae9d1d
4
- data.tar.gz: 947de5396ef179829a15db7a938608eb05e9d02f
3
+ metadata.gz: efd545d35d71cb442a18193a7692232e412955d0
4
+ data.tar.gz: 8e2796e5cf647f811732b63225123aec8292d998
5
5
  SHA512:
6
- metadata.gz: 232e598a4e240603299eac379b7d84a0c627fdbafaca03ff4d5350dab4d5de7dd16171bc9159a14fad277e0c3229d2408ed46ae83cd382d4629ae502fcbda3e2
7
- data.tar.gz: 798be685864d37e44fe714e1b1291439bfb3587946c46b0406bf1f823bfaa31cd960352ef6654f843a97d6e473f47c47a03536a9c5df91a6e3b8f7eedf3fb4ce
6
+ metadata.gz: 5feb54622bd51340dcd65f2c37555765c20ddc3d3ad581c8903a13abc48814e6639882fad4bd0011b64af5dcc0b4e9afe0bcc0294861518be0c1b508f7b9af73
7
+ data.tar.gz: '09eb6a90c5beeebd7c0650669f3941e116a5e6993f34a521939a5bc81ebbfe042059490a82d095c14537ddfcc9cb626bae0fea18cc3cbe1318ed18d91df94a60'
data/README.md CHANGED
@@ -43,6 +43,7 @@ Options:
43
43
  # Default: 10
44
44
  -p, [--pull=N] # pull request ID on GitHub
45
45
  -b, [--branch=BRANCH] # builds on that branch
46
+ -s, [--status=STATUS] # success / failure / running / killed
46
47
 
47
48
  list last builds
48
49
  ```
@@ -60,6 +61,7 @@ Options:
60
61
  # Default: 1
61
62
  -p, [--pull=N] # show last build from pull request ID
62
63
  -b, [--branch=BRANCH] # builds on that branch
64
+ -s, [--status=STATUS] # success / failure / running / killed
63
65
 
64
66
  show a build
65
67
  ```
data/lib/drone/builds.rb CHANGED
@@ -20,8 +20,10 @@ module Drone
20
20
  @protocol = protocol || 'http'
21
21
  end
22
22
 
23
- def list(limit: nil, ref: nil)
24
- json_api(builds_url).select { |b| !ref || b['ref'] == ref }.first(limit || DEFAULT_LIMIT).reverse
23
+ def list(limit: nil, ref: nil, status: nil)
24
+ json_api(builds_url).select do |b|
25
+ (!ref || b['ref'] == ref) && (!status || b['status'] == status)
26
+ end.first(limit || DEFAULT_LIMIT).reverse
25
27
  end
26
28
 
27
29
  def show(id, filter: nil, context: nil)
@@ -18,10 +18,15 @@ class Drone::Builds::Cli < Thor
18
18
  method_option :limit, type: :numeric, default: LIMIT, aliases: '-l', desc: 'number of builds shown'
19
19
  method_option :pull, type: :numeric, aliases: '-p', desc: 'pull request ID on GitHub'
20
20
  method_option :branch, type: :string, aliases: '-b', desc: 'builds on that branch'
21
+ method_option :status, type: :string, aliases: '-s', desc: 'success / failure / running / killed'
21
22
  def list
22
23
  ref = self.class.options_to_ref(options)
23
24
 
24
- builds = self.class.parser.parse_builds(self.class.client.list(limit: options[:limit], ref: ref))
25
+ builds = self.class.parser.parse_builds(self.class.client.list(
26
+ limit: options[:limit],
27
+ ref: ref,
28
+ status: options[:status]
29
+ ))
25
30
 
26
31
  puts self.class.parser.table(builds, %i(id status ref message))
27
32
  end
@@ -32,11 +37,16 @@ class Drone::Builds::Cli < Thor
32
37
  method_option :last, type: :numeric, default: 1, aliases: '-l', desc: 'show nth last build'
33
38
  method_option :pull, type: :numeric, aliases: '-p', desc: 'show last build from pull request ID'
34
39
  method_option :branch, type: :string, aliases: '-b', desc: 'builds on that branch'
40
+ method_option :status, type: :string, aliases: '-s', desc: 'success / failure / running / killed'
35
41
  def show(id = nil)
36
42
  ref = self.class.options_to_ref(options)
37
43
 
38
44
  if id.to_i.to_s != id
39
- id = self.class.client.list(limit: options[:last]&.abs, ref: ref)[0]&.[]('id')
45
+ id = self.class.client.list(
46
+ limit: options[:last]&.abs,
47
+ ref: ref,
48
+ status: options[:status]
49
+ )[0]&.[]('id')
40
50
  end
41
51
 
42
52
  abort "No build found for options: #{options}" unless id
@@ -1,5 +1,5 @@
1
1
  module Drone
2
2
  class Builds
3
- VERSION = '0.5.1'.freeze
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drone-builds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-04 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize