Class: Desert::Plugin
Overview
nodoc
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #controllers_path ⇒ Object
-
#find_template(template) ⇒ Object
Finds a template with the specified path.
- #framework_paths ⇒ Object
-
#helpers_path ⇒ Object
TODO: Test me.
-
#initialize(path) ⇒ Plugin
constructor
A new instance of Plugin.
-
#layouts_path ⇒ Object
The path to the layout for this plugin.
- #migration ⇒ Object
- #migration_path ⇒ Object
-
#models_path ⇒ Object
TODO: Test me.
-
#templates_path ⇒ Object
The path to the views for this plugin.
- #with_current_plugin ⇒ Object
Constructor Details
#initialize(path) ⇒ Plugin
Returns a new instance of Plugin.
4 5 6 7 |
# File 'lib/desert/plugin.rb', line 4 def initialize(path) @path = File.(path) @name = File.basename(@path) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/desert/plugin.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/desert/plugin.rb', line 3 def path @path end |
Instance Method Details
#==(other) ⇒ Object
56 57 58 |
# File 'lib/desert/plugin.rb', line 56 def ==(other) self.path == other.path end |
#controllers_path ⇒ Object
18 19 20 |
# File 'lib/desert/plugin.rb', line 18 def controllers_path "#{@path}/app/controllers" end |
#find_template(template) ⇒ Object
Finds a template with the specified path
38 39 40 41 |
# 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 ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 ⇒ Object
TODO: Test me
28 29 30 |
# File 'lib/desert/plugin.rb', line 28 def helpers_path "#{@path}/app/helpers" end |
#layouts_path ⇒ Object
The path to the layout for this plugin
33 34 35 |
# File 'lib/desert/plugin.rb', line 33 def layouts_path "#{templates_path}/layouts" end |
#migration ⇒ Object
60 61 62 |
# File 'lib/desert/plugin.rb', line 60 def migration @migration ||= PluginMigrations::Migrator.new(:up, migration_path) end |
#migration_path ⇒ Object
9 10 11 |
# File 'lib/desert/plugin.rb', line 9 def migration_path "#{@path}/db/migrate" end |
#models_path ⇒ Object
TODO: Test me
23 24 25 |
# File 'lib/desert/plugin.rb', line 23 def models_path "#{@path}/app/models" end |
#templates_path ⇒ Object
The path to the views for this plugin
14 15 16 |
# File 'lib/desert/plugin.rb', line 14 def templates_path "#{@path}/app/views" end |
#with_current_plugin ⇒ Object
64 65 66 67 68 69 70 71 72 |
# 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 |