Class: Alula::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/alula/generator.rb

Direct Known Subclasses

Archive, FeedBuilder, FeedJSON, Paginate, Sitemap

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, opts) ⇒ Generator

Returns a new instance of Generator.



29
30
31
32
# File 'lib/alula/generator.rb', line 29

def initialize(options, opts)
  @options = options
  @site = opts.delete(:site)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/alula/generator.rb', line 10

def options
  @options
end

#siteObject (readonly)

Returns the value of attribute site.



11
12
13
# File 'lib/alula/generator.rb', line 11

def site
  @site
end

Class Method Details

.generatorsObject



7
# File 'lib/alula/generator.rb', line 7

def self.generators; @@generators ||= {}; end

.load(opts) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/alula/generator.rb', line 13

def self.load(opts)
  name = opts.delete(:type).to_s
  options = opts.delete(:options)
  
  # Try to find our generator
  # cls_name = self.constants.select {|t| t.to_s.downcase == type.downcase}.first
  # if cls_name
    # cls = self.const_get(cls_name)
    # gen = cls.new(options, opts)
  # end
  if generators[name] and !(!!options == options and !options)
    generator = generators[name]
    return generator.new(options, opts)
  end
end

.register(name, klass) ⇒ Object

autoload :Paginate, ‘alula/generators/paginate’ autoload :FeedBuilder, ‘alula/generators/feedbuilder’ autoload :Sitemap, ‘alula/generators/sitemap’



6
# File 'lib/alula/generator.rb', line 6

def self.register(name, klass); generators[name.to_s] = klass; end

Instance Method Details

#allow_compressing?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/alula/generator.rb', line 38

def allow_compressing?
  :high
end

#generatorsObject



8
# File 'lib/alula/generator.rb', line 8

def generators; self.class.generators; end

#substitutes(locale, item) ⇒ Object



34
35
36
# File 'lib/alula/generator.rb', line 34

def substitutes(locale, item)
  {}
end