circler 0.6.0 → 0.6.1
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/Gemfile.lock +37 -23
- data/README.md +2 -2
- data/Rakefile +3 -3
- data/bin/circle +1 -1
- data/bin/console +3 -3
- data/circler.gemspec +36 -24
- data/exe/circle +1 -1
- data/lib/circler/cli.rb +2 -2
- data/lib/circler/command/base_command.rb +9 -4
- data/lib/circler/command/browse_command.rb +1 -1
- data/lib/circler/command/builds_command.rb +7 -6
- data/lib/circler/command/cancel_command.rb +1 -1
- data/lib/circler/command/projects_command.rb +1 -1
- data/lib/circler/command/retry_command.rb +2 -2
- data/lib/circler/command/watch_command.rb +23 -34
- data/lib/circler/networking/pusher_client.rb +7 -1
- data/lib/circler/printer/build_printer.rb +34 -17
- data/lib/circler/printer/project_printer.rb +21 -11
- data/lib/circler/printer/step_printer.rb +21 -21
- data/lib/circler/response/action.rb +2 -2
- data/lib/circler/response/build.rb +14 -18
- data/lib/circler/response/step.rb +1 -1
- data/lib/circler/version.rb +1 -1
- metadata +24 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 911139590b6993d3e20d1617a4a075205846ef5d
|
|
4
|
+
data.tar.gz: 65679b7ae60bddf899dd63bb96e35bd702db7cde
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3e827801221bdcecd1e8211545385a79d27093e2346baacc4daf28f2e2e8a8915582f108a8f301a04c62d10367474d348a087224e1973157a179a31819233bb
|
|
7
|
+
data.tar.gz: a396a9550c1f72bb5f88e7227b567d3afbcc6d5ac064b2d259aefb80cf88d8fbe54fbb73859fd0dc4ba6e3595b2a66a6b037abdc10952d8aa4e99329401a324e
|
data/Gemfile.lock
CHANGED
|
@@ -1,55 +1,68 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
circler (0.6.
|
|
5
|
-
circleci (~> 1.0
|
|
4
|
+
circler (0.6.1)
|
|
5
|
+
circleci (~> 1.1.0)
|
|
6
6
|
colorize (~> 0.8.1)
|
|
7
|
-
faraday (~> 0.
|
|
7
|
+
faraday (~> 0.12.0)
|
|
8
8
|
highline (~> 1.7.8)
|
|
9
9
|
launchy (~> 2.4.3)
|
|
10
10
|
pusher-client (~> 0.6.2)
|
|
11
11
|
rugged (~> 0.25.1.1)
|
|
12
|
-
terminal-notifier (~> 1.
|
|
13
|
-
terminal-table (~> 1.
|
|
12
|
+
terminal-notifier (~> 1.8.0)
|
|
13
|
+
terminal-table (~> 1.8.0)
|
|
14
14
|
thor (~> 0.19.4)
|
|
15
15
|
|
|
16
16
|
GEM
|
|
17
17
|
remote: https://rubygems.org/
|
|
18
18
|
specs:
|
|
19
|
-
addressable (2.5.
|
|
19
|
+
addressable (2.5.1)
|
|
20
20
|
public_suffix (~> 2.0, >= 2.0.2)
|
|
21
|
-
|
|
21
|
+
ast (2.3.0)
|
|
22
|
+
circleci (1.1.0)
|
|
22
23
|
colorize (0.8.1)
|
|
23
24
|
diff-lcs (1.3)
|
|
24
|
-
faraday (0.
|
|
25
|
+
faraday (0.12.2)
|
|
25
26
|
multipart-post (>= 1.2, < 3)
|
|
26
27
|
highline (1.7.8)
|
|
27
|
-
json (2.0
|
|
28
|
+
json (2.1.0)
|
|
28
29
|
launchy (2.4.3)
|
|
29
30
|
addressable (~> 2.3)
|
|
30
31
|
multipart-post (2.0.0)
|
|
32
|
+
parser (2.4.0.0)
|
|
33
|
+
ast (~> 2.2)
|
|
34
|
+
powerpack (0.1.1)
|
|
31
35
|
public_suffix (2.0.5)
|
|
32
36
|
pusher-client (0.6.2)
|
|
33
37
|
json
|
|
34
38
|
websocket (~> 1.0)
|
|
39
|
+
rainbow (2.2.2)
|
|
40
|
+
rake
|
|
35
41
|
rake (12.0.0)
|
|
36
|
-
rspec (3.
|
|
37
|
-
rspec-core (~> 3.
|
|
38
|
-
rspec-expectations (~> 3.
|
|
39
|
-
rspec-mocks (~> 3.
|
|
40
|
-
rspec-core (3.
|
|
41
|
-
rspec-support (~> 3.
|
|
42
|
-
rspec-expectations (3.
|
|
42
|
+
rspec (3.6.0)
|
|
43
|
+
rspec-core (~> 3.6.0)
|
|
44
|
+
rspec-expectations (~> 3.6.0)
|
|
45
|
+
rspec-mocks (~> 3.6.0)
|
|
46
|
+
rspec-core (3.6.0)
|
|
47
|
+
rspec-support (~> 3.6.0)
|
|
48
|
+
rspec-expectations (3.6.0)
|
|
43
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
-
rspec-support (~> 3.
|
|
45
|
-
rspec-mocks (3.
|
|
50
|
+
rspec-support (~> 3.6.0)
|
|
51
|
+
rspec-mocks (3.6.0)
|
|
46
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
-
rspec-support (~> 3.
|
|
48
|
-
rspec-support (3.
|
|
53
|
+
rspec-support (~> 3.6.0)
|
|
54
|
+
rspec-support (3.6.0)
|
|
55
|
+
rubocop (0.47.1)
|
|
56
|
+
parser (>= 2.3.3.1, < 3.0)
|
|
57
|
+
powerpack (~> 0.1)
|
|
58
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
59
|
+
ruby-progressbar (~> 1.7)
|
|
60
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
61
|
+
ruby-progressbar (1.8.1)
|
|
49
62
|
rugged (0.25.1.1)
|
|
50
|
-
terminal-notifier (1.
|
|
51
|
-
terminal-table (1.
|
|
52
|
-
unicode-display_width (~> 1.1.1)
|
|
63
|
+
terminal-notifier (1.8.0)
|
|
64
|
+
terminal-table (1.8.0)
|
|
65
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
53
66
|
thor (0.19.4)
|
|
54
67
|
unicode-display_width (1.1.3)
|
|
55
68
|
websocket (1.2.4)
|
|
@@ -62,6 +75,7 @@ DEPENDENCIES
|
|
|
62
75
|
circler!
|
|
63
76
|
rake
|
|
64
77
|
rspec
|
|
78
|
+
rubocop (~> 0.47.1)
|
|
65
79
|
|
|
66
80
|
BUNDLED WITH
|
|
67
81
|
1.12.5
|
data/README.md
CHANGED
|
@@ -28,9 +28,9 @@ Commands:
|
|
|
28
28
|
circle browse # open circle ci website
|
|
29
29
|
circle build # show build description
|
|
30
30
|
circle builds # list builds
|
|
31
|
-
circle help [COMMAND] #
|
|
31
|
+
circle help [COMMAND] # describe available commands or one specific command
|
|
32
32
|
circle projects # list projects
|
|
33
|
-
circle retry #
|
|
33
|
+
circle retry # retry a build
|
|
34
34
|
circle version # show gem version
|
|
35
35
|
circle watch # watch a build in real time
|
|
36
36
|
|
data/Rakefile
CHANGED
data/bin/circle
CHANGED
data/bin/console
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'circler'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +10,5 @@ require "circler"
|
|
|
10
10
|
# require "pry"
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start
|
data/circler.gemspec
CHANGED
|
@@ -3,35 +3,47 @@ lib = File.expand_path('../lib', __FILE__)
|
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'circler/version'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
spec.name = "circler"
|
|
8
|
-
spec.version = Circler::VERSION
|
|
9
|
-
spec.authors = ["unhappychoice"]
|
|
10
|
-
spec.email = ["unhappychoice@gmail.com"]
|
|
11
|
-
|
|
12
|
-
spec.summary = %q{CLI tool for CircleCI}
|
|
13
|
-
spec.description = %q{A command line tool for CircleCI}
|
|
14
|
-
spec.homepage = "https://github.com/unhappychoice/circler"
|
|
15
|
-
spec.license = "MIT"
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
-
spec.bindir = "exe"
|
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
-
spec.require_paths = ["lib"]
|
|
20
|
-
|
|
21
|
-
# Production
|
|
6
|
+
def production_dependency(spec)
|
|
22
7
|
spec.add_dependency 'pusher-client', '~> 0.6.2'
|
|
23
8
|
spec.add_dependency 'thor', '~> 0.19.4'
|
|
24
|
-
spec.add_dependency 'faraday', '~> 0.
|
|
9
|
+
spec.add_dependency 'faraday', '~> 0.12.0'
|
|
25
10
|
spec.add_dependency 'launchy', '~> 2.4.3'
|
|
26
|
-
spec.add_dependency 'circleci', '~> 1.0
|
|
11
|
+
spec.add_dependency 'circleci', '~> 1.1.0'
|
|
27
12
|
spec.add_dependency 'rugged', '~> 0.25.1.1'
|
|
28
|
-
spec.add_dependency 'terminal-table', '~> 1.
|
|
13
|
+
spec.add_dependency 'terminal-table', '~> 1.8.0'
|
|
29
14
|
spec.add_dependency 'highline', '~> 1.7.8'
|
|
30
15
|
spec.add_dependency 'colorize', '~> 0.8.1'
|
|
31
|
-
spec.add_dependency 'terminal-notifier', '~> 1.
|
|
16
|
+
spec.add_dependency 'terminal-notifier', '~> 1.8.0'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def development_dependency(spec)
|
|
20
|
+
spec.add_development_dependency 'bundler'
|
|
21
|
+
spec.add_development_dependency 'rake'
|
|
22
|
+
spec.add_development_dependency 'rspec'
|
|
23
|
+
spec.add_development_dependency 'rubocop', '~> 0.47.1'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def project_files
|
|
27
|
+
`git ls-files -z`
|
|
28
|
+
.split("\x0")
|
|
29
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Gem::Specification.new do |spec|
|
|
33
|
+
spec.name = 'circler'
|
|
34
|
+
spec.version = Circler::VERSION
|
|
35
|
+
spec.authors = ['unhappychoice']
|
|
36
|
+
spec.email = ['unhappychoice@gmail.com']
|
|
37
|
+
|
|
38
|
+
spec.summary = 'CLI tool for CircleCI'
|
|
39
|
+
spec.description = 'A command line tool for CircleCI'
|
|
40
|
+
spec.homepage = 'https://github.com/unhappychoice/circler'
|
|
41
|
+
spec.license = 'MIT'
|
|
42
|
+
spec.files = project_files
|
|
43
|
+
spec.bindir = 'exe'
|
|
44
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
45
|
+
spec.require_paths = ['lib']
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
spec
|
|
35
|
-
spec.add_development_dependency "rake"
|
|
36
|
-
spec.add_development_dependency "rspec"
|
|
47
|
+
production_dependency spec
|
|
48
|
+
development_dependency spec
|
|
37
49
|
end
|
data/exe/circle
CHANGED
data/lib/circler/cli.rb
CHANGED
|
@@ -30,7 +30,7 @@ require 'circler/networking/pusher_client'
|
|
|
30
30
|
module Circler
|
|
31
31
|
class CLI < Thor
|
|
32
32
|
desc 'projects', 'list projects'
|
|
33
|
-
method_option :format, aliases: 'f', type: :string, banner: 'pretty/simple'
|
|
33
|
+
method_option :format, aliases: 'f', type: :string, banner: 'pretty/simple'
|
|
34
34
|
def projects
|
|
35
35
|
ProjectsCommand.run(options)
|
|
36
36
|
end
|
|
@@ -38,7 +38,7 @@ module Circler
|
|
|
38
38
|
desc 'builds', 'list builds'
|
|
39
39
|
method_option :project, aliases: 'p', type: :string, banner: 'user/project'
|
|
40
40
|
method_option :branch, aliases: 'b', type: :string, banner: 'some-branch'
|
|
41
|
-
method_option :format, aliases: 'f', type: :string, banner: 'pretty/simple'
|
|
41
|
+
method_option :format, aliases: 'f', type: :string, banner: 'pretty/simple'
|
|
42
42
|
def builds
|
|
43
43
|
BuildsCommand.run(options)
|
|
44
44
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Circler
|
|
2
2
|
class BaseCommand
|
|
3
3
|
class << self
|
|
4
|
-
def setup_token
|
|
4
|
+
def setup_token
|
|
5
5
|
CircleCi.configure do |config|
|
|
6
6
|
config.token = ENV['CIRCLE_CI_TOKEN'] || ask('Circle CI token ? :')
|
|
7
7
|
end
|
|
@@ -10,8 +10,8 @@ module Circler
|
|
|
10
10
|
def project_name(options)
|
|
11
11
|
if options.project
|
|
12
12
|
options.project
|
|
13
|
-
elsif
|
|
14
|
-
|
|
13
|
+
elsif reponame
|
|
14
|
+
reponame
|
|
15
15
|
else
|
|
16
16
|
say ProjectPrinter.new(Project.all)
|
|
17
17
|
ask('Input user-name/project-name :')
|
|
@@ -21,13 +21,18 @@ module Circler
|
|
|
21
21
|
def reponame
|
|
22
22
|
repository = Rugged::Repository.new('.')
|
|
23
23
|
origin = repository.remotes.find { |r| r.name == 'origin' }
|
|
24
|
-
|
|
24
|
+
regexp = %r{git@github.com(?::|/)([\w_-]+/[\w_-]+)(?:\.git)*}
|
|
25
|
+
return Regexp.last_match(1) if origin.url =~ regexp
|
|
25
26
|
nil
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def build_number(options)
|
|
29
30
|
options.build || ask('Input build number')
|
|
30
31
|
end
|
|
32
|
+
|
|
33
|
+
def should_be_pretty(options)
|
|
34
|
+
options['format'] != 'simple'
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
end
|
|
33
38
|
end
|
|
@@ -5,13 +5,14 @@ module Circler
|
|
|
5
5
|
setup_token
|
|
6
6
|
username, reponame = project_name(options).split('/')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
builds =
|
|
9
|
+
if options.branch
|
|
10
|
+
Build.branch(username, reponame, options.branch)
|
|
11
|
+
else
|
|
12
|
+
Build.all(username, reponame)
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
say BuildPrinter.new(builds,
|
|
15
|
+
say BuildPrinter.new(builds, pretty: should_be_pretty(options))
|
|
15
16
|
end
|
|
16
17
|
end
|
|
17
18
|
end
|
|
@@ -7,7 +7,7 @@ module Circler
|
|
|
7
7
|
number = build_number(options)
|
|
8
8
|
build = Build.cancel(username, reponame, number)
|
|
9
9
|
if build.username
|
|
10
|
-
say "build #{build.
|
|
10
|
+
say "build #{build.project_name} #{build.build_number} is canceled."
|
|
11
11
|
else
|
|
12
12
|
say "failed to cancel #{username}/#{reponame} #{number}."
|
|
13
13
|
end
|
|
@@ -7,9 +7,9 @@ module Circler
|
|
|
7
7
|
number = build_number(options)
|
|
8
8
|
build = Build.retry(username, reponame, number)
|
|
9
9
|
if build.username
|
|
10
|
-
say "build #{
|
|
10
|
+
say "build #{username}/#{reponame} #{build.build_number} is triggered"
|
|
11
11
|
else
|
|
12
|
-
say "failed to trigger #{username}/#{reponame} #{number}
|
|
12
|
+
say "failed to trigger #{username}/#{reponame} #{number}"
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -3,14 +3,11 @@ module Circler
|
|
|
3
3
|
class << self
|
|
4
4
|
def run(options)
|
|
5
5
|
setup_token
|
|
6
|
+
setup_client
|
|
6
7
|
|
|
7
8
|
build = get_build(options)
|
|
8
9
|
|
|
9
|
-
if
|
|
10
|
-
say 'Connecting to pusher'.blue
|
|
11
|
-
setup_client
|
|
12
|
-
say 'Connected'.blue
|
|
13
|
-
|
|
10
|
+
if build && build.running?
|
|
14
11
|
start_watch(build)
|
|
15
12
|
wait_until_finish
|
|
16
13
|
finalize(build, build.channel_name)
|
|
@@ -21,61 +18,53 @@ module Circler
|
|
|
21
18
|
|
|
22
19
|
private
|
|
23
20
|
|
|
24
|
-
def setup_client
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
def setup_client
|
|
22
|
+
@client = CirclerPusherClient.new
|
|
23
|
+
@client.connect
|
|
27
24
|
end
|
|
28
25
|
|
|
29
26
|
def get_build(options)
|
|
30
27
|
username, reponame = project_name(options).split('/')
|
|
31
|
-
number = build_number
|
|
28
|
+
number = build_number options
|
|
32
29
|
Build.get(username, reponame, number)
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
def start_watch(build)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
@running = true
|
|
34
|
+
text = "Start watching #{build.project_name} ##{build.build_number}"
|
|
35
|
+
print_bordered text
|
|
36
|
+
TerminalNotifier.notify text
|
|
39
37
|
|
|
40
|
-
bind_event_handling
|
|
38
|
+
bind_event_handling build.channel_name
|
|
41
39
|
end
|
|
42
40
|
|
|
43
41
|
def bind_event_handling(channel)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
print_bordered d['log']['name'].green
|
|
47
|
-
end
|
|
42
|
+
@client.bind_event_json(channel, 'newAction') do |json|
|
|
43
|
+
print_bordered json['log']['name'].green
|
|
48
44
|
end
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
@client.bind_event_json(channel, 'appendAction') do |json|
|
|
47
|
+
say json['out']['message']
|
|
52
48
|
end
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@@running = d['log']['name'] != 'Disable SSH'
|
|
57
|
-
end
|
|
50
|
+
@client.bind_event_json(channel, 'updateAction') do |json|
|
|
51
|
+
@running = json['log']['name'] != 'Disable SSH'
|
|
58
52
|
end
|
|
59
53
|
end
|
|
60
54
|
|
|
61
55
|
def wait_until_finish
|
|
62
|
-
while
|
|
63
|
-
sleep(1)
|
|
64
|
-
end
|
|
56
|
+
sleep(1) while @running
|
|
65
57
|
end
|
|
66
58
|
|
|
67
59
|
def finalize(build, channel)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
print_bordered
|
|
71
|
-
TerminalNotifier.notify
|
|
60
|
+
@client.unsubscribe(channel)
|
|
61
|
+
text = "Finish watching #{build.project_name} ##{build.build_number}"
|
|
62
|
+
print_bordered text.blue
|
|
63
|
+
TerminalNotifier.notify text
|
|
72
64
|
end
|
|
73
65
|
|
|
74
66
|
def print_bordered(text)
|
|
75
|
-
say Terminal::Table.new(
|
|
76
|
-
rows: [[text]],
|
|
77
|
-
style: { width: 120 }
|
|
78
|
-
).to_s
|
|
67
|
+
say Terminal::Table.new(rows: [[text]], style: { width: 120 }).to_s
|
|
79
68
|
end
|
|
80
69
|
end
|
|
81
70
|
end
|
|
@@ -14,6 +14,12 @@ class CirclerPusherClient
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def bind_event_json(channel, event)
|
|
18
|
+
bind(channel, event) do |data|
|
|
19
|
+
JSON.parse(data).each { |json| yield(json) }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
17
23
|
def unsubscribe(channel)
|
|
18
24
|
@socket.unsubscribe(channel)
|
|
19
25
|
end
|
|
@@ -27,7 +33,7 @@ class CirclerPusherClient
|
|
|
27
33
|
def pusher_options
|
|
28
34
|
{
|
|
29
35
|
secure: true,
|
|
30
|
-
auth_method:
|
|
36
|
+
auth_method: proc { |a, b| auth(a, b) },
|
|
31
37
|
logger: Logger.new('/dev/null')
|
|
32
38
|
}
|
|
33
39
|
end
|
|
@@ -1,40 +1,57 @@
|
|
|
1
1
|
module Circler
|
|
2
2
|
class BuildPrinter
|
|
3
|
-
def initialize(builds,
|
|
3
|
+
def initialize(builds, pretty: true)
|
|
4
4
|
@builds = builds
|
|
5
|
-
@
|
|
5
|
+
@pretty = pretty
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def to_s
|
|
9
|
-
|
|
10
|
-
max_row_widths = max_row_widths(@builds)
|
|
11
|
-
@builds.map(&:information)
|
|
12
|
-
.map { |array| array.map.with_index { |column, index| column.to_s + ' ' * (max_row_widths[index] - column.to_s.size) }.join(' ').to_s }
|
|
13
|
-
.join("\n")
|
|
14
|
-
else
|
|
15
|
-
Terminal::Table.new(title: title, headings: headings, rows: rows).to_s
|
|
16
|
-
end
|
|
9
|
+
@pretty ? print_pretty : print_compact
|
|
17
10
|
end
|
|
18
11
|
|
|
19
12
|
private
|
|
20
13
|
|
|
14
|
+
def print_compact
|
|
15
|
+
rows.map { |row| pad_columns_by_space(row, max_row_widths) }.join("\n")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def print_pretty
|
|
19
|
+
Terminal::Table.new(title: title, headings: headings, rows: rows).to_s
|
|
20
|
+
end
|
|
21
|
+
|
|
21
22
|
def title
|
|
22
|
-
|
|
23
|
+
build = @builds.first
|
|
24
|
+
"Recent Builds / #{build.project_name}".green
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def headings
|
|
26
|
-
|
|
28
|
+
%w(Number Status Branch Author Commit Duration StartTime)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def rows
|
|
30
32
|
@builds.map(&:information)
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
def max_row_widths
|
|
34
|
-
builds
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
def max_row_widths
|
|
36
|
+
@builds
|
|
37
|
+
.map(&:information)
|
|
38
|
+
.map { |array| array.map(&:to_s).map(&:size) }
|
|
39
|
+
.transpose
|
|
40
|
+
.map(&:max)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def pad_columns_by_space(columns, max_widths)
|
|
44
|
+
columns
|
|
45
|
+
.map
|
|
46
|
+
.with_index { |column, i| pad_column_by_space(column, max_widths, i) }
|
|
47
|
+
.join(' ')
|
|
48
|
+
.to_s
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def pad_column_by_space(column, max_widths, index)
|
|
52
|
+
column_string = column.to_s
|
|
53
|
+
spaces = ' ' * (max_widths[index] - column_string.size)
|
|
54
|
+
column_string + spaces
|
|
38
55
|
end
|
|
39
56
|
end
|
|
40
57
|
end
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
module Circler
|
|
2
2
|
class ProjectPrinter
|
|
3
3
|
attr_accessor :compact
|
|
4
|
-
def initialize(projects,
|
|
4
|
+
def initialize(projects, pretty: true)
|
|
5
5
|
@projects = projects
|
|
6
|
-
@
|
|
6
|
+
@pretty = pretty
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def to_s
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
|
|
10
|
+
@pretty ? print_pretty : print_compact
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def print_compact
|
|
16
|
+
@projects
|
|
17
|
+
.map(&:information)
|
|
18
|
+
.map { |array| array.join('/').to_s }
|
|
19
|
+
.sort
|
|
20
|
+
.join("\n")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def print_pretty
|
|
24
|
+
Terminal::Table.new(
|
|
25
|
+
title: 'Projects'.green,
|
|
26
|
+
headings: ['User name', 'Repository name'],
|
|
27
|
+
rows: @projects.map(&:information)
|
|
28
|
+
).to_s
|
|
19
29
|
end
|
|
20
30
|
end
|
|
21
31
|
end
|
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
module Circler
|
|
2
2
|
class StepPrinter
|
|
3
|
-
def initialize(steps,
|
|
3
|
+
def initialize(steps, pretty: true)
|
|
4
4
|
@steps = steps
|
|
5
|
-
@
|
|
5
|
+
@pretty = pretty
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def to_s
|
|
9
|
-
|
|
9
|
+
Terminal::Table.new do |t|
|
|
10
10
|
@steps
|
|
11
|
-
.group_by
|
|
11
|
+
.group_by(&:type)
|
|
12
12
|
.each do |key, steps|
|
|
13
13
|
t << :separator
|
|
14
|
-
t << [{ value: key.green, alignment: :center, :
|
|
15
|
-
steps.each
|
|
16
|
-
t << :separator
|
|
17
|
-
|
|
18
|
-
s.actions.each do |a|
|
|
19
|
-
t << [
|
|
20
|
-
colorize_by_status(a.name.slice(0..120), a.status),
|
|
21
|
-
format_time(a.run_time_millis)
|
|
22
|
-
]
|
|
23
|
-
if a.failed? && a.log
|
|
24
|
-
t << [{ value: a.log, alignment: :left, colspan: 2}]
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
14
|
+
t << [{ value: key.green, alignment: :center, colspan: 2 }]
|
|
15
|
+
steps.each { |s| print_actions(t, s) }
|
|
28
16
|
end
|
|
29
|
-
end
|
|
30
|
-
table.to_s
|
|
17
|
+
end.to_s
|
|
31
18
|
end
|
|
32
19
|
|
|
33
20
|
private
|
|
@@ -45,8 +32,21 @@ module Circler
|
|
|
45
32
|
def format_time(time)
|
|
46
33
|
return '' unless time
|
|
47
34
|
minute = format('%02d', time / 1000 / 60)
|
|
48
|
-
second = format('%02d', (time / 1000)
|
|
35
|
+
second = format('%02d', (time / 1000) % 60)
|
|
49
36
|
"#{minute}:#{second}"
|
|
50
37
|
end
|
|
38
|
+
|
|
39
|
+
def print_actions(table, step)
|
|
40
|
+
table << :separator
|
|
41
|
+
step.actions.each do |a|
|
|
42
|
+
table << [
|
|
43
|
+
colorize_by_status(a.name.slice(0..120), a.status),
|
|
44
|
+
format_time(a.run_time_millis)
|
|
45
|
+
]
|
|
46
|
+
if a.failed? && a.log
|
|
47
|
+
table << [{ value: a.log, alignment: :left, colspan: 2 }]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -3,14 +3,14 @@ module Circler
|
|
|
3
3
|
class << self
|
|
4
4
|
def all(username, reponame)
|
|
5
5
|
CircleCi::Project.recent_builds(username, reponame)
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
.body
|
|
7
|
+
.map { |b| Build.new(b) }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def branch(username, reponame, branch)
|
|
11
11
|
CircleCi::Project.recent_builds_branch(username, reponame, branch)
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
.body
|
|
13
|
+
.map { |b| Build.new(b) }
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def get(username, reponame, number)
|
|
@@ -22,7 +22,7 @@ module Circler
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def cancel(username, reponame, number)
|
|
25
|
-
|
|
25
|
+
Build.new(CircleCi::Build.cancel(username, reponame, number).body)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -54,6 +54,10 @@ module Circler
|
|
|
54
54
|
"private-#{username}@#{reponame}@#{build_number}@vcs-github@0"
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
def project_name
|
|
58
|
+
"#{username}/#{reponame}"
|
|
59
|
+
end
|
|
60
|
+
|
|
57
61
|
def information
|
|
58
62
|
[
|
|
59
63
|
@hash['build_num'],
|
|
@@ -62,18 +66,18 @@ module Circler
|
|
|
62
66
|
@hash['author_name'],
|
|
63
67
|
(@hash['subject'] || '').slice(0..60),
|
|
64
68
|
format_time(@hash['build_time_millis']),
|
|
65
|
-
@hash['start_time']
|
|
69
|
+
@hash['start_time']
|
|
66
70
|
]
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def steps
|
|
70
74
|
hash = @hash['steps'].group_by { |s| s['actions'].first['type'] }
|
|
71
|
-
hash.flat_map { |type, value| value.map{ |v| Step.new(type, v) }}
|
|
75
|
+
hash.flat_map { |type, value| value.map { |v| Step.new(type, v) } }
|
|
72
76
|
end
|
|
73
77
|
|
|
74
78
|
private
|
|
75
79
|
|
|
76
|
-
def
|
|
80
|
+
def colorize_by_status(string, status)
|
|
77
81
|
case status
|
|
78
82
|
when 'success', 'fixed' then string.green
|
|
79
83
|
when 'canceled' then string.yellow
|
|
@@ -83,19 +87,11 @@ module Circler
|
|
|
83
87
|
end
|
|
84
88
|
end
|
|
85
89
|
|
|
86
|
-
def
|
|
87
|
-
self.class.colorize_by_status(string, status)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def self.format_time(time)
|
|
90
|
+
def format_time(time)
|
|
91
91
|
return '' unless time
|
|
92
92
|
minute = format('%02d', time / 1000 / 60)
|
|
93
|
-
second = format('%02d', (time / 1000)
|
|
93
|
+
second = format('%02d', (time / 1000) % 60)
|
|
94
94
|
"#{minute}:#{second}"
|
|
95
95
|
end
|
|
96
|
-
|
|
97
|
-
def format_time(time)
|
|
98
|
-
self.class.format_time(time)
|
|
99
|
-
end
|
|
100
96
|
end
|
|
101
97
|
end
|
data/lib/circler/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: circler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- unhappychoice
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-03
|
|
11
|
+
date: 2017-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pusher-client
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.
|
|
47
|
+
version: 0.12.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.
|
|
54
|
+
version: 0.12.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: launchy
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,14 +72,14 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 1.0
|
|
75
|
+
version: 1.1.0
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 1.0
|
|
82
|
+
version: 1.1.0
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rugged
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +100,14 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 1.
|
|
103
|
+
version: 1.8.0
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 1.
|
|
110
|
+
version: 1.8.0
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: highline
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -142,14 +142,14 @@ dependencies:
|
|
|
142
142
|
requirements:
|
|
143
143
|
- - "~>"
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: 1.
|
|
145
|
+
version: 1.8.0
|
|
146
146
|
type: :runtime
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
150
|
- - "~>"
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: 1.
|
|
152
|
+
version: 1.8.0
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
154
|
name: bundler
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,6 +192,20 @@ dependencies:
|
|
|
192
192
|
- - ">="
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
194
|
version: '0'
|
|
195
|
+
- !ruby/object:Gem::Dependency
|
|
196
|
+
name: rubocop
|
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
|
198
|
+
requirements:
|
|
199
|
+
- - "~>"
|
|
200
|
+
- !ruby/object:Gem::Version
|
|
201
|
+
version: 0.47.1
|
|
202
|
+
type: :development
|
|
203
|
+
prerelease: false
|
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
205
|
+
requirements:
|
|
206
|
+
- - "~>"
|
|
207
|
+
- !ruby/object:Gem::Version
|
|
208
|
+
version: 0.47.1
|
|
195
209
|
description: A command line tool for CircleCI
|
|
196
210
|
email:
|
|
197
211
|
- unhappychoice@gmail.com
|