Class: Capistrano::Cron::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/cron/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Job



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/capistrano/cron/job.rb', line 7

def initialize(options = {})
  @options = options
  @at = options.delete(:at)
  @template = options.delete(:template)
  @mailto = options.fetch(:mailto, :default_mailto)
  @job_template = options.delete(:job_template) || ":job"
  @roles = Array(options.delete(:roles))
  @options[:output] = options.has_key?(:output) ? Capistrano::Cron::Output::Redirection.new(options[:output]).to_s : ""
  @options[:environment_variable] ||= "RAILS_ENV"
  @options[:environment] ||= :production
  @options[:path] = Shellwords.shellescape(@options[:path])
end

Instance Attribute Details

#at ⇒ Object (readonly)

Returns the value of attribute at.



5
6
7
# File 'lib/capistrano/cron/job.rb', line 5

def at
  @at
end

#mailto ⇒ Object (readonly)

Returns the value of attribute mailto.



5
6
7
# File 'lib/capistrano/cron/job.rb', line 5

def mailto
  @mailto
end

#roles ⇒ Object (readonly)

Returns the value of attribute roles.



5
6
7
# File 'lib/capistrano/cron/job.rb', line 5

def roles
  @roles
end

Instance Method Details

#has_role?(role) ⇒ Boolean



26
27
28
# File 'lib/capistrano/cron/job.rb', line 26

def has_role?(role)
  roles.empty? || roles.include?(role)
end

#output ⇒ Object



20
21
22
23
24
# File 'lib/capistrano/cron/job.rb', line 20

def output
  job = process_template(@template, @options)
  out = process_template(@job_template, @options.merge(job: job))
  out.gsub("%", '\%')
end