Class: Catapult::CLI
- Inherits:
-
Thor
- Object
- Thor
- Catapult::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/catapult/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
11 12 13 |
# File 'lib/catapult/cli.rb', line 11 def self.source_root File.('../../..', __FILE__) end |
Instance Method Details
#build(*assets) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/catapult/cli.rb', line 20 def build(*assets) target = Pathname([:target] || './public/assets') if [:compile] Catapult.environment.js_compressor = Compressor::JS.new Catapult.environment.css_compressor = Compressor::CSS.new end say "Building: #{Catapult.root}" Catapult.environment.each_logical_path(assets) do |logical_path| if asset = Catapult.environment.find_asset(logical_path) filename = target.join(logical_path) FileUtils.mkpath(filename.dirname) say "Write asset: #{filename}" asset.write_to(filename) end end end |
#new(name) ⇒ Object
68 69 70 |
# File 'lib/catapult/cli.rb', line 68 def new(name) directory('templates/app', name) end |
#server ⇒ Object
44 45 46 47 48 49 |
# File 'lib/catapult/cli.rb', line 44 def server Rack::Server.start( :Port => [:port] || 9292, :app => Catapult.app ) end |
#watch(*assets) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/catapult/cli.rb', line 55 def watch(*assets) say "Watching: #{Catapult.root}" build(*assets) paths = Catapult.environment.paths paths = paths.select {|p| File.exists?(p) } Listen.to(*paths) { build } end |