Skip to content

Instantly share code, notes, and snippets.

@mattetti
Forked from alloy/gist:225050
Created December 18, 2009 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattetti/259716 to your computer and use it in GitHub Desktop.
Save mattetti/259716 to your computer and use it in GitHub Desktop.
# Install kicker on osx: sudo gem install kicker --source http://gemcutter.org
#
# Place a `.kick' file with this code in the root of your project, which contains the file to watch.
# Then start running kicker from the project root: $ kicker
module Mockup
FILE_TO_WATCH = 'mockup-1.psd'
def self.last_exported_version
FileUtils.mkdir_p 'output'
if version = Dir.glob("output/*.png").sort.last
$1.to_i if version =~ /mockup-(\d+)\.png$/
end
end
def self.version
unless @version and File.exist?('output')
@version = last_exported_version || 0
end
@version += 1
end
def self.create_export!
execute "sips #{FILE_TO_WATCH} -s format png --out output/mockup-#{version}.png"
end
def self.call(files)
create_export! if files.delete(FILE_TO_WATCH)
end
end
process Mockup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment