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 11 |
# File 'lib/crontab_rb/parse.rb', line 7 def initialize @template = "cd :path && bundle exec bin/rails runner -e #{Rails.env} ':command' >/dev/null 2>&1" @job_template = "/bin/bash -l -c ':job'" @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
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/crontab_rb/parse.rb', line 13 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 job = process_template(@template, ) task = process_template(@job_template, .merge(:job => job)) timer = process_timer() contents << timer + " " + task + "\n" end contents.join("\n") end |