Class: Compass::Installers::Manifest

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/compass/installers/manifest.rb

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest_file = nil, options = {}) ⇒ Manifest

Returns a new instance of Manifest.



15
16
17
18
19
20
21
# File 'lib/compass/installers/manifest.rb', line 15

def initialize(manifest_file = nil, options = {})
  @entries = []
  @options = options
  @generate_config = true
  @compile_after_generation = true
  parse(manifest_file) if manifest_file
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/compass/installers/manifest.rb', line 14

def options
  @options
end

#welcome_message_optionsObject (readonly)

Returns the value of attribute welcome_message_options.



87
88
89
# File 'lib/compass/installers/manifest.rb', line 87

def welcome_message_options
  @welcome_message_options
end

Class Method Details

.known_extensionsObject



23
24
25
# File 'lib/compass/installers/manifest.rb', line 23

def self.known_extensions
  @known_extensions ||= {}
end

.plural_typesObject



27
28
29
# File 'lib/compass/installers/manifest.rb', line 27

def self.plural_types
  @plural_types ||= {}
end

.type(t, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/compass/installers/manifest.rb', line 31

def self.type(t, options = {})
  Array(options[:extensions]).each do |ext|
    self.known_extensions[ext] = t
  end
  self.plural_types[options[:plural]] = t if options[:plural]
  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

Instance Method Details

#compile?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/compass/installers/manifest.rb', line 119

def compile?
  @compile_after_generation
end

#description(value = nil) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/compass/installers/manifest.rb', line 102

def description(value = nil)
  if value
    @description = value
  else
    @description
  end
end

#discover(type) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/compass/installers/manifest.rb', line 57

def discover(type)
  type = self.class.plural_types[type] || type
  dir = File.dirname(@manifest_file)
  Dir.glob("#{dir}/**/*").each do |file|
    next if /manifest\.rb/ =~ file
    short_name = file[(dir.length+1)..-1]
    options = {}
    ext = if File.extname(short_name) == ".erb"
      options[:erb] = true
      File.extname(short_name[0..-5])
    else
      File.extname(short_name)
    end[1..-1]
    file_type = self.class.known_extensions[ext]
    file_type = :file if file_type.nil?
    file_type = :directory if File.directory?(file)
    if type == :all || type == file_type
      send(file_type, short_name, options)
    end
  end
end

#eachObject

Enumerates over the manifest files



111
112
113
# File 'lib/compass/installers/manifest.rb', line 111

def each
  @entries.each {|e| yield e}
end

#generate_config?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/compass/installers/manifest.rb', line 115

def generate_config?
  @generate_config
end

#help(value = nil) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/compass/installers/manifest.rb', line 79

def help(value = nil)
  if value
    @help = value
  else
    @help
  end
end

#welcome_message(value = nil, options = {}) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/compass/installers/manifest.rb', line 89

def welcome_message(value = nil, options = {})
  if value
    @welcome_message = value
    @welcome_message_options = options
  else
    @welcome_message
  end
end