Class: Montage::Commands::Generate
- Inherits:
-
Object
- Object
- Montage::Commands::Generate
- Extended by:
- Montage::Commands
- Defined in:
- lib/montage/commands/generate.rb
Overview
Generates sprites for a project.
Constant Summary collapse
- RESET =
Terminal reset code; removes any content on the current line and moves the cursor back to the beginning.
"\r\e[0K"
- GLYPHS =
Glyphs used when doing long-running processes.
%w( ~ \\ | / )
Constants included from Montage::Commands
Class Method Summary collapse
-
.run(argv) ⇒ Object
Given a project, generates sprites.
Instance Method Summary collapse
-
#initialize(project, force) ⇒ Generate
constructor
Creates a new Generate instance.
-
#run! ⇒ Object
Runs the generator, saving the sprites and cache.
Methods included from Montage::Commands
Constructor Details
#initialize(project, force) ⇒ Generate
Creates a new Generate instance.
57 58 59 |
# File 'lib/montage/commands/generate.rb', line 57 def initialize(project, force) @project, @force, @generated = project, force, [] end |
Class Method Details
.run(argv) ⇒ Object
Given a project, generates sprites.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/montage/commands/generate.rb', line 19 def self.run(argv) # If there are any arguments, the first one is a path to a montage # config file. if argv.first and not Pathname.new(argv.first).file? say color(<<-ERROR.compress_lines, :red) Couldn't find `#{argv.first}' configuration file. Are you sure you got the path right? ERROR exit(1) end new(Montage::Project.find(argv.first || Dir.pwd), Montage::Commands.config[:force]).run! rescue Montage::MissingProject say color(<<-ERROR.compress_lines, :red) Couldn't find a Montage project in the current directory. If you want to create a new project here, run `montage init'. ERROR exit(1) rescue Montage::MissingSource, Montage::TargetNotWritable => e say Montage::Commands::BLANK say color(e..compress_lines, :red) exit(1) end |
Instance Method Details
#run! ⇒ Object
Runs the generator, saving the sprites and cache.
63 64 65 66 67 68 69 70 |
# File 'lib/montage/commands/generate.rb', line 63 def run! if generate_sprites! optimise_with_pngout! write_cache! write_sass! warn_deviants! end end |