Class: Stasis::Plugin

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

Direct Known Subclasses

Before, Helpers, Ignore, Instead, Layout, Priority, Render

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Attribute Details

+ (Object) _methods

`Hash` -- Keys are the "bind as" method names and values are the actual method names on the `Plugin` instance.



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

def _methods
  @_methods
end

Class Method Details

+ (Object) _priority

`Fixnum` -- The execution priority for this plugin (defaults to 0).



19
# File 'lib/stasis/plugin.rb', line 19

def _priority; @priority || 0; end

+ (Object) inherited(subclass)



5
6
7
8
# File 'lib/stasis/plugin.rb', line 5

def inherited(subclass)
  @plugins ||= []
  @plugins << subclass
end

+ (Object) plugins



10
11
12
# File 'lib/stasis/plugin.rb', line 10

def plugins
  (@plugins || []).dup
end

+ (Object) priority(number)

Class method to set priority on the `Plugin`.



55
56
57
# File 'lib/stasis/plugin.rb', line 55

def priority(number)
  @priority = number
end

Instance Method Details

- (Boolean) _match_key?(hash, match_key)

Helper method provided for built-in Stasis plugins. Returns an `Array` of values of a `Hash` whose keys are `nil`, a literal match, or a pattern match.

Returns:

  • (Boolean)


73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/stasis/plugin.rb', line 73

def _match_key?(hash, match_key)
  hash.inject([]) do |array, (key, value)|
    if key.nil?
      array << value
    elsif key.is_a?(::String) && key == match_key
      array << value
    elsif key.is_a?(::Regexp) && key =~ match_key
      array << value
    end
    array
  end
end

- (Boolean) _within?(within_path, path = @stasis.path)

Helper method provided for built-in Stasis plugins. Returns a boolean value denoting whether or not a path is within another path.

Returns:

  • (Boolean)


62
63
64
65
66
67
68
69
# File 'lib/stasis/plugin.rb', line 62

def _within?(within_path, path=@stasis.path)
  if within_path && path
    dir = File.dirname(within_path)
    path[0..dir.length-1] == dir
  else
    true
  end
end