-
-
Save alloy/225050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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