Class: Proviso::Plugin
- Inherits:
-
Object
show all
- Extended by:
- Helpers
- Defined in:
- lib/proviso/plugin.rb
Constant Summary
Constants included
from Helpers
Helpers::CONFIG_FILE, Helpers::PROVISO_PATH
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
home_directory, running_on_a_mac?, running_on_windows?, yaml_file
Constructor Details
#initialize(uri) ⇒ Plugin
Returns a new instance of Plugin.
30
31
32
33
|
# File 'lib/proviso/plugin.rb', line 30
def initialize(uri)
@uri = uri
guess_name(uri)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10
11
12
|
# File 'lib/proviso/plugin.rb', line 10
def name
@name
end
|
#uri ⇒ Object
Returns the value of attribute uri.
10
11
12
|
# File 'lib/proviso/plugin.rb', line 10
def uri
@uri
end
|
Class Method Details
.directory ⇒ Object
12
13
14
|
# File 'lib/proviso/plugin.rb', line 12
def self.directory
"#{home_directory}/.proviso/plugins"
end
|
.list ⇒ Object
16
17
18
19
20
|
# File 'lib/proviso/plugin.rb', line 16
def self.list
Dir["#{directory}/*"].map do |folder|
File.basename(folder)
end
end
|
.load! ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/proviso/plugin.rb', line 22
def self.load!
list.each do |plugin|
folder = "#{self.directory}/#{plugin}"
$: << "#{folder}/lib" if File.directory? "#{folder}/lib"
load "#{folder}/init.rb" if File.exists? "#{folder}/init.rb"
end
end
|
Instance Method Details
#install ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/proviso/plugin.rb', line 43
def install
FileUtils.mkdir_p(path)
Dir.chdir(path) do
system("git init > /dev/null 2>&1")
if !system("git pull --depth 1 #{uri} > /dev/null 2>&1")
FileUtils.rm_rf path
return false
end
end
true
end
|
#path ⇒ Object
39
40
41
|
# File 'lib/proviso/plugin.rb', line 39
def path
"#{self.class.directory}/#{name}"
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/proviso/plugin.rb', line 35
def to_s
name
end
|
#uninstall ⇒ Object
55
56
57
|
# File 'lib/proviso/plugin.rb', line 55
def uninstall
FileUtils.rm_r path if File.directory?(path)
end
|