Class: Naf::ApplicationType

Inherits:
NafBase
  • Object
show all
Defined in:
app/models/naf/application_type.rb

Constant Summary collapse

SCRIPT_RUNNER =
"#{Gem.ruby} #{Rails.root}/script/rails runner"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NafBase

full_table_name_prefix

Class Method Details

.bash_commandObject



64
65
66
# File 'app/models/naf/application_type.rb', line 64

def self.bash_command
  @bash_command ||= find_by_script_type_name('bash command')
end

.bash_scriptObject



68
69
70
# File 'app/models/naf/application_type.rb', line 68

def self.bash_script
  @bash_script ||= find_by_script_type_name('bash script')
end

.railsObject



56
57
58
# File 'app/models/naf/application_type.rb', line 56

def self.rails
  @rails ||= find_by_script_type_name('rails')
end

.rubyObject



60
61
62
# File 'app/models/naf/application_type.rb', line 60

def self.ruby
  @ruby ||= find_by_script_type_name('ruby')
end

Instance Method Details

#bash_command_invocator(job) ⇒ Object



44
45
46
# File 'app/models/naf/application_type.rb', line 44

def bash_command_invocator(job)
  invoke(job, job.command)
end

#bash_script_invocator(job) ⇒ Object



48
49
50
# File 'app/models/naf/application_type.rb', line 48

def bash_script_invocator(job)
  invoke(job, job.command)
end

#invoke(job, command) ⇒ Object



35
36
37
38
# File 'app/models/naf/application_type.rb', line 35

def invoke(job, command)
  ENV['NAF_JOB_ID'] = job.id.to_s
  Open4::popen4(command)
end

#rails_invocator(job) ⇒ Object



40
41
42
# File 'app/models/naf/application_type.rb', line 40

def rails_invocator(job)
  invoke(job, SCRIPT_RUNNER + " " + job.command)
end

#ruby_script_invocator(job) ⇒ Object



52
53
54
# File 'app/models/naf/application_type.rb', line 52

def ruby_script_invocator(job)
  invoke(job, job.command)
end

#spawn(job) ⇒ Object


*** Instance Methods *** +++++++++++++++++++++++++



31
32
33
# File 'app/models/naf/application_type.rb', line 31

def spawn(job)
  self.send(invocation_method.to_sym, job)
end