lib/assetify/dsl.rb in assetify-0.7.0.rc1 vs lib/assetify/dsl.rb in assetify-1.0.0.rc1
- old
+ new
@@ -1,14 +1,17 @@
module Assetify
class DSL
attr_reader :assets
- def set_namespace(name)
- @ns = @ns.nil? ? name : "#{@ns}/#{name}"
- end
+ #
+ # Makes a pkg, a gz/tar/zip asset/
+ #
+ # pkg :foo, "http://to.tgz" do
+ # end
+ #
def pkg name, url, opts = {}, &block
@pkg = Pkg.new name, url
if block_given?
set_namespace name unless opts[:shallow]
instance_exec &block
@@ -17,10 +20,17 @@
@pkg.unpack_to_vendor
end
assets
end
+
+ #
+ # Makes a group, a namspace for the assets.
+ #
+ # group :foo do
+ # end
+ #
def group name, &block
set_namespace name
instance_exec &block
@ns = nil
assets
@@ -38,18 +48,14 @@
:to => to})# h.split(".").last, )
end
end
end
- # Create assets path setters
- Assetify::ASSETS.each do |asset|
- define_method asset do |path|
- Opt[asset] = path
- end
- end
#
+ # Parse the assets.
+ #
# js "foo", "http://foo.com"
# js "foo", "http://foo.com", :to => "/other/place"
#
def method_missing method, name, uri, *params
params, ver = params.partition { |param| param.is_a?(Hash) }
@@ -57,15 +63,41 @@
params.each { |hsh| opts.merge! hsh }
ver = ver[0]
(@assets ||= []) << Asset.new(method.to_sym, name, uri, ver, opts)
end
- class << self
+ #
+ # Global command, detects the filetype
+ #
+ # a "jquery", "http://...jquery.js"
+ #
+ def a name, url, *params
+ ext, *rest = url.split(".").reverse
+ send(ext, name, url)
+ end
- def parse io
- new.instance_eval(io) #.assets
+
+ # Create Jsfile assets path setters
+ #
+ # javascript "new/path"
+ # ...
+ Assetify::ASSETS.each do |asset|
+ define_method asset do |path|
+ Opt[asset] = path
end
+ end
+ def set_namespace name
+ @ns = @ns.nil? ? name : "#{@ns}/#{name}"
+ end
+
+ #
+ # DSL.parse()
+ #
+ def self.parse chunk
+ # puts "Assetify - Error Parsing 'Jsfile'."
+ # Instance eval with 2nd, 3rd args to the rescue
+ new.instance_eval(chunk, "Jsfile", 1)
end
end
end