lib/xmvc/builder.rb in xmvc-0.1.3 vs lib/xmvc/builder.rb in xmvc-0.1.4

- old
+ new

@@ -1,57 +1,34 @@ +$LOAD_PATH.unshift(File.dirname(__FILE__)) module Xmvc - class BuilderManager - class << self + class Builder < Thor + + autoload :Vendor, 'builders/vendor' + + include Thor::Actions + + desc "all", "Build all assets" + def all(*params) + Xmvc.ui.warn('build all assets with sprcokets') + sec = Sprockets::Secretary.new({ + :source_files => Xmvc.environment.get("javascripts") + }) + create_file("public/javascripts/app/app-all-debug.js", sec.concatenation) + end + + desc "setup", "Initialize config file" + def setup + Xmvc.ui.warn("Builder setup") - def dispatch(name, *params) - name = name.to_sym - options = params.shift || {} - case name - when :setup - setup(options) - else - begin - Xmvc.asset_mgr(options).invoke(:build, [name]) - rescue Jammit::Error => e - raise Xmvc::BuilderError.new(e.message) - end - end - end - - private - - def setup(options) - begin - ## - # Invoke jammit init app-name so that Jammit creates it's config/assets.yml - # Note that we must pass-in the name of the newly created app @name so that - # Jammit appends that to its config_path, otherwise it would create its config file - # in the pwd. - @asset_root = options[:asset_root] || File.expand_path('.') - - javascripts = { - "application" => application_assets("javascripts", options[:application]) - } - options[:vendors].each do |vendor| - javascripts.update(vendor["name"] => vendor_assets("javascripts", vendor)) - end - - jammit = Xmvc.asset_mgr(options) - jammit.invoke(:init) - jammit.invoke(:config, ["set", "javascripts", javascripts]) - jammit.invoke(:build) - - rescue Jammit::Error => e - raise Xmvc::BuilderError.new(e.message) - end - end - - def vendor_assets(type, vendor) - vendor[type].map {|f| File.join("vendor", vendor["name"], f) } - end - - def application_assets(type, assets) - assets.map {|f| File.join(f)} - end + Xmvc.secretary = Sprockets::Secretary.new({}) + Xmvc.public_path = File.expand_path("public") + host = Vendor.new([], { + :debug => true + }) + host.invoke("app", [Xmvc.environment]) end + + private + + end end \ No newline at end of file