Class: Xmvc::Plugin
- Inherits:
-
Object
- Object
- Xmvc::Plugin
- Defined in:
- lib/xmvc/plugin.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Plugin
constructor
A new instance of Plugin.
- #install ⇒ Object
- #install_assets ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(name) ⇒ Plugin
Returns a new instance of Plugin.
36 37 38 39 40 41 |
# File 'lib/xmvc/plugin.rb', line 36 def initialize name @name = @directory = name @type = @name =~ /git:\/\// ? 'git' : 'dir' @public_directory = "vendor/plugins/#{@name}/public" end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
34 35 36 |
# File 'lib/xmvc/plugin.rb', line 34 def directory @directory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/xmvc/plugin.rb', line 34 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
34 35 36 |
# File 'lib/xmvc/plugin.rb', line 34 def type @type end |
Class Method Details
.all_plugins ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/xmvc/plugin.rb', line 25 def self.all_plugins pluginsDir = 'vendor/plugins' #Gets the name of each plugin directory inside vendor/plugins and calls self.plugin with it Dir.entries(pluginsDir).select {|fileName| File.directory?("#{pluginsDir}/#{fileName}") && (fileName =~ /^\./) != 0 } end |
.dispatch ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/xmvc/plugin.rb', line 6 def self.dispatch meth = ARGV.shift.downcase name = ARGV.shift if name == 'all' self.send("#{meth}_all") else ExtMVC::Plugin.new(name).send(meth) end end |
.install_all ⇒ Object
17 18 19 |
# File 'lib/xmvc/plugin.rb', line 17 def self.install_all self.all_plugins.each {|pluginName| ExtMVC::Plugin.new(pluginName).install} end |
.uninstall_all ⇒ Object
21 22 23 |
# File 'lib/xmvc/plugin.rb', line 21 def self.uninstall_all self.all_plugins.each {|pluginName| ExtMVC::Plugin.new(pluginName).uninstall} end |
Instance Method Details
#install ⇒ Object
43 44 45 |
# File 'lib/xmvc/plugin.rb', line 43 def install install_assets end |
#install_assets ⇒ Object
47 48 49 |
# File 'lib/xmvc/plugin.rb', line 47 def install_assets install_assets_from_directory(@public_directory) if File.exists?(@public_directory) end |
#uninstall ⇒ Object
51 52 53 54 55 |
# File 'lib/xmvc/plugin.rb', line 51 def uninstall if File.exists?(@public_directory) end end |