Class: Capistrano::Calendar::Runner
- Inherits:
-
Object
- Object
- Capistrano::Calendar::Runner
- Defined in:
- lib/capistrano/calendar/runner.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #run! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
10 11 12 |
# File 'lib/capistrano/calendar/runner.rb', line 10 def initialize(argv) @argv = argv end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
14 15 16 |
# File 'lib/capistrano/calendar/runner.rb', line 14 def client @client end |
Class Method Details
.run(*args) ⇒ Object
6 7 8 |
# File 'lib/capistrano/calendar/runner.rb', line 6 def self.run(*args) new(*args).run! end |
Instance Method Details
#run! ⇒ Object
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 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/capistrano/calendar/runner.rb', line 16 def run! parser = OptionParser.new do |o| o. = "Usage: capistrano-calendar [options] COMMAND [CONFIGURATION_DATA]" o.separator "" o.separator "Commands:" o.separator "" o.separator " create_event - create calendar event" o.separator "" o.separator "CONFIGURATION_DATA is base64 encoded yaml data" o.separator "" o.separator "Common options:" o.on_tail("-h", "--help", "Show this message") { puts o; exit } o.on_tail('-v', '--version', "Show version") { puts Capistrano::Calendar::VERSION; exit } end parser.parse!(@argv) @command = @argv.shift @configuration = @argv.shift case @command when 'create_event' @configuration or abort(parser.help) @configuration = Capistrano::Calendar::Configuration.decode(@configuration) @configuration.is_a?(Hash) or abort("Bad configuration given") @client = Capistrano::Calendar::Client.new(@configuration) if @configuration[:calendar_foreground] create_event else daemonize { create_event } end else abort parser.help end end |