e18ed8118b
A pattern is a folder in the framework's templates directory. It must have a manifest file that tells compass what to install and where. Unlike the project template, a pattern can be stamped out any number of times. It is best for pattern stylesheets to only provide example usage to get the user started. All the core styles for the pattern should be distributed as part of the framework's stylesheets as mixins to facilitate easy upgrades and bug fixing on the part of the pattern's maintainer. Patterns can install stylesheets, images, javascripts, and arbitrary files. The installer will put these assets into the correct locations according to the project type (E.g. rails, stand-alone). Example Usage: compass --framework blueprint --pattern buttons
58 lines
1.2 KiB
Ruby
58 lines
1.2 KiB
Ruby
module Compass
|
|
module Installers
|
|
|
|
class Manifest
|
|
include Enumerable
|
|
|
|
# A Manifest entry
|
|
class Entry < Struct.new(:type, :from, :options)
|
|
def to
|
|
options[:to] || from
|
|
end
|
|
end
|
|
|
|
def initialize(manifest_file = nil)
|
|
@entries = []
|
|
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
|
|
def each_#{t}
|
|
@entries.select {|e| e.type == :#{t}}.each {|e| yield e}
|
|
end
|
|
END
|
|
end
|
|
|
|
type :stylesheet
|
|
type :image
|
|
type :javascript
|
|
type :file
|
|
|
|
# Enumerates over the manifest files
|
|
def each
|
|
@entries.each {|e| yield e}
|
|
end
|
|
|
|
|
|
protected
|
|
# 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 |