lib/lolcommits/runner.rb in lolcommits-0.9.0 vs lib/lolcommits/runner.rb in lolcommits-0.9.1.pre1
- old
+ new
@@ -5,12 +5,10 @@
class Runner
attr_accessor :capture_delay, :capture_stealth, :capture_device, :message,
:sha, :snapshot_loc, :main_image, :config, :vcs_info,
:capture_animate
- include Methadone::CLILogging
-
def initialize(attributes = {})
attributes.each do |attr, val|
send("#{attr}=", val)
end
@@ -83,59 +81,52 @@
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(
+ capturer = Platform.capturer_class(capture_animated?).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
- def animate?
- capture_animate && (capture_animate.to_i > 0)
+ def capture_animated?
+ capture_animate > 0
end
private
- # def capturer_class
- # capturer_module = 'Lolcommits'
- # Object.const_get(capturer_module).const_get(Platform.capturer_class(animate?))
- # end
-
def image_file_type
- animate? ? 'gif' : 'jpg'
+ capture_animated? ? 'gif' : 'jpg'
end
- end
- protected
-
- def resize_snapshot!
- debug 'Runner: resizing snapshot'
- image = MiniMagick::Image.open(snapshot_loc)
- if image[:width] > 640 || image[:height] > 480
- # this is ghetto resize-to-fill
- image.combine_options do |c|
- c.resize '640x480^'
- c.gravity 'center'
- c.extent '640x480'
+ def resize_snapshot!
+ debug 'Runner: resizing snapshot'
+ image = MiniMagick::Image.open(snapshot_loc)
+ if image[:width] > 640 || image[:height] > 480
+ # this is ghetto resize-to-fill
+ image.combine_options do |c|
+ c.resize '640x480^'
+ c.gravity 'center'
+ c.extent '640x480'
+ end
+ debug "Runner: writing resized image to #{snapshot_loc}"
+ image.write snapshot_loc
end
- debug "Runner: writing resized image to #{snapshot_loc}"
- image.write snapshot_loc
+ debug "Runner: copying resized image to #{main_image}"
+ FileUtils.cp(snapshot_loc, main_image)
end
- debug "Runner: copying resized image to #{main_image}"
- FileUtils.cp(snapshot_loc, main_image)
- end
- def cleanup!
- debug 'Runner: running cleanup'
- # clean up the captured image and any other raw assets
- FileUtils.rm(snapshot_loc)
- FileUtils.rm_f(config.video_loc)
- FileUtils.rm_rf(config.frames_loc)
+ def cleanup!
+ debug 'Runner: running cleanup'
+ # clean up the captured image and any other raw assets
+ FileUtils.rm(snapshot_loc)
+ FileUtils.rm_f(config.video_loc)
+ FileUtils.rm_rf(config.frames_loc)
+ end
end
end