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.
-
#git_info ⇒ Object
Returns the value of attribute git_info.
-
#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.
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 |
# File 'lib/lolcommits/runner.rb', line 12 def initialize(attributes = {}) attributes.each do |attr, val| send("#{attr}=", val) end return unless sha.nil? || .nil? self.git_info = GitInfo.new self.sha = git_info.sha if sha.nil? self. = git_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 |
#git_info ⇒ Object
Returns the value of attribute git_info.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def git_info @git_info 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 |
Class Method Details
.plugins ⇒ Object
71 72 73 |
# File 'lib/lolcommits/runner.rb', line 71 def self.plugins Lolcommits::Plugin.subclasses end |
Instance Method Details
#animate? ⇒ Boolean
92 93 94 |
# File 'lib/lolcommits/runner.rb', line 92 def animate? capture_animate && (capture_animate.to_i > 0) end |
#plugins_for(position) ⇒ Object
67 68 69 |
# File 'lib/lolcommits/runner.rb', line 67 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
26 27 28 29 30 31 32 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 |
# File 'lib/lolcommits/runner.rb', line 26 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
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/lolcommits/runner.rb', line 76 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 |