Class: Henshin::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/henshin/plugin.rb

Direct Known Subclasses

Generator, Layoutor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Plugin

Create a new instance of Plugin

Parameters:

  • site (Site)

    that the plugin belongs to



27
28
29
30
31
32
# File 'lib/henshin/plugin.rb', line 27

def initialize(site)
  @extensions = {:input => [],
                 :output => ''}
  @config = {}
  @priority = 3
end

Instance Attribute Details

#configHash{Symbol => Object}

Returns the config for the plugin.

Returns:

  • (Hash{Symbol => Object})

    the config for the plugin



17
18
19
# File 'lib/henshin/plugin.rb', line 17

def config
  @config
end

#extensionsHash{:input, :output => Array, String}

Returns the file extensions that can be read by the plugin and the extension of the output.

Examples:


@extensions = {:input => ['md', 'markdown'],
               :output => 'html'}

Returns:

  • (Hash{:input, :output => Array, String})

    the file extensions that can be read by the plugin and the extension of the output



13
14
15
# File 'lib/henshin/plugin.rb', line 13

def extensions
  @extensions
end

#priorityInteger

Returns The plugins are sorted on priority, high priority plugins are called first. You could really use any number, but stick to 1 to 5.

Returns:

  • (Integer)

    The plugins are sorted on priority, high priority plugins are called first. You could really use any number, but stick to 1 to 5.



22
23
24
# File 'lib/henshin/plugin.rb', line 22

def priority
  @priority
end

Class Method Details

.subclassesArray

Finds all classes that subclass this particular class

Returns:

  • (Array)

    an array of class objects

See Also:



39
40
41
42
43
44
45
46
47
48
# File 'lib/henshin/plugin.rb', line 39

def self.subclasses     
  r = Henshin.constants.find_all do |c_klass| 
    if (c_klass != c_klass.upcase) && (Henshin.const_get(c_klass).is_a?(Class))
      self > Henshin.const_get(c_klass)
    else
      nil
    end
  end
  r.collect {|k| Henshin.const_get(k)}
end

Instance Method Details

#<=>(other) ⇒ Object

Plugins are sorted by priority



51
52
53
# File 'lib/henshin/plugin.rb', line 51

def <=>(other)
  self.priority <=> other.priority
end