Class: Travis::Surveillance::CLI::Artist
- Inherits:
-
Object
- Object
- Travis::Surveillance::CLI::Artist
- Defined in:
- lib/travis/surveillance/cli.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(project) ⇒ Artist
constructor
A new instance of Artist.
Constructor Details
#initialize(project) ⇒ Artist
Returns a new instance of Artist.
15 16 17 |
# File 'lib/travis/surveillance/cli.rb', line 15 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
13 14 15 |
# File 'lib/travis/surveillance/cli.rb', line 13 def project @project end |
Instance Method Details
#draw ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/travis/surveillance/cli.rb', line 19 def draw if project.builds.any? && builds = project.builds.reverse print "\x1b[2J\x1b[H" latest = builds.first table = Terminal::Table.new title: "#{project.owner}/#{project.name} (#{project.url})", style: { width: 120 } do |t| t << ["Build", "#{latest.number} (#{latest.url})"] t << ["Duration", latest.duration] unless latest.building? t << ["Branch", latest.branch] t << ["Commit", latest.commit] t << ["Compare URL", latest.compare_url] t << ["Author", latest.] t << ["Message", latest..length > 80 ? "#{latest.[0..80]}..." : latest.] end print table print "\n\n" table = Terminal::Table.new title: "Build Matrix", headings: ['Job', 'State', 'Duration', 'Runtime', 'ENV'], style: { width: 120 } do |t| latest.jobs.each do |job| t << [job.number, job.state, job.duration, job.runtime, ((job.config.env && job.config.env.length > 30) ? "#{job.config.env[0..30]}..." : job.config.env)] end end print table if builds.size > 1 print "\n\n" table = Terminal::Table.new :title => "Build History", :headings => ['Build', 'State', 'Branch', 'Message', 'Duration'], style: { width: 120 } do |t| builds.each do |build| next if build == latest t << [build.number, build.state, build.branch, (build..length > 30 ? "#{build.[0..30]}..." : build.), build.duration] end end print table end end print "\x1b[H" $stdout.flush end |