circler 0.1.3 → 0.2.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: d78b140d5b8237f2ea48fe307598b7c6d71ac6f4
4
- data.tar.gz: 1be453dfd3df46d8e8d1e553ac0fa1ffe392375e
3
+ metadata.gz: 0a2915be4476721570000fcd1fb54d7e42100969
4
+ data.tar.gz: d469bbb48a50f212f332c4fa07348388f6f5f8f4
5
5
  SHA512:
6
- metadata.gz: 25adb773d2460a7220e614016c8e11663e017639c60e0194a64fd4eed6cf5dbb095b0ef3baea87bfc92a8a9b7e362098db26f253c5338c23b319d485341e6487
7
- data.tar.gz: ec67f0facca59c9deabfc28244cd5567981e7b052d1ce0df5c26456a80587d816bdf42ebe807fa7c3e49561d7b6aa09d161b6c4e69af87e08dceb160cf39b70a
6
+ metadata.gz: 520a6987ac1086744907dcd82b7edfe9458eaf1897f77ef7d2a4778565db4d44f478c57c43f684948b60e62e7a301efabe12e634828516951a563325d371b422
7
+ data.tar.gz: aed62cc99804a8f87cd0f5b4e46e4ce81c9ae3070a3f5b062468a029e06337ea5e3e4efa8fae897bd2632638b7f718b3e3d50d8804a0069a70fac1f1ad39b6a8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circler (0.1.3)
4
+ circler (0.2.0)
5
5
  circleci (~> 0.2.0)
6
6
  colorize (~> 0.7.7)
7
7
  faraday (~> 0.9.2)
@@ -15,6 +15,7 @@ require 'circler/command/browse_command'
15
15
  require 'circler/response/project'
16
16
  require 'circler/response/build'
17
17
  require 'circler/response/step'
18
+ require 'circler/response/action'
18
19
  require 'circler/printer/project_printer'
19
20
  require 'circler/printer/build_printer'
20
21
  require 'circler/printer/step_printer'
@@ -7,17 +7,25 @@ module Circler
7
7
 
8
8
  def to_s
9
9
  table = Terminal::Table.new do |t|
10
- @steps.each do |s|
11
- t << [{ value: s.type.green, alignment: :center, :colspan => 2 }]
12
- t << :separator
13
- s.actions.each do |a|
14
- t << [
15
- colorize_by_status(a['name'].slice(0..120), a['status']),
16
- format_time(a['run_time_millis'].to_i)
17
- ]
10
+ @steps
11
+ .group_by {|s| s.type }
12
+ .each do |key, steps|
13
+ t << :separator
14
+ t << [{ value: key.green, alignment: :center, :colspan => 2 }]
15
+ steps.each do |s|
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
18
28
  end
19
- t << :separator
20
- end
21
29
  end
22
30
  table.to_s
23
31
  end
@@ -28,7 +36,7 @@ module Circler
28
36
  case status
29
37
  when 'success', 'fixed' then string.green
30
38
  when 'canceled' then string.yellow
31
- when 'failed' then string.red
39
+ when 'failed', 'timedout' then string.red
32
40
  when 'no_tests', 'not_run' then string.light_black
33
41
  else string
34
42
  end
@@ -0,0 +1,29 @@
1
+ module Circler
2
+ class Action
3
+ attr_reader :name, :status, :run_time_millis
4
+ def initialize(hash)
5
+ @hash = hash
6
+ @name = hash['name']
7
+ @status = hash['status']
8
+ @run_time_millis = hash['run_time_millis']
9
+ end
10
+
11
+ def log
12
+ request(@hash['output_url'])
13
+ .map{ |r| r['message']}
14
+ .join
15
+ .gsub(/.{120}/, "\\0\n")
16
+ .gsub(/\r/, '')
17
+ end
18
+
19
+ def failed?
20
+ @status == 'timedout' || @status == 'failed'
21
+ end
22
+
23
+ private
24
+
25
+ def request(url)
26
+ JSON.parse(Faraday.new(url).get.body)
27
+ end
28
+ end
29
+ end
@@ -44,7 +44,7 @@ module Circler
44
44
 
45
45
  def steps
46
46
  hash = @hash['steps'].group_by { |s| s['actions'].first['type'] }
47
- hash.map { |type, step| Step.new(type, step) }
47
+ hash.flat_map { |type, value| value.map{ |v| Step.new(type, v) }}
48
48
  end
49
49
 
50
50
  private
@@ -1,20 +1,16 @@
1
1
  module Circler
2
2
  class Step
3
3
  attr_reader :type
4
+ attr_reader :status
4
5
 
5
6
  def initialize(type, hash)
6
7
  @type = type
8
+ @status = hash['status']
7
9
  @hash = hash
8
10
  end
9
11
 
10
12
  def actions
11
- @hash.flat_map { |s| s['actions'] }
12
- end
13
-
14
- def logs
15
- actions.map do |a|
16
- Faraday.new(a.output_url).get.body
17
- end
13
+ @hash['actions'].map{ |a| Action.new(a) }
18
14
  end
19
15
  end
20
16
  end
@@ -1,3 +1,3 @@
1
1
  module Circler
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - unhappychoice
@@ -193,6 +193,7 @@ files:
193
193
  - lib/circler/printer/build_printer.rb
194
194
  - lib/circler/printer/project_printer.rb
195
195
  - lib/circler/printer/step_printer.rb
196
+ - lib/circler/response/action.rb
196
197
  - lib/circler/response/build.rb
197
198
  - lib/circler/response/project.rb
198
199
  - lib/circler/response/step.rb