2009-02-01 22:23:16 +00:00
|
|
|
module Compass
|
|
|
|
module Installers
|
|
|
|
|
|
|
|
class Manifest
|
2009-04-03 08:06:23 +00:00
|
|
|
include Enumerable
|
2009-02-01 22:23:16 +00:00
|
|
|
|
|
|
|
# A Manifest entry
|
2009-02-03 02:45:25 +00:00
|
|
|
class Entry < Struct.new(:type, :from, :options)
|
|
|
|
def to
|
|
|
|
options[:to] || from
|
|
|
|
end
|
|
|
|
end
|
2009-02-01 22:23:16 +00:00
|
|
|
|
2009-07-27 07:12:36 +00:00
|
|
|
attr_reader :options
|
|
|
|
def initialize(manifest_file = nil, options = {})
|
2009-02-01 22:23:16 +00:00
|
|
|
@entries = []
|
2009-07-27 07:12:36 +00:00
|
|
|
@options = options
|
|
|
|
@generate_config = true
|
|
|
|
@compile_after_generation = true
|
2009-02-01 22:23:16 +00:00
|
|
|
parse(manifest_file) if manifest_file
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.type(t)
|
|
|
|
eval <<-END
|
|
|
|
def #{t}(from, options = {})
|
|
|
|
@entries << Entry.new(:#{t}, from, options)
|
|
|
|
end
|
|
|
|
def has_#{t}?
|
|
|
|
@entries.detect {|e| e.type == :#{t}}
|
|
|
|
end
|
2009-02-03 18:01:06 +00:00
|
|
|
def each_#{t}
|
|
|
|
@entries.select {|e| e.type == :#{t}}.each {|e| yield e}
|
|
|
|
end
|
2009-02-01 22:23:16 +00:00
|
|
|
END
|
|
|
|
end
|
|
|
|
|
|
|
|
type :stylesheet
|
|
|
|
type :image
|
|
|
|
type :javascript
|
|
|
|
type :file
|
2009-08-10 04:33:48 +00:00
|
|
|
type :html
|
2009-02-01 22:23:16 +00:00
|
|
|
|
|
|
|
# Enumerates over the manifest files
|
|
|
|
def each
|
|
|
|
@entries.each {|e| yield e}
|
|
|
|
end
|
|
|
|
|
2009-07-27 07:12:36 +00:00
|
|
|
def generate_config?
|
|
|
|
@generate_config
|
|
|
|
end
|
|
|
|
|
|
|
|
def compile?
|
|
|
|
@compile_after_generation
|
|
|
|
end
|
2009-02-01 22:23:16 +00:00
|
|
|
|
|
|
|
protected
|
2009-07-27 07:12:36 +00:00
|
|
|
|
|
|
|
def no_configuration_file!
|
|
|
|
@generate_config = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def skip_compilation!
|
|
|
|
@compile_after_generation = false
|
|
|
|
end
|
|
|
|
|
2009-02-01 22:23:16 +00:00
|
|
|
# parses a manifest file which is a ruby script
|
|
|
|
# evaluated in a Manifest instance context
|
|
|
|
def parse(manifest_file)
|
|
|
|
open(manifest_file) do |f|
|
|
|
|
eval(f.read, instance_binding, manifest_file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def instance_binding
|
|
|
|
binding
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|