class Desert::Plugin

Attributes

name[R]
path[R]

Public Class Methods

new(path) click to toggle source
# File lib/desert/plugin.rb, line 4
def initialize(path)
  @path = File.expand_path(path)
  @name = File.basename(@path)
end

Public Instance Methods

==(other) click to toggle source
# File lib/desert/plugin.rb, line 56
def ==(other)
  self.path == other.path
end
controllers_path() click to toggle source
# File lib/desert/plugin.rb, line 18
def controllers_path
  "#{@path}/app/controllers"
end
find_template(template) click to toggle source

Finds a template with the specified path

# File lib/desert/plugin.rb, line 38
def find_template(template)
  template_path = "#{templates_path}/#{template}"
  File.exists?(template_path) ? template_path : nil
end
framework_paths() click to toggle source
# File lib/desert/plugin.rb, line 43
def framework_paths
  # TODO: Don't include dirs for frameworks that are not used
  %w(
    railties
    railties/lib
    actionpack/lib
    activesupport/lib
    activerecord/lib
    actionmailer/lib
    actionwebservice/lib
  ).map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
end
helpers_path() click to toggle source

TODO: Test me

# File lib/desert/plugin.rb, line 28
def helpers_path
  "#{@path}/app/helpers"
end
layouts_path() click to toggle source

The path to the layout for this plugin

# File lib/desert/plugin.rb, line 33
def layouts_path
  "#{templates_path}/layouts"
end
migration() click to toggle source
# File lib/desert/plugin.rb, line 60
def migration
  @migration ||= PluginMigrations::Migrator.new(:up, migration_path)
end
migration_path() click to toggle source
# File lib/desert/plugin.rb, line 9
def migration_path
  "#{@path}/db/migrate"
end
models_path() click to toggle source

TODO: Test me

# File lib/desert/plugin.rb, line 23
def models_path
  "#{@path}/app/models"
end
templates_path() click to toggle source

The path to the views for this plugin

# File lib/desert/plugin.rb, line 14
def templates_path
  "#{@path}/app/views"
end
with_current_plugin() { || ... } click to toggle source
# File lib/desert/plugin.rb, line 64
def with_current_plugin
  old_plugin = PluginMigrations::Migrator.current_plugin
  begin
    PluginMigrations::Migrator.current_plugin = self
    yield
  ensure
    PluginMigrations::Migrator.current_plugin = old_plugin
  end
end