Module: Conf
- Included in:
- Object
- Defined in:
- lib/bleetz/conf.rb
Constant Summary collapse
- @@actions =
{}
- @@tasks =
{}
- @@options =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #action(action, desc = "") ⇒ Object
- #call(action) ⇒ Object
- #set(opt, value) ⇒ Object
- #shell(cmd) ⇒ Object
Class Method Details
.included(base) ⇒ Object
15 16 17 |
# File 'lib/bleetz/conf.rb', line 15 def self.included(base) base.extend(self) end |
Instance Method Details
#action(action, desc = "") ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bleetz/conf.rb', line 19 def action(action, desc = "") check_main_call(:action) @cmds = [] begin yield rescue Exception => e if e.class.eql? RuntimeError raise BleetzException.new(e.) else raise BleetzException.new("#{e.class}: #{e.} in #{e.backtrace[0]}") end end h = { action.to_sym => @cmds } t = { action.to_sym => desc.to_s } @@actions = @@actions.merge(h) @@tasks = @@tasks.merge(t) end |
#call(action) ⇒ Object
43 44 45 46 47 |
# File 'lib/bleetz/conf.rb', line 43 def call(action) check_sub_call(:call) raise "'call :action_name'. You didn't pass a Symbol." unless action.is_a? Symbol @cmds << action end |
#set(opt, value) ⇒ Object
49 50 51 52 |
# File 'lib/bleetz/conf.rb', line 49 def set(opt, value) check_main_call(:set) @@options[opt.to_sym] = value end |
#shell(cmd) ⇒ Object
37 38 39 40 41 |
# File 'lib/bleetz/conf.rb', line 37 def shell(cmd) check_sub_call(:shell) raise "'shell' needs a String as parameter." unless cmd.is_a? String @cmds << cmd end |