Skip to content

Instantly share code, notes, and snippets.

@Jonnotie
Forked from alloy/gist:225050
Created November 3, 2009 14:09
Show Gist options
  • Save Jonnotie/225071 to your computer and use it in GitHub Desktop.
Save Jonnotie/225071 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.psd'
FOLDER = 'output'
def self.last_exported_version
FileUtils.mkdir_p FOLDER
Dir.glob("#{FOLDER}/mockup-*.png").map do |f|
f.match(/mockup-(\d+)\.png$/)[1].to_i
end.sort.last
end
def self.version
unless @version and File.exist?(FOLDER)
@version = last_exported_version || 0
end
@version += 1
end
def self.create_export!
execute "sips #{FILE_TO_WATCH} -s format png --out #{FOLDER}/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