class Heroku::Plugin
Constants
- DEPRECATED_PLUGINS
Attributes
name[R]
uri[R]
Public Class Methods
check_for_deprecation(plugin)
click to toggle source
# File lib/heroku/plugin.rb, line 69 def self.check_for_deprecation(plugin) return unless STDIN.isatty if DEPRECATED_PLUGINS.include?(plugin) if confirm "The plugin #{plugin} has been deprecated. Would you like to remove it? (y/N)" remove_plugin(plugin) end end end
directory()
click to toggle source
# File lib/heroku/plugin.rb, line 36 def self.directory File.expand_path("#{home_directory}/.heroku/plugins") end
list()
click to toggle source
# File lib/heroku/plugin.rb, line 40 def self.list Dir["#{directory}/*"].sort.map do |folder| File.basename(folder) end end
load!()
click to toggle source
# File lib/heroku/plugin.rb, line 46 def self.load! list.each do |plugin| check_for_deprecation(plugin) next if skip_plugins.include?(plugin) load_plugin(plugin) end end
load_plugin(plugin)
click to toggle source
# File lib/heroku/plugin.rb, line 54 def self.load_plugin(plugin) begin folder = "#{self.directory}/#{plugin}" $: << "#{folder}/lib" if File.directory? "#{folder}/lib" load "#{folder}/init.rb" if File.exists? "#{folder}/init.rb" rescue ScriptError, StandardError => error styled_error(error, "Unable to load plugin #{plugin}.") false end end
new(uri)
click to toggle source
# File lib/heroku/plugin.rb, line 83 def initialize(uri) @uri = uri guess_name(uri) end
remove_plugin(plugin)
click to toggle source
# File lib/heroku/plugin.rb, line 65 def self.remove_plugin(plugin) FileUtils.rm_rf("#{self.directory}/#{plugin}") end
skip_plugins()
click to toggle source
# File lib/heroku/plugin.rb, line 79 def self.skip_plugins @skip_plugins ||= ENV["SKIP_PLUGINS"].to_s.split(/[ ,]/) end
Public Instance Methods
install()
click to toggle source
# File lib/heroku/plugin.rb, line 96 def install if File.directory?(path) uninstall end FileUtils.mkdir_p(self.class.directory) Dir.chdir(self.class.directory) do git("clone #{uri}") unless $?.success? FileUtils.rm_rf path return false end end true end
path()
click to toggle source
# File lib/heroku/plugin.rb, line 92 def path "#{self.class.directory}/#{name}" end
to_s()
click to toggle source
# File lib/heroku/plugin.rb, line 88 def to_s name end
uninstall()
click to toggle source
# File lib/heroku/plugin.rb, line 111 def uninstall ensure_plugin_exists FileUtils.rm_r(path) end
update()
click to toggle source
# File lib/heroku/plugin.rb, line 116 def update ensure_plugin_exists if File.symlink?(path) raise Heroku::Plugin::ErrorUpdatingSymlinkPlugin else Dir.chdir(path) do unless git('config --get branch.master.remote').empty? message = git("pull") unless $?.success? error("Unable to update #{name}.\n" + message) end else error("#{name} is a legacy plugin installation. Enable updating by reinstalling with `heroku plugins:install`. ") end end end end
Private Instance Methods
ensure_plugin_exists()
click to toggle source
# File lib/heroku/plugin.rb, line 139 def ensure_plugin_exists unless File.directory?(path) error("#{name} plugin not found.") end end
guess_name(url)
click to toggle source
# File lib/heroku/plugin.rb, line 145 def guess_name(url) @name = File.basename(url) @name = File.basename(File.dirname(url)) if @name.empty? @name.gsub!(/\.git$/, '') if @name =~ /\.git$/ end