Module: Staticpress::Plugin

Extended by:
Helpers
Defined in:
lib/staticpress/plugin.rb

Class Method Summary collapse

Methods included from Helpers

config, extensionless_basename, extensionless_path, hash_from_array, hash_from_match_data, paginate, settings, spider_map, titleize

Class Method Details

.activate_enabledObject



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

def self.activate_enabled
  config.plugins.each do |plugin_name|
    require find(plugin_name).to_s
  end
end

.find(name) ⇒ Object

Raises:



11
12
13
14
15
16
17
18
19
20
# File 'lib/staticpress/plugin.rb', line 11

def self.find(name)
  file_name = name.end_with?('.rb') ? name : "#{name}.rb"

  plugin_locations.each do |location|
    file = location + file_name
    return file if file.file?
  end

  raise Staticpress::Error, "Plugin not found: #{name}"
end

.plugin_locationsObject



22
23
24
25
26
27
# File 'lib/staticpress/plugin.rb', line 22

def self.plugin_locations
  [
    ((Staticpress.blog_path + config.plugins_path) if config.plugins_path),
    (Staticpress.root + 'staticpress' + 'plugins')
  ].compact
end