Class: Heroku::Plugin
Defined Under Namespace
Classes: ErrorUpdatingSymlinkPlugin
Constant Summary
collapse
- DEPRECATED_PLUGINS =
%w(
heroku-cedar
heroku-certs
heroku-credentials
heroku-dyno-size
heroku-kill
heroku-labs
heroku-logging
heroku-netrc
heroku-pgdumps
heroku-postgresql
heroku-releases
heroku-shared-postgresql
heroku-sql-console
heroku-status
heroku-stop
heroku-suggest
pgbackups-automate
pgcmd
heroku-fork
)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
action, ask, confirm, confirm_billing, confirm_command, create_git_remote, deprecate, display, display_header, display_object, display_row, display_table, error, error_with_failure, error_with_failure=, extended, extended_into, fail, format_bytes, format_date, format_error, format_with_bang, get_terminal_environment, git, has_git?, home_directory, host_name, hprint, hputs, included, included_into, json_decode, json_encode, launchy, line_formatter, longest, output_with_bang, quantify, redisplay, retry_on_exception, run_command, running_on_a_mac?, running_on_windows?, set_buffer, shell, spinner, status, string_distance, styled_array, styled_error, styled_hash, styled_header, suggestion, time_ago, truncate, with_tty
Constructor Details
#initialize(uri) ⇒ Plugin
Returns a new instance of Plugin.
95
96
97
98
|
# File 'lib/heroku/plugin.rb', line 95
def initialize(uri)
@uri = uri
guess_name(uri)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
32
33
34
|
# File 'lib/heroku/plugin.rb', line 32
def name
@name
end
|
#uri ⇒ Object
Returns the value of attribute uri.
32
33
34
|
# File 'lib/heroku/plugin.rb', line 32
def uri
@uri
end
|
Class Method Details
.check_for_deprecation(plugin) ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'lib/heroku/plugin.rb', line 81
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 ⇒ Object
34
35
36
|
# File 'lib/heroku/plugin.rb', line 34
def self.directory
File.expand_path("#{home_directory}/.heroku/plugins")
end
|
.list ⇒ Object
38
39
40
41
42
|
# File 'lib/heroku/plugin.rb', line 38
def self.list
Dir["#{directory}/*"].sort.map do |folder|
File.basename(folder)
end
end
|
.load_plugin(plugin) ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/heroku/plugin.rb', line 66
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
|
.remove_plugin(plugin) ⇒ Object
77
78
79
|
# File 'lib/heroku/plugin.rb', line 77
def self.remove_plugin(plugin)
FileUtils.rm_rf("#{self.directory}/#{plugin}")
end
|
.skip_plugins ⇒ Object
91
92
93
|
# File 'lib/heroku/plugin.rb', line 91
def self.skip_plugins
@skip_plugins ||= ENV["SKIP_PLUGINS"].to_s.split(/[ ,]/)
end
|
Instance Method Details
#install ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/heroku/plugin.rb', line 108
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 ⇒ Object
104
105
106
|
# File 'lib/heroku/plugin.rb', line 104
def path
"#{self.class.directory}/#{name}"
end
|
#to_s ⇒ Object
100
101
102
|
# File 'lib/heroku/plugin.rb', line 100
def to_s
name
end
|
#uninstall ⇒ Object
123
124
125
126
|
# File 'lib/heroku/plugin.rb', line 123
def uninstall
ensure_plugin_exists
FileUtils.rm_r(path)
end
|
#update ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/heroku/plugin.rb', line 128
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(<<-ERROR)
#{name} is a legacy plugin installation.
Enable updating by reinstalling with `pogo plugins:install`.
ERROR
end
end
end
end
|