Class: Lolcommits::Runner
- Inherits:
-
Object
- Object
- Lolcommits::Runner
- Includes:
- Methadone::CLILogging
- Defined in:
- lib/lolcommits/runner.rb
Instance Attribute Summary collapse
-
#capture_animate ⇒ Object
Returns the value of attribute capture_animate.
-
#capture_delay ⇒ Object
Returns the value of attribute capture_delay.
-
#capture_device ⇒ Object
Returns the value of attribute capture_device.
-
#capture_stealth ⇒ Object
Returns the value of attribute capture_stealth.
-
#config ⇒ Object
Returns the value of attribute config.
-
#main_image ⇒ Object
Returns the value of attribute main_image.
-
#message ⇒ Object
Returns the value of attribute message.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#snapshot_loc ⇒ Object
Returns the value of attribute snapshot_loc.
-
#vcs_info ⇒ Object
Returns the value of attribute vcs_info.
Class Method Summary collapse
Instance Method Summary collapse
- #animate? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Runner
constructor
A new instance of Runner.
- #plugins_for(position) ⇒ Object
-
#run ⇒ Object
wrap run to handle things that should happen before and after this used to be handled with ActiveSupport::Callbacks, but now we’re just using a simple procedural list.
-
#run_capture ⇒ Object
the main capture.
Constructor Details
#initialize(attributes = {}) ⇒ Runner
Returns a new instance of Runner.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lolcommits/runner.rb', line 12 def initialize(attributes = {}) attributes.each do |attr, val| send("#{attr}=", val) end return unless sha.nil? || .nil? if GitInfo.repo_root? self.vcs_info = GitInfo.new elsif MercurialInfo.repo_root? self.vcs_info = MercurialInfo.new else raise('Unknown VCS') end self.sha = vcs_info.sha if sha.nil? self. = vcs_info. if .nil? end |
Instance Attribute Details
#capture_animate ⇒ Object
Returns the value of attribute capture_animate.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_animate @capture_animate end |
#capture_delay ⇒ Object
Returns the value of attribute capture_delay.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_delay @capture_delay end |
#capture_device ⇒ Object
Returns the value of attribute capture_device.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_device @capture_device end |
#capture_stealth ⇒ Object
Returns the value of attribute capture_stealth.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_stealth @capture_stealth end |
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def config @config end |
#main_image ⇒ Object
Returns the value of attribute main_image.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def main_image @main_image end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def end |
#sha ⇒ Object
Returns the value of attribute sha.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def sha @sha end |
#snapshot_loc ⇒ Object
Returns the value of attribute snapshot_loc.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def snapshot_loc @snapshot_loc end |
#vcs_info ⇒ Object
Returns the value of attribute vcs_info.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def vcs_info @vcs_info end |
Class Method Details
.plugins ⇒ Object
78 79 80 |
# File 'lib/lolcommits/runner.rb', line 78 def self.plugins Lolcommits::Plugin.subclasses end |
Instance Method Details
#animate? ⇒ Boolean
99 100 101 |
# File 'lib/lolcommits/runner.rb', line 99 def animate? capture_animate && (capture_animate.to_i > 0) end |
#plugins_for(position) ⇒ Object
74 75 76 |
# File 'lib/lolcommits/runner.rb', line 74 def plugins_for(position) self.class.plugins.select { |p| p.runner_order == position } end |
#run ⇒ Object
wrap run to handle things that should happen before and after this used to be handled with ActiveSupport::Callbacks, but now we’re just using a simple procedural list
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/lolcommits/runner.rb', line 33 def run # do things that need to happen before capture and plugins # do native plugins that need to happen before capture plugins_for(:precapture).each do |plugin| debug "Runner: precapture about to execute #{plugin}" plugin.new(self).execute_precapture end # do gem plugins that need to happen before capture? # do main capture to snapshot_loc run_capture # check capture succeded, file must exist if File.exist?(snapshot_loc) ## resize snapshot first resize_snapshot! # do native plugins that need to happen immediately after capture and # resize this is effectively the "image processing" phase for now, # reserve just for us and handle manually...? Lolcommits::Loltext.new(self).execute_postcapture # do native plugins that need to happen after capture plugins_for(:postcapture).each do |plugin| debug "Runner: postcapture about to execute #{plugin}" plugin.new(self).execute_postcapture end # do gem plugins that need to happen after capture? # do things that should happen last cleanup! else debug 'Runner: failed to capture a snapshot' exit 1 end end |
#run_capture ⇒ Object
the main capture
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/lolcommits/runner.rb', line 83 def run_capture puts '*** Preserving this moment in history.' unless capture_stealth self.snapshot_loc = config.raw_image(image_file_type) self.main_image = config.main_image(sha, image_file_type) capturer = Platform.capturer_class(animate?).new( :capture_device => capture_device, :capture_delay => capture_delay, :snapshot_location => snapshot_loc, :video_location => config.video_loc, :frames_location => config.frames_loc, :animated_duration => capture_animate ) capturer.capture end |