Class: Commands::Periodic
- Inherits:
-
Object
- Object
- Commands::Periodic
- Defined in:
- lib/commands/periodic.rb
Instance Method Summary collapse
-
#options ⇒ Object
holds the options that were passed you can set any initial defaults here.
- #register(opts, global_options) ⇒ Object
-
#required_options ⇒ Object
required options.
- #run(global_options) ⇒ Object
Instance Method Details
#options ⇒ Object
holds the options that were passed you can set any initial defaults here
13 14 15 16 |
# File 'lib/commands/periodic.rb', line 13 def @options ||= { } end |
#register(opts, global_options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/commands/periodic.rb', line 26 def register(opts, ) opts. = "Usage: periodic [options]" opts.description = "Run a periodic command" opts.on('-c', "--command name", "Required - Command to run.") do |v| [:command] = v end opts.on('-i', "--interval value", Integer, "Required - Interval in seconds.") do |v| [:interval] = v end end |
#required_options ⇒ Object
required options
19 20 21 22 23 24 |
# File 'lib/commands/periodic.rb', line 19 def @required_options ||= Set.new [ :command, :interval ] end |
#run(global_options) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/commands/periodic.rb', line 40 def run() # see if we can open the config file - we append the .config suffix # the file is expected to be in JSON format command = [:command] interval = [:interval] while true EbmSharedLib::CL.do_cmd_result(command) sleep(interval) end end |