lib/lolcommits/runner.rb in lolcommits-0.4.6 vs lib/lolcommits/runner.rb in lolcommits-0.5.0.pre1
- old
+ new
@@ -2,11 +2,11 @@
PLUGINS = Lolcommits::Plugin.subclasses
class Runner
attr_accessor :capture_delay, :capture_device, :message, :sha,
:snapshot_loc, :main_image, :repo, :config, :repo_internal_path,
- :font
+ :font, :capture_animate
include Methadone::CLILogging
include ActiveSupport::Callbacks
define_callbacks :run
set_callback :run, :before, :execute_lolcommits_tranzlate
@@ -37,22 +37,38 @@
def run
die_if_rebasing!
run_callbacks :run do
puts "*** Preserving this moment in history."
- self.snapshot_loc = self.config.raw_image
- self.main_image = self.config.main_image(self.sha)
- capturer = "Lolcommits::Capture#{Configuration.platform}".constantize.new(
+ self.snapshot_loc = self.config.raw_image(image_file_type)
+ self.main_image = self.config.main_image(self.sha, image_file_type)
+ capturer = capturer_class.new(
:capture_device => self.capture_device,
:capture_delay => self.capture_delay,
:snapshot_location => self.snapshot_loc,
- :font => self.font
+ :font => self.font,
+ :video_location => self.config.video_loc,
+ :frames_location => self.config.frames_loc,
+ :animated_duration => self.capture_animate
)
capturer.capture
resize_snapshot!
end
end
+
+ def animate?
+ capture_animate && (capture_animate > 0)
+ end
+
+ private
+ def capturer_class
+ "Lolcommits::Capture#{Configuration.platform}#{animate? ? 'Animated' : nil}".constantize
+ end
+
+ def image_file_type
+ animate? ? 'gif' : 'jpg'
+ end
end
protected
def die_if_rebasing!
debug "Runner: Making sure user isn't rebasing"
@@ -82,11 +98,13 @@
FileUtils.cp(self.snapshot_loc, self.main_image)
end
def cleanup!
debug "Runner: running cleanup"
- #clean up the captured image
+ # clean up the captured image and any other raw assets
FileUtils.rm(self.snapshot_loc)
+ FileUtils.rm_f(self.config.video_loc)
+ FileUtils.rm_rf(self.config.frames_loc)
end
# register a method called "execute_lolcommits_#{plugin_name}"
# for each subclass of plugin. these methods should be used as
# callbacks to the run method.