Class: CrontabRb::Parse
- Inherits:
-
Object
- Object
- CrontabRb::Parse
- Defined in:
- lib/crontab_rb/parse.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ Parse
constructor
A new instance of Parse.
Constructor Details
#initialize ⇒ Parse
Returns a new instance of Parse.
7 8 9 10 |
# File 'lib/crontab_rb/parse.rb', line 7 def initialize @job_template = ":time /bin/bash -l -c 'cd :path && bundle exec :command'" @path = Dir.pwd end |
Class Method Details
.from_database ⇒ Object
3 4 5 |
# File 'lib/crontab_rb/parse.rb', line 3 def self.from_database new.call end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/crontab_rb/parse.rb', line 12 def call records = Database.all return "\n" if records.empty? contents = [] records.each do |record| = record [:type] = record[:time] [:time] = Template::EVERY[[:time]] [:path] = @path out = process_template(@job_template, ) out = process_template(out, ) contents << out + "\n" end contents.join("\n") end |