class Frontsau::ThorApp
Public Instance Methods
clean()
click to toggle source
# File lib/frontsau/thor_app.rb, line 41 def clean Dir[Frontsau.config[:assets][:path]+"/*"].each do |f| remove_file f end end
compile()
click to toggle source
# File lib/frontsau/thor_app.rb, line 7 def compile say "Dumping assets:" inside Frontsau.assets_path do paths = Frontsau.sprockets.compilable_paths manifest = {} p = ProgressBar.create( total: paths.count, format: " %p% | %B" ) paths.each do |path| p.increment begin asset = Frontsau.sprockets[path] data = asset.to_s create_file path, data, force: true, verbose: false manifest[path] = { digest: asset.digest, modified: asset.mtime } rescue Exception => e say "" say "" say "#{e.class.name} ", :red say "#{e.message}" say "" say "" end end say "" create_file "manifest.json", JSON.pretty_generate(manifest), force: true end end
debug(what = "all")
click to toggle source
# File lib/frontsau/thor_app.rb, line 69 def debug what = "all" puts "" if what == "all" Frontsau.sprockets.each_logical_path do |path| puts " #{path}" end elsif Frontsau.sprockets.compilable_paths.each do |path| puts " #{path}" end end puts "" end
haml(input)
click to toggle source
# File lib/frontsau/thor_app.rb, line 105 def haml input if !File.exist? input raise "Input file does not exist!" end path = File.dirname input name = File.basename input, '.haml' tool_root = File.dirname(File.dirname(File.dirname(__FILE__))) cmd = File.join(tool_root,"bin/frontsau-phaml-compiler") html = `#{cmd} '#{input}'` output = File.join(path,"#{name}.php") File.write output, html end
server()
click to toggle source
# File lib/frontsau/thor_app.rb, line 84 def server app = Rack::Builder.new do use Rack::CommonLogger use Rack::ShowExceptions use Rack::Cors do allow do origins '*' resource '*' end end map "/" do run Frontsau::Assets::Rack.new end map "/#{Frontsau.config[:assets][:path]}" do run Frontsau.sprockets end end Rack::Handler::WEBrick.run app, :Port => 9292 end
watch()
click to toggle source
# File lib/frontsau/thor_app.rb, line 49 def watch compile say "Watching for asset changes:" Frontsau::Assets::Watcher.new do |path| begin asset = Frontsau.sprockets[path] create_file path, asset.to_s, force: true, verbose: true rescue Exception => e say "" say "" say "#{e.class.name} ", :red say "#{e.message}" say "" say "" end end end