Module: Xmvc::Helpers::Sprockets::ClassMethods

Defined in:
lib/xmvc/helpers/sprockets.rb

Instance Method Summary collapse

Instance Method Details

#xmvc_asset(vid, format) ⇒ Object

Request a Sprockets::Concatenation file

Parameters:

  • vid (Symbol)

    Vendor-id

  • format (Symbol)

    :js, :css, :sass, etc



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/xmvc/helpers/sprockets.rb', line 56

def xmvc_asset(vid, format)
  sec = secretary(vid.to_sym, format)
  vendor = @vendors[vid.to_sym]
  
  #asset_root = File.join(@xmvc_root, @xmvc_asset_root, "javascripts", vendor.class.vendor_name.to_s)
  
  #FileUtils.mkdir(dir) unless File.exists?(asset_root)
  #filename = File.join(dir, "#{@vendors[vid].build_name}.#{format.to_s}")
  @paths ||= {}
  unless source_is_unchanged?(sec)
    #sec.concatenation.save_to(filename)
    @paths[vid] = vendor.class.bundle_js(vendor, sec, File.join(@xmvc_root, Xmvc::PUBLIC_PATH))
  end
  @paths[vid] || ''
end

#xmvc_asset_root(asset_root) ⇒ Object

Defines teh Sprockets asset_root param where concatenation files will be created.



47
48
49
# File 'lib/xmvc/helpers/sprockets.rb', line 47

def xmvc_asset_root(asset_root)
  @xmvc_asset_root = File.expand_path(asset_root)
end

#xmvc_root(root) ⇒ Object

Defines the Sprockets root param xmvc_root File.join(MyApp::ROOT, “subfolder”)



40
41
42
# File 'lib/xmvc/helpers/sprockets.rb', line 40

def xmvc_root(root)
  @xmvc_root = root
end

#xmvc_vendors(vendors) ⇒ Object

Define the available vendors with Thor task API xmvc_vendors :extjs => ExtJS::API, :“extjs-mvc” => ExtJS::MVC::API



25
26
27
28
29
30
31
32
33
34
# File 'lib/xmvc/helpers/sprockets.rb', line 25

def xmvc_vendors(vendors)
  #hashify the incoming array of vendors.
  @vendors = {}
  vendors.each do |vendor|
    @vendors[vendor.vendor_name.to_sym] = vendor
  end
  
  # Add the Xmvc API
  @vendors[:app] = Xmvc::API
end