Class: Sashimi::Plugin
- Inherits:
-
Object
- Object
- Sashimi::Plugin
- Defined in:
- lib/sashimi/plugin.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.list ⇒ Object
List all installed plugins.
Instance Method Summary collapse
-
#about ⇒ Object
Returns the informations about the plugin.
-
#add ⇒ Object
Add to a Rails app.
-
#guess_name ⇒ Object
Try to guess the plugin name.
-
#initialize(name, url = '') ⇒ Plugin
constructor
A new instance of Plugin.
-
#install ⇒ Object
Install the plugin.
-
#repository ⇒ Object
:nodoc:.
-
#summary ⇒ Object
Return the plugin summary.
-
#to_hash ⇒ Object
Serialize the plugin to
Hash
format. -
#uninstall ⇒ Object
Uninstall the plugin.
-
#update ⇒ Object
Update the plugin.
Constructor Details
#initialize(name, url = '') ⇒ Plugin
Returns a new instance of Plugin.
5 6 7 8 |
# File 'lib/sashimi/plugin.rb', line 5 def initialize(name, url = '') @url = URI::parse(url).to_s @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/sashimi/plugin.rb', line 3 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/sashimi/plugin.rb', line 3 def url @url end |
Class Method Details
.list ⇒ Object
List all installed plugins.
63 64 65 |
# File 'lib/sashimi/plugin.rb', line 63 def list AbstractRepository.list end |
Instance Method Details
#about ⇒ Object
Returns the informations about the plugin.
35 36 37 |
# File 'lib/sashimi/plugin.rb', line 35 def about @about ||= repository.about end |
#add ⇒ Object
Add to a Rails app
26 27 28 |
# File 'lib/sashimi/plugin.rb', line 26 def add repository.add end |
#guess_name ⇒ Object
Try to guess the plugin name.
45 46 47 48 49 50 51 52 |
# File 'lib/sashimi/plugin.rb', line 45 def guess_name name = File.basename(@url) if name == 'trunk' || name.empty? name = File.basename(File.dirname(@url)) end name.gsub!(/\.git$/, '') if name =~ /\.git$/ name end |
#install ⇒ Object
Install the plugin
11 12 13 |
# File 'lib/sashimi/plugin.rb', line 11 def install repository.install end |
#repository ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/sashimi/plugin.rb', line 30 def repository #:nodoc: @repository ||= instantiate_repository end |
#summary ⇒ Object
Return the plugin summary.
40 41 42 |
# File 'lib/sashimi/plugin.rb', line 40 def summary about['summary'] end |
#to_hash ⇒ Object
Serialize the plugin to Hash
format.
55 56 57 58 59 |
# File 'lib/sashimi/plugin.rb', line 55 def to_hash { self.guess_name => { 'type' => repository.scm_type, 'summary' => self.summary } } end |
#uninstall ⇒ Object
Uninstall the plugin
16 17 18 |
# File 'lib/sashimi/plugin.rb', line 16 def uninstall repository.uninstall end |
#update ⇒ Object
Update the plugin
21 22 23 |
# File 'lib/sashimi/plugin.rb', line 21 def update repository.update end |