Class: CruiseStatus::Command
- Inherits:
-
Object
- Object
- CruiseStatus::Command
- Defined in:
- lib/cruisestatus/command.rb
Constant Summary collapse
- DEFAULT_PROMPT =
"Are you sure you want to check in? (y/n): "
Class Method Summary collapse
Class Method Details
.are_you_sure?(status) ⇒ Boolean
43 44 45 46 47 48 49 50 51 |
# File 'lib/cruisestatus/command.rb', line 43 def self.are_you_sure?( status ) puts "\n", "Build FAILURES: #{status.}" input = "" while( input && input.strip.empty? ) input = Readline.readline @prompt end input.strip.downcase[0,1] == "y" ? 0 : 1 end |
.run!(argv) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cruisestatus/command.rb', line 7 def self.run!( argv ) @prompt = nil opts = OptionParser.new do |o| o. = <<-EOS Usage: #{File.basename($0)} [options] CRUISE_RB_RSS_URL Reads the feed at CRUISE_RB_RSS_URL and reports if the build[s] passed. Examples: #{File.basename($0)} http://my.cruiseserver.com #{File.basename($0)} http://my.cruiseserver.com/projects.rss #{File.basename($0)} http://my.cruiseserver.com/projects/myproject.rss EOS o.on( "-p", "--prompt" ) { |val| @prompt = DEFAULT_PROMPT } end opts.parse! argv if argv.empty? abort opts. else status = CruiseStatus.new argv.last if status.pass? puts "Build PASSED" 0 else return are_you_sure?( status ) if @prompt 1 end end end |