class Lolcommits::CLI::TimelapseGif

Creates an animated timeline GIF of lolcommits history.

Public Class Methods

new(config) click to toggle source

param config [Lolcommits::Configuration]

# File lib/lolcommits/cli/timelapse_gif.rb, line 10
def initialize(config)
  @configuration = config
end

Public Instance Methods

run(args = nil) click to toggle source

Runs the history timeline animator task thingy param args [String] the arg passed to the gif command on CLI (optional)

# File lib/lolcommits/cli/timelapse_gif.rb, line 16
def run(args = nil)
  Fatals.die_if_not_git_repo!

  case args
  when 'today'
    lolimages = @configuration.jpg_images_today
    filename  = "#{Date.today}.gif"
  else
    lolimages = @configuration.jpg_images
    filename  = 'archive.gif'
  end

  if lolimages.empty?
    warn 'No lolcommits have been captured for this time yet.'
    exit 1
  end

  puts '*** Generating animated gif.'

  gif = MiniMagick::Image.new File.join @configuration.archivedir, filename

  # This is for ruby 1.8.7, *lolimages just doesn't work with ruby 187
  gif.run_command('convert', *['-delay', '50', '-loop', '0', lolimages, gif.path.to_s].flatten)

  puts "*** #{gif.path} generated."
end