Class: Lazylead::ORM::Task
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Lazylead::ORM::Task
- Includes:
- Lazylead::ORM
- Defined in:
- lib/lazylead/model.rb
Overview
General lazylead task.
Instance Method Summary collapse
- #detect_cc(sys) ⇒ Object
-
#exec ⇒ Object
Execute task.
- #postman ⇒ Object
- #props ⇒ Object
-
#type ⇒ Object
Scheduling type.
-
#unit ⇒ Object
Scheduling unit.
Methods included from Lazylead::ORM
#env, #inspect, #to_hash, #to_s
Instance Method Details
#detect_cc(sys) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/lazylead/model.rb', line 124 def detect_cc(sys) opts = props opts["cc"] = CC.new.detect(opts["cc"], sys) return opts.except "cc" if opts["cc"].is_a? EmptyCC opts end |
#exec ⇒ Object
Execute task
98 99 100 101 102 103 |
# File 'lib/lazylead/model.rb', line 98 def exec sys = system.connect opts = props opts = detect_cc(sys) if opts.key? "cc" action.constantize.new.run(sys, postman, opts) end |
#postman ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/lazylead/model.rb', line 141 def postman if props.key? "postman" props["postman"].constantize.new else Postman.new end end |
#props ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/lazylead/model.rb', line 131 def props @props ||= begin if team.nil? Opts.new(env(to_hash)) else Opts.new(env(team.to_hash.merge(to_hash))) end end end |
#type ⇒ Object
Scheduling type. Current implementation is based on ‘rufus-scheduler’ gem and supports
the following types: 'cron', 'interval', 'in', 'at', 'every'
108 109 110 |
# File 'lib/lazylead/model.rb', line 108 def type trigger.first end |
#unit ⇒ Object
Scheduling unit. Current implementation is based on ‘rufus-scheduler’ gem thus each scheduling type has own arguments:
1. Scheduling type 'cron' has 'unit' = '00 09 * * *'
2. Scheduling type 'interval' has 'unit' = '2h'
3. Scheduling type 'every' has 'unit' = '3h'
4. Scheduling type 'in' has 'unit' = '10d'
5. Scheduling type 'at' has 'unit' = '2014/12/24 2000'
120 121 122 |
# File 'lib/lazylead/model.rb', line 120 def unit trigger.last end |