Class: Sashimi::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/sashimi/plugin.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/sashimi/plugin.rb', line 3

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/sashimi/plugin.rb', line 3

def url
  @url
end

Class Method Details

.listObject

List all installed plugins.



63
64
65
# File 'lib/sashimi/plugin.rb', line 63

def list
  AbstractRepository.list
end

Instance Method Details

#aboutObject

Returns the informations about the plugin.



35
36
37
# File 'lib/sashimi/plugin.rb', line 35

def about
  @about ||= repository.about
end

#addObject

Add to a Rails app



26
27
28
# File 'lib/sashimi/plugin.rb', line 26

def add
  repository.add
end

#guess_nameObject

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

#installObject

Install the plugin



11
12
13
# File 'lib/sashimi/plugin.rb', line 11

def install
  repository.install
end

#repositoryObject

:nodoc:



30
31
32
# File 'lib/sashimi/plugin.rb', line 30

def repository #:nodoc:
  @repository ||= instantiate_repository
end

#summaryObject

Return the plugin summary.



40
41
42
# File 'lib/sashimi/plugin.rb', line 40

def summary
  about['summary']
end

#to_hashObject

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

#uninstallObject

Uninstall the plugin



16
17
18
# File 'lib/sashimi/plugin.rb', line 16

def uninstall
  repository.uninstall
end

#updateObject

Update the plugin



21
22
23
# File 'lib/sashimi/plugin.rb', line 21

def update
  repository.update
end