Class: Launch::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/launch/job.rb,
ext/launch.c

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) {|_self| ... } ⇒ Job

Returns a new instance of Job.

Yields:

  • (_self)

Yield Parameters:

  • _self (Launch::Job)

    the object that the method was called on



113
114
115
116
117
118
119
# File 'lib/launch/job.rb', line 113

def initialize(attributes = {})
  @launch_attributes = {}

  self.attributes = attributes

  yield self if block_given?
end

Class Method Details

.checkinObject



6
7
8
9
10
# File 'lib/launch/job.rb', line 6

def checkin
  from_launch Launch.message(Messages::CHECKIN)
rescue Errno::EPERM
  raise JobError.new(nil, "must checkin from process spawned by lauchd for job with sockets")
end

.find(label) ⇒ Object



12
13
14
15
16
# File 'lib/launch/job.rb', line 12

def find(label)
  from_launch Launch.message(Messages::GETJOB => label)
rescue Errno::ESRCH
  raise UnknownJob.new(nil, "no job exists with the label `#{label}'")
end

Instance Method Details

#attributes=(attributes) ⇒ Object



107
108
109
110
111
# File 'lib/launch/job.rb', line 107

def attributes=(attributes)
  attributes.each do |key, value|
    send(:"#{key}=", value)
  end
end

#inspectObject



121
122
123
# File 'lib/launch/job.rb', line 121

def inspect
  "#<#{self.class} #{attributes_inspect}>"
end

#launch_attributesObject



125
126
127
# File 'lib/launch/job.rb', line 125

def launch_attributes
  @launch_attributes
end

#launch_attributes=(attributes) ⇒ Object



129
130
131
# File 'lib/launch/job.rb', line 129

def launch_attributes=(attributes)
  @launch_attributes = attributes
end

#removeObject



133
134
135
# File 'lib/launch/job.rb', line 133

def remove
  message(Messages::REMOVEJOB => label)
end

#startObject



137
138
139
# File 'lib/launch/job.rb', line 137

def start
  message(Messages::STARTJOB => label)
end

#stopObject



141
142
143
# File 'lib/launch/job.rb', line 141

def stop
  message(Messages::STOPJOB => label)
end

#submitObject



145
146
147
# File 'lib/launch/job.rb', line 145

def submit
  message(Messages::SUBMITJOB => launch_attributes)
end