drone-builds 0.2.8 → 0.2.9
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/drone/builds.rb +23 -3
- data/lib/drone/builds/cli.rb +4 -1
- data/lib/drone/builds/version.rb +1 -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: 495c16f3d5f8531ee5471c5a7257022dff406a01
|
4
|
+
data.tar.gz: 07e717b39c8b1d7aee0741cf2f73e1ad96861993
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b9950472c3fad4c7ecddc8d8d38755c3316a8891719dd29055a892ee85597503ed9f78d811b25f3e35e0809151dffd59595e55b58eb80ba43938e26a8b2fbe3
|
7
|
+
data.tar.gz: ae785181d44491a48154588b868363c7a2034473c7fbde40e9b1df4f5500cadafdf27b5da9456cde42e0a8606f74739f94617b7330573170e2c6bb0a0f1088ff
|
data/lib/drone/builds.rb
CHANGED
@@ -23,10 +23,14 @@ module Drone
|
|
23
23
|
json_api(builds_url).first(limit || DEFAULT_LIMIT).reverse
|
24
24
|
end
|
25
25
|
|
26
|
-
def show(id, filter: nil)
|
27
|
-
text_api(logs_url(id)).lines.each
|
26
|
+
def show(id, filter: nil, context: nil)
|
27
|
+
text_api(logs_url(id)).lines.each do |l|
|
28
|
+
yield l if show_line(l, filter: filter, context: context)
|
29
|
+
end
|
28
30
|
rescue OpenURI::HTTPError
|
29
|
-
stream_api(stream_url(id))
|
31
|
+
stream_api(stream_url(id)) do |l|
|
32
|
+
yield l if show_line(l, filter: filter, context: context)
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
private
|
@@ -79,5 +83,21 @@ module Drone
|
|
79
83
|
lines = data.lines.grep(/^data:/).map { |l| l.gsub(/^data:/, '') }
|
80
84
|
lines.map(&:strip).compact.join("\n")
|
81
85
|
end
|
86
|
+
|
87
|
+
def show_line(line, filter:, context:)
|
88
|
+
return true if filter.nil?
|
89
|
+
|
90
|
+
@count ||= 0
|
91
|
+
|
92
|
+
if line.include?(filter)
|
93
|
+
@count = context
|
94
|
+
true
|
95
|
+
elsif @count > 0
|
96
|
+
@count -= 1
|
97
|
+
true
|
98
|
+
else
|
99
|
+
false
|
100
|
+
end
|
101
|
+
end
|
82
102
|
end
|
83
103
|
end
|
data/lib/drone/builds/cli.rb
CHANGED
@@ -25,6 +25,7 @@ class Drone::Builds::Cli < Thor
|
|
25
25
|
|
26
26
|
desc 'show', 'show a build'
|
27
27
|
method_option :filter, type: :string, aliases: '-f', desc: 'filter builds output lines'
|
28
|
+
method_option :context, type: :numeric, aliases: '-c', desc: 'number of lines after filter match'
|
28
29
|
method_option :last, type: :numeric, default: 1, aliases: '-l', desc: 'show nth last build'
|
29
30
|
def show(id = nil)
|
30
31
|
if id.nil? || id == 'l' || id == 'last'
|
@@ -34,7 +35,9 @@ class Drone::Builds::Cli < Thor
|
|
34
35
|
|
35
36
|
abort 'id is required' if id.to_s.empty?
|
36
37
|
|
37
|
-
self.class.client.show(id, filter: options[:filter])
|
38
|
+
self.class.client.show(id, filter: options[:filter], context: options[:context]) do |line|
|
39
|
+
puts line
|
40
|
+
end
|
38
41
|
end
|
39
42
|
|
40
43
|
desc 'version', 'version used'
|
data/lib/drone/builds/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.9
|
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-04-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|