lib/assetify/dsl.rb in assetify-1.0.0.rc1 vs lib/assetify/dsl.rb in assetify-1.0.0
- old
+ new
@@ -1,11 +1,10 @@
module Assetify
class DSL
attr_reader :assets
-
-
+
#
# Makes a pkg, a gz/tar/zip asset/
#
# pkg :foo, "http://to.tgz" do
# end
@@ -20,11 +19,10 @@
@pkg.unpack_to_vendor
end
assets
end
-
#
# Makes a group, a namspace for the assets.
#
# group :foo do
# end
@@ -41,18 +39,16 @@
if @pkg
@pkg.get(regex).each do |path, data|
next if path =~ /\/$/ # dont let dirs get in... ugly
ext, *name = path.split(".").reverse
name = name.reverse.join(".").split("/").last
- (@assets ||= []) << Asset.new(ext, name, path, nil, {
- :pkg => @pkg,
- :to => to})# h.split(".").last, )
+ @assets ||= []
+ @assets << Asset.new(ext, name, path, nil, { :pkg => @pkg , :to => to } )
end
end
end
-
#
# Parse the assets.
#
# js "foo", "http://foo.com"
# js "foo", "http://foo.com", :to => "/other/place"
@@ -60,26 +56,27 @@
def method_missing method, name, uri, *params
params, ver = params.partition { |param| param.is_a?(Hash) }
opts = {:ns => @ns, :pkg => @pkg}
params.each { |hsh| opts.merge! hsh }
ver = ver[0]
- (@assets ||= []) << Asset.new(method.to_sym, name, uri, ver, opts)
+ @assets ||= []
+ @assets << Asset.new(method.to_sym, name, uri, ver, opts)
end
#
# Global command, detects the filetype
#
# a "jquery", "http://...jquery.js"
#
def a name, url, *params
- ext, *rest = url.split(".").reverse
- send(ext, name, url)
+ extension = url.split(".").last
+ send(extension, name, url)
end
-
- # Create Jsfile assets path setters
#
+ # Create Assetfile assets path setters
+ #
# javascript "new/path"
# ...
Assetify::ASSETS.each do |asset|
define_method asset do |path|
Opt[asset] = path
@@ -92,12 +89,12 @@
#
# DSL.parse()
#
def self.parse chunk
- # puts "Assetify - Error Parsing 'Jsfile'."
+ # puts "Assetify - Error Parsing 'Assetfile'."
# Instance eval with 2nd, 3rd args to the rescue
- new.instance_eval(chunk, "Jsfile", 1)
+ new.instance_eval(chunk, "Assetfile", 1)
end
end
end