class Circle::CLI::App
Constants
- CIRCLE_URL
- LOGIN_HELP
- NO_TOKEN_MESSAGE
Public Instance Methods
build()
click to toggle source
# File lib/circle/cli/app.rb, line 90 def build validate_repo! project.build! say "A build has been triggered.\n\n", :green invoke :status, [], watch: true end
cancel()
click to toggle source
# File lib/circle/cli/app.rb, line 99 def cancel validate_repo! validate_latest! latest.cancel! unless latest.finished? invoke :status say "\nThe build has been cancelled.", :red unless latest.finished? end
login()
click to toggle source
# File lib/circle/cli/app.rb, line 119 def login say LOGIN_HELP, :yellow ask set_color("\nPress [enter] to open CircleCI", :blue) Launchy.open(CIRCLE_URL) value = ask set_color('Enter your token:', :blue) repo.circle_token = value say "\nYour token has been set to '#{value}'.", :green end
open()
click to toggle source
# File lib/circle/cli/app.rb, line 82 def open validate_repo! validate_latest! Launchy.open latest[:build_url] end
overview()
click to toggle source
# File lib/circle/cli/app.rb, line 60 def overview validate_repo! abort! 'No recent builds.' if project.recent_builds.empty? watcher = Watcher.new do display_builds(project.recent_builds) end watcher.to_preload do project.clear_cache! project.recent_builds end if options[:watch] watcher.poll(options[:poll]) else watcher.display end end
status()
click to toggle source
# File lib/circle/cli/app.rb, line 32 def status validate_repo! validate_latest! watcher = Watcher.new do display_status end watcher.to_preload do project.clear_cache! project.latest.preload end if options[:watch] watcher.poll(options[:poll]) else watcher.display end end
token(value = nil)
click to toggle source
# File lib/circle/cli/app.rb, line 108 def token(value = nil) if value repo.circle_token = value elsif value = repo.circle_token say value else say NO_TOKEN_MESSAGE, :yellow end end
watch()
click to toggle source
# File lib/circle/cli/app.rb, line 53 def watch invoke :status, [], watch: true end
Private Instance Methods
abort!(message)
click to toggle source
# File lib/circle/cli/app.rb, line 151 def abort!(message) abort set_color(message, :red) end
display(description, value, color)
click to toggle source
# File lib/circle/cli/app.rb, line 155 def display(description, value, color) status = set_color description.ljust(15), :bold result = set_color value.to_s, color say "#{status} #{result}" end
display_builds(builds)
click to toggle source
# File lib/circle/cli/app.rb, line 189 def display_builds(builds) print_table builds.map { |build| branch = set_color(build[:branch], :bold) status = set_color(build.status, build.color) started = build.formatted_start_time [branch, status, build.subject, started] } end
display_failures(failures)
click to toggle source
# File lib/circle/cli/app.rb, line 181 def display_failures(failures) say "\nFailing specs:", :bold print_table failures.map { |spec| [set_color(spec['file'], :red), spec['name']] } end
display_status()
click to toggle source
# File lib/circle/cli/app.rb, line 161 def display_status say "#{latest[:subject]}\n\n", :cyan if latest[:subject] display 'Build status', latest.status, latest.color display 'Started at', latest.formatted_start_time, latest.color display 'Finished at', latest.formatted_stop_time, latest.color display 'Compare', latest[:compare], latest.color if latest[:compare] display_steps latest.steps unless latest.steps.empty? display_failures latest.failing_tests unless latest.failing_tests.empty? exit 1 if latest.failed? exit 0 if latest.finished? end
display_steps(steps)
click to toggle source
# File lib/circle/cli/app.rb, line 173 def display_steps(steps) say "\nSteps:", :bold print_table steps.map { |step| [set_color(step[:name], step.color), step.duration] } end
latest()
click to toggle source
# File lib/circle/cli/app.rb, line 138 def latest project.latest end
project()
click to toggle source
# File lib/circle/cli/app.rb, line 134 def project @project ||= Project.new(repo) end
repo()
click to toggle source
# File lib/circle/cli/app.rb, line 130 def repo @repo ||= Repo.new(options) end
validate_latest!()
click to toggle source
# File lib/circle/cli/app.rb, line 147 def validate_latest! abort! 'No CircleCI builds found.' unless project.latest end
validate_repo!()
click to toggle source
# File lib/circle/cli/app.rb, line 142 def validate_repo! abort! "Unsupported repo url format #{repo.uri}" unless repo.uri.github? abort! NO_TOKEN_MESSAGE unless repo.circle_token end