Class: DRYFT::Job
Instance Attribute Summary collapse
-
#def_acts ⇒ Object
readonly
Returns the value of attribute def_acts.
-
#deps ⇒ Object
readonly
Returns the value of attribute deps.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
-
#initialize(db, info) ⇒ Job
constructor
A new instance of Job.
- #reload ⇒ Object
- #update_from_deps(jobs) ⇒ Object
Constructor Details
#initialize(db, info) ⇒ Job
Returns a new instance of Job.
6 7 8 9 10 |
# File 'lib/dryft/job.rb', line 6 def initialize(db, info) @db = db @id = get_id(db, info) load end |
Instance Attribute Details
#def_acts ⇒ Object (readonly)
Returns the value of attribute def_acts.
4 5 6 |
# File 'lib/dryft/job.rb', line 4 def def_acts @def_acts end |
#deps ⇒ Object (readonly)
Returns the value of attribute deps.
4 5 6 |
# File 'lib/dryft/job.rb', line 4 def deps @deps end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/dryft/job.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/dryft/job.rb', line 4 def name @name end |
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
4 5 6 |
# File 'lib/dryft/job.rb', line 4 def proc @proc end |
Instance Method Details
#reload ⇒ Object
12 13 14 |
# File 'lib/dryft/job.rb', line 12 def reload load end |
#update_from_deps(jobs) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dryft/job.rb', line 16 def update_from_deps(jobs) no_change = true @deps.each do |dep| src_job = jobs.by_proc(dep[:proc]) if dep[:acts].not_equivalent_to?( src_job.def_acts ) no_change = false dep[:acts].after( src_job.def_acts.to_xml ) dep[:acts].unlink puts "At #{@name}:#{dep[:start]}, updated procedure <#{dep[:proc]}> from its definition." end end if no_change puts "No change to '#{@name}'." else updated_code = @doc.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::NO_DECLARATION) @db.execute("UPDATE jobcode SET code = ? WHERE hex(id) = ?", [updated_code, @id]) # Switch to a new job ID, because there is no way to trigger a reload ov the original job ID's code. new_id = @db.execute("SELECT HEX(RANDOMBLOB(LENGTH(Id))) FROM jobcode")[0][0] @db.execute("UPDATE compilerproperties SET JobId = x'#{new_id}' WHERE hex(JobId) = ?", [@id]) @db.execute("UPDATE jobaddon SET JobId = x'#{new_id}' WHERE hex(JobId) = ?", [@id]) @db.execute("UPDATE jobaddonassembly SET JobId = x'#{new_id}' WHERE hex(JobId) = ?", [@id]) @db.execute("UPDATE jobattachment SET JobId = x'#{new_id}' WHERE hex(JobId) = ?", [@id]) @db.execute("UPDATE jobcode SET Id = x'#{new_id}' WHERE hex(Id) = ?", [@id]) @db.execute("UPDATE jobinfo SET Id = x'#{new_id}' WHERE hex(Id) = ?", [@id]) @db.execute("UPDATE jobproperties SET Id = x'#{new_id}' WHERE hex(Id) = ?", [@id]) @db.execute("UPDATE jobproperties2 SET Id = x'#{new_id}' WHERE hex(Id) = ?", [@id]) @db.execute("UPDATE triggers SET JobId = x'#{new_id}' WHERE hex(JobId) = ?", [@id]) @id = new_id reload end end |