Class: Jekyll::Plugin

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

Direct Known Subclasses

Converter, Generator

Constant Summary collapse

PRIORITIES =
{ :lowest => -100,
:low => -10,
:normal => 0,
:high => 10,
:highest => 100 }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Plugin

Initialize a new plugin. This should be overridden by the subclass.

config - The Hash of configuration options.

Returns a new instance.



71
72
73
# File 'lib/jekyll/plugin.rb', line 71

def initialize(config = {})
  # no-op for default
end

Class Method Details

.<=>(other) ⇒ Object

Spaceship is priority [higher -> lower]

other - The class to be compared.

Returns -1, 0, 1.



62
63
64
# File 'lib/jekyll/plugin.rb', line 62

def self.<=>(other)
  PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
end

.inherited(base) ⇒ Object

Install a hook so that subclasses are recorded. This method is only ever called by Ruby itself.

base - The Class subclass.

Returns nothing.



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

def self.inherited(base)
  subclasses << base
  subclasses.sort!
end

.priority(priority = nil) ⇒ Object

Get or set the priority of this plugin. When called without an argument it returns the priority. When an argument is given, it will set the priority.

priority - The Symbol priority (default: nil). Valid options are:

:lowest, :low, :normal, :high, :highest

Returns the Symbol priority.



36
37
38
39
40
41
# File 'lib/jekyll/plugin.rb', line 36

def self.priority(priority = nil)
  if priority && PRIORITIES.has_key?(priority)
    @priority = priority
  end
  @priority || :normal
end

.safe(safe = nil) ⇒ Object

Get or set the safety of this plugin. When called without an argument it returns the safety. When an argument is given, it will set the safety.

safe - The Boolean safety (default: nil).

Returns the safety Boolean.



50
51
52
53
54
55
# File 'lib/jekyll/plugin.rb', line 50

def self.safe(safe = nil)
  if safe
    @safe = safe
  end
  @safe || false
end

.subclassesObject

The list of Classes that have been subclassed.

Returns an Array of Class objects.



24
25
26
# File 'lib/jekyll/plugin.rb', line 24

def self.subclasses
  @subclasses ||= []
end