class Dokkufy::Plugin
Attributes
hostname[RW]
path[RW]
username[RW]
Public Class Methods
all(with_notes = false)
click to toggle source
# File lib/dokkufy/plugin.rb, line 24 def self.all with_notes = false return @plugins if @plugins open("http://progrium.viewdocs.io/dokku/plugins") do |f| hp = Hpricot(f) plugins = hp.search("tbody tr td").each_slice(3) @plugins = plugins.each_with_index.map do |plugin, index| first_element = plugin.first.children.reject{|e| e.inner_text.strip == ""}.first entry = [index+1, first_element.attributes["href"].split("github.com/").last, first_element.inner_text] entry << plugin.last.inner_text if with_notes entry end end end
new(hostname, username)
click to toggle source
# File lib/dokkufy/plugin.rb, line 9 def initialize hostname, username self.hostname = hostname self.username = username end
Public Instance Methods
install(id_or_name)
click to toggle source
# File lib/dokkufy/plugin.rb, line 14 def install id_or_name self.path = id_or_name Dokkufy::Server.new(hostname, username).install_plugin(path, name) end
uninstall(id_or_name)
click to toggle source
# File lib/dokkufy/plugin.rb, line 19 def uninstall id_or_name self.path = id_or_name Dokkufy::Server.new(hostname, username).uninstall_plugin(path, name) end
Private Instance Methods
name()
click to toggle source
# File lib/dokkufy/plugin.rb, line 55 def name Dokkufy::Plugin.all.each do |plugin| if plugin[1] == path return plugin[2].split(" ").first.downcase end end end
path=(id_or_name)
click to toggle source
# File lib/dokkufy/plugin.rb, line 42 def path=(id_or_name) if id_or_name.to_i.to_s == id_or_name Dokkufy::Plugin.all.each do |plugin| if plugin[0] == id_or_name.to_i @path = plugin[1] return end end else @id = id_or_name end end