pogo 2.31.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. data/README.md +73 -0
  2. data/bin/pogo +22 -0
  3. data/data/cacert.pem +3988 -0
  4. data/lib/heroku.rb +22 -0
  5. data/lib/heroku/auth.rb +320 -0
  6. data/lib/heroku/cli.rb +38 -0
  7. data/lib/heroku/client.rb +764 -0
  8. data/lib/heroku/client/heroku_postgresql.rb +111 -0
  9. data/lib/heroku/client/pgbackups.rb +113 -0
  10. data/lib/heroku/client/rendezvous.rb +105 -0
  11. data/lib/heroku/client/ssl_endpoint.rb +25 -0
  12. data/lib/heroku/command.rb +273 -0
  13. data/lib/heroku/command/account.rb +23 -0
  14. data/lib/heroku/command/accounts.rb +34 -0
  15. data/lib/heroku/command/addons.rb +305 -0
  16. data/lib/heroku/command/apps.rb +311 -0
  17. data/lib/heroku/command/auth.rb +86 -0
  18. data/lib/heroku/command/base.rb +230 -0
  19. data/lib/heroku/command/certs.rb +148 -0
  20. data/lib/heroku/command/config.rb +137 -0
  21. data/lib/heroku/command/db.rb +218 -0
  22. data/lib/heroku/command/domains.rb +85 -0
  23. data/lib/heroku/command/drains.rb +46 -0
  24. data/lib/heroku/command/git.rb +65 -0
  25. data/lib/heroku/command/help.rb +163 -0
  26. data/lib/heroku/command/keys.rb +115 -0
  27. data/lib/heroku/command/labs.rb +161 -0
  28. data/lib/heroku/command/logs.rb +98 -0
  29. data/lib/heroku/command/maintenance.rb +61 -0
  30. data/lib/heroku/command/pg.rb +277 -0
  31. data/lib/heroku/command/pgbackups.rb +289 -0
  32. data/lib/heroku/command/plugins.rb +110 -0
  33. data/lib/heroku/command/ps.rb +232 -0
  34. data/lib/heroku/command/releases.rb +124 -0
  35. data/lib/heroku/command/run.rb +179 -0
  36. data/lib/heroku/command/sharing.rb +89 -0
  37. data/lib/heroku/command/ssl.rb +61 -0
  38. data/lib/heroku/command/stack.rb +62 -0
  39. data/lib/heroku/command/status.rb +51 -0
  40. data/lib/heroku/command/update.rb +47 -0
  41. data/lib/heroku/command/version.rb +23 -0
  42. data/lib/heroku/deprecated.rb +5 -0
  43. data/lib/heroku/deprecated/help.rb +38 -0
  44. data/lib/heroku/distribution.rb +9 -0
  45. data/lib/heroku/helpers.rb +517 -0
  46. data/lib/heroku/helpers/heroku_postgresql.rb +104 -0
  47. data/lib/heroku/plugin.rb +161 -0
  48. data/lib/heroku/updater.rb +158 -0
  49. data/lib/heroku/version.rb +3 -0
  50. data/lib/vendor/heroku/okjson.rb +598 -0
  51. data/spec/helper/legacy_help.rb +16 -0
  52. data/spec/heroku/auth_spec.rb +246 -0
  53. data/spec/heroku/client/heroku_postgresql_spec.rb +34 -0
  54. data/spec/heroku/client/pgbackups_spec.rb +43 -0
  55. data/spec/heroku/client/rendezvous_spec.rb +62 -0
  56. data/spec/heroku/client/ssl_endpoint_spec.rb +48 -0
  57. data/spec/heroku/client_spec.rb +564 -0
  58. data/spec/heroku/command/addons_spec.rb +585 -0
  59. data/spec/heroku/command/apps_spec.rb +351 -0
  60. data/spec/heroku/command/auth_spec.rb +38 -0
  61. data/spec/heroku/command/base_spec.rb +109 -0
  62. data/spec/heroku/command/certs_spec.rb +178 -0
  63. data/spec/heroku/command/config_spec.rb +144 -0
  64. data/spec/heroku/command/db_spec.rb +110 -0
  65. data/spec/heroku/command/domains_spec.rb +87 -0
  66. data/spec/heroku/command/drains_spec.rb +34 -0
  67. data/spec/heroku/command/git_spec.rb +116 -0
  68. data/spec/heroku/command/help_spec.rb +93 -0
  69. data/spec/heroku/command/keys_spec.rb +120 -0
  70. data/spec/heroku/command/labs_spec.rb +99 -0
  71. data/spec/heroku/command/logs_spec.rb +60 -0
  72. data/spec/heroku/command/maintenance_spec.rb +51 -0
  73. data/spec/heroku/command/pg_spec.rb +223 -0
  74. data/spec/heroku/command/pgbackups_spec.rb +280 -0
  75. data/spec/heroku/command/plugins_spec.rb +104 -0
  76. data/spec/heroku/command/ps_spec.rb +195 -0
  77. data/spec/heroku/command/releases_spec.rb +130 -0
  78. data/spec/heroku/command/run_spec.rb +86 -0
  79. data/spec/heroku/command/sharing_spec.rb +59 -0
  80. data/spec/heroku/command/ssl_spec.rb +32 -0
  81. data/spec/heroku/command/stack_spec.rb +46 -0
  82. data/spec/heroku/command/status_spec.rb +48 -0
  83. data/spec/heroku/command/version_spec.rb +16 -0
  84. data/spec/heroku/command_spec.rb +211 -0
  85. data/spec/heroku/helpers/heroku_postgresql_spec.rb +109 -0
  86. data/spec/heroku/helpers_spec.rb +48 -0
  87. data/spec/heroku/plugin_spec.rb +172 -0
  88. data/spec/heroku/updater_spec.rb +44 -0
  89. data/spec/spec.opts +1 -0
  90. data/spec/spec_helper.rb +209 -0
  91. data/spec/support/display_message_matcher.rb +49 -0
  92. data/spec/support/openssl_mock_helper.rb +8 -0
  93. metadata +220 -0
@@ -0,0 +1,48 @@
1
+ require "spec_helper"
2
+ require "heroku/helpers"
3
+
4
+ module Heroku
5
+ describe Helpers do
6
+ include Heroku::Helpers
7
+
8
+ context "display_object" do
9
+
10
+ it "should display Array correctly" do
11
+ capture_stdout do
12
+ display_object([1,2,3])
13
+ end.should == <<-OUT
14
+ 1
15
+ 2
16
+ 3
17
+ OUT
18
+ end
19
+
20
+ it "should display { :header => [] } list correctly" do
21
+ capture_stdout do
22
+ display_object({:first_header => [1,2,3], :last_header => [7,8,9]})
23
+ end.should == <<-OUT
24
+ === first_header
25
+ 1
26
+ 2
27
+ 3
28
+
29
+ === last_header
30
+ 7
31
+ 8
32
+ 9
33
+
34
+ OUT
35
+ end
36
+
37
+ it "should display String properly" do
38
+ capture_stdout do
39
+ display_object('string')
40
+ end.should == <<-OUT
41
+ string
42
+ OUT
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,172 @@
1
+ require "spec_helper"
2
+ require "heroku/plugin"
3
+
4
+ module Heroku
5
+ describe Plugin do
6
+ include SandboxHelper
7
+
8
+ it "lives in ~/.heroku/plugins" do
9
+ Plugin.stub!(:home_directory).and_return('/home/user')
10
+ Plugin.directory.should == '/home/user/.heroku/plugins'
11
+ end
12
+
13
+ it "extracts the name from git urls" do
14
+ Plugin.new('git://github.com/heroku/plugin.git').name.should == 'plugin'
15
+ end
16
+
17
+ describe "management" do
18
+ before(:each) do
19
+ @sandbox = "/tmp/heroku_plugins_spec_#{Process.pid}"
20
+ FileUtils.mkdir_p(@sandbox)
21
+ Dir.stub!(:pwd).and_return(@sandbox)
22
+ Plugin.stub!(:directory).and_return(@sandbox)
23
+ end
24
+
25
+ after(:each) do
26
+ FileUtils.rm_rf(@sandbox)
27
+ end
28
+
29
+ it "lists installed plugins" do
30
+ FileUtils.mkdir_p(@sandbox + '/plugin1')
31
+ FileUtils.mkdir_p(@sandbox + '/plugin2')
32
+ Plugin.list.should include 'plugin1'
33
+ Plugin.list.should include 'plugin2'
34
+ end
35
+
36
+ it "installs pulling from the plugin url" do
37
+ plugin_folder = "/tmp/heroku_plugin"
38
+ FileUtils.mkdir_p(plugin_folder)
39
+ `cd #{plugin_folder} && git init && echo 'test' > README && git add . && git commit -m 'my plugin'`
40
+ Plugin.new(plugin_folder).install
41
+ File.directory?("#{@sandbox}/heroku_plugin").should be_true
42
+ File.read("#{@sandbox}/heroku_plugin/README").should == "test\n"
43
+ end
44
+
45
+ it "reinstalls over old copies" do
46
+ plugin_folder = "/tmp/heroku_plugin"
47
+ FileUtils.mkdir_p(plugin_folder)
48
+ `cd #{plugin_folder} && git init && echo 'test' > README && git add . && git commit -m 'my plugin'`
49
+ Plugin.new(plugin_folder).install
50
+ Plugin.new(plugin_folder).install
51
+ File.directory?("#{@sandbox}/heroku_plugin").should be_true
52
+ File.read("#{@sandbox}/heroku_plugin/README").should == "test\n"
53
+ end
54
+
55
+ context "update" do
56
+
57
+ before(:each) do
58
+ plugin_folder = "/tmp/heroku_plugin"
59
+ FileUtils.mkdir_p(plugin_folder)
60
+ `cd #{plugin_folder} && git init && echo 'test' > README && git add . && git commit -m 'my plugin'`
61
+ Plugin.new(plugin_folder).install
62
+ `cd #{plugin_folder} && echo 'updated' > README && git add . && git commit -m 'my plugin update'`
63
+ end
64
+
65
+ it "updates existing copies" do
66
+ Plugin.new('heroku_plugin').update
67
+ File.directory?("#{@sandbox}/heroku_plugin").should be_true
68
+ File.read("#{@sandbox}/heroku_plugin/README").should == "updated\n"
69
+ end
70
+
71
+ it "warns on legacy plugins" do
72
+ `cd #{@sandbox}/heroku_plugin && git config --unset branch.master.remote`
73
+ stderr = capture_stderr do
74
+ begin
75
+ Plugin.new('heroku_plugin').update
76
+ rescue SystemExit
77
+ end
78
+ end
79
+ stderr.should == <<-STDERR
80
+ ! heroku_plugin is a legacy plugin installation.
81
+ ! Enable updating by reinstalling with `heroku plugins:install`.
82
+ STDERR
83
+ end
84
+
85
+ it "raises exception on symlinked plugins" do
86
+ `cd #{@sandbox} && ln -s heroku_plugin heroku_plugin_symlink`
87
+ lambda { Plugin.new('heroku_plugin_symlink').update }.should raise_error Heroku::Plugin::ErrorUpdatingSymlinkPlugin
88
+ end
89
+
90
+ end
91
+
92
+
93
+ it "uninstalls removing the folder" do
94
+ FileUtils.mkdir_p(@sandbox + '/plugin1')
95
+ Plugin.new('git://github.com/heroku/plugin1.git').uninstall
96
+ Plugin.list.should == []
97
+ end
98
+
99
+ it "adds the lib folder in the plugin to the load path, if present" do
100
+ FileUtils.mkdir_p(@sandbox + '/plugin/lib')
101
+ File.open(@sandbox + '/plugin/lib/my_custom_plugin_file.rb', 'w') { |f| f.write "" }
102
+ Plugin.load!
103
+ lambda { require 'my_custom_plugin_file' }.should_not raise_error(LoadError)
104
+ end
105
+
106
+ it "loads init.rb, if present" do
107
+ FileUtils.mkdir_p(@sandbox + '/plugin')
108
+ File.open(@sandbox + '/plugin/init.rb', 'w') { |f| f.write "LoadedInit = true" }
109
+ Plugin.load!
110
+ LoadedInit.should be_true
111
+ end
112
+
113
+ describe "when there are plugin load errors" do
114
+ before(:each) do
115
+ FileUtils.mkdir_p(@sandbox + '/some_plugin/lib')
116
+ File.open(@sandbox + '/some_plugin/init.rb', 'w') { |f| f.write "require 'some_non_existant_file'" }
117
+ end
118
+
119
+ it "should not throw an error" do
120
+ capture_stderr do
121
+ lambda { Plugin.load! }.should_not raise_error
122
+ end
123
+ end
124
+
125
+ it "should fail gracefully" do
126
+ stderr = capture_stderr do
127
+ Plugin.load!
128
+ end
129
+ stderr.should include('some_non_existant_file (LoadError)')
130
+ end
131
+
132
+ it "should still load other plugins" do
133
+ FileUtils.mkdir_p(@sandbox + '/some_plugin_2/lib')
134
+ File.open(@sandbox + '/some_plugin_2/init.rb', 'w') { |f| f.write "LoadedPlugin2 = true" }
135
+ stderr = capture_stderr do
136
+ Plugin.load!
137
+ end
138
+ stderr.should include('some_non_existant_file (LoadError)')
139
+ LoadedPlugin2.should be_true
140
+ end
141
+ end
142
+
143
+ describe "deprecated plugins" do
144
+ before(:each) do
145
+ FileUtils.mkdir_p(@sandbox + '/heroku-releases/lib')
146
+ end
147
+
148
+ after(:each) do
149
+ FileUtils.rm_rf(@sandbox + '/heroku-releases/lib')
150
+ end
151
+
152
+ it "should show confirmation to remove deprecated plugins if in an interactive shell" do
153
+ old_stdin_isatty = STDIN.isatty
154
+ STDIN.stub!(:isatty).and_return(true)
155
+ Plugin.should_receive(:confirm).with("The plugin heroku-releases has been deprecated. Would you like to remove it? (y/N)").and_return(true)
156
+ Plugin.should_receive(:remove_plugin).with("heroku-releases")
157
+ Plugin.load!
158
+ STDIN.stub!(:isatty).and_return(old_stdin_isatty)
159
+ end
160
+
161
+ it "should not prompt for deprecation if not in an interactive shell" do
162
+ old_stdin_isatty = STDIN.isatty
163
+ STDIN.stub!(:isatty).and_return(false)
164
+ Plugin.should_not_receive(:confirm)
165
+ Plugin.should_not_receive(:remove_plugin).with("heroku-releases")
166
+ Plugin.load!
167
+ STDIN.stub!(:isatty).and_return(old_stdin_isatty)
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,44 @@
1
+ require "spec_helper"
2
+ require "heroku/updater"
3
+ require "heroku/version"
4
+
5
+ module Heroku
6
+ describe Updater do
7
+
8
+ it "calculates the latest local version" do
9
+ Heroku::Updater.latest_local_version.should == Heroku::VERSION
10
+ end
11
+
12
+ it "calculates compare_versions" do
13
+ Heroku::Updater.compare_versions('1.1.1', '1.1.1').should == 0
14
+
15
+ Heroku::Updater.compare_versions('2.1.1', '1.1.1').should == 1
16
+ Heroku::Updater.compare_versions('1.1.1', '2.1.1').should == -1
17
+
18
+ Heroku::Updater.compare_versions('1.2.1', '1.1.1').should == 1
19
+ Heroku::Updater.compare_versions('1.1.1', '1.2.1').should == -1
20
+
21
+ Heroku::Updater.compare_versions('1.1.2', '1.1.1').should == 1
22
+ Heroku::Updater.compare_versions('1.1.1', '1.1.2').should == -1
23
+
24
+ Heroku::Updater.compare_versions('2.1.1', '1.2.1').should == 1
25
+ Heroku::Updater.compare_versions('1.2.1', '2.1.1').should == -1
26
+
27
+ Heroku::Updater.compare_versions('2.1.1', '1.1.2').should == 1
28
+ Heroku::Updater.compare_versions('1.1.2', '2.1.1').should == -1
29
+
30
+ Heroku::Updater.compare_versions('1.2.4', '1.2.3').should == 1
31
+ Heroku::Updater.compare_versions('1.2.3', '1.2.4').should == -1
32
+
33
+ Heroku::Updater.compare_versions('1.2.1', '1.2' ).should == 1
34
+ Heroku::Updater.compare_versions('1.2', '1.2.1').should == -1
35
+
36
+ Heroku::Updater.compare_versions('1.1.1.pre1', '1.1.1').should == 1
37
+ Heroku::Updater.compare_versions('1.1.1', '1.1.1.pre1').should == -1
38
+
39
+ Heroku::Updater.compare_versions('1.1.1.pre2', '1.1.1.pre1').should == 1
40
+ Heroku::Updater.compare_versions('1.1.1.pre1', '1.1.1.pre2').should == -1
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,209 @@
1
+ $stdin = File.new("/dev/null")
2
+
3
+ require "rubygems"
4
+
5
+ require "excon"
6
+ Excon.defaults[:mock] = true
7
+
8
+ # ensure these are around for errors
9
+ # as their require is generally deferred
10
+ require "heroku-api"
11
+ require "rest_client"
12
+
13
+ require "heroku/cli"
14
+ require "rspec"
15
+ require "rr"
16
+ require "fakefs/safe"
17
+ require 'tmpdir'
18
+ require "webmock/rspec"
19
+
20
+ include WebMock::API
21
+
22
+ WebMock::HttpLibAdapters::ExconAdapter.disable!
23
+
24
+ def api
25
+ Heroku::API.new(:api_key => "pass", :mock => true)
26
+ end
27
+
28
+ def stub_api_request(method, path)
29
+ stub_request(method, "https://api.heroku.com#{path}")
30
+ end
31
+
32
+ def prepare_command(klass)
33
+ command = klass.new
34
+ command.stub!(:app).and_return("myapp")
35
+ command.stub!(:ask).and_return("")
36
+ command.stub!(:display)
37
+ command.stub!(:hputs)
38
+ command.stub!(:hprint)
39
+ command.stub!(:heroku).and_return(mock('heroku client', :host => 'heroku.com'))
40
+ command
41
+ end
42
+
43
+ def execute(command_line)
44
+ extend RR::Adapters::RRMethods
45
+
46
+ args = command_line.split(" ")
47
+ command = args.shift
48
+
49
+ Heroku::Command.load
50
+ object, method = Heroku::Command.prepare_run(command, args)
51
+
52
+ any_instance_of(Heroku::Command::Base) do |base|
53
+ stub(base).app.returns("myapp")
54
+ end
55
+
56
+ stub(Heroku::Auth).get_credentials.returns(['email@example.com', 'apikey01'])
57
+ stub(Heroku::Auth).api_key.returns('apikey01')
58
+
59
+ original_stdin, original_stderr, original_stdout = $stdin, $stderr, $stdout
60
+
61
+ $stdin = captured_stdin = StringIO.new
62
+ $stderr = captured_stderr = StringIO.new
63
+ $stdout = captured_stdout = StringIO.new
64
+
65
+ begin
66
+ object.send(method)
67
+ rescue SystemExit
68
+ ensure
69
+ $stdin, $stderr, $stdout = original_stdin, original_stderr, original_stdout
70
+ Heroku::Command.current_command = nil
71
+ end
72
+
73
+ [captured_stderr.string, captured_stdout.string]
74
+ end
75
+
76
+ def any_instance_of(klass, &block)
77
+ extend RR::Adapters::RRMethods
78
+ any_instance_of(klass, &block)
79
+ end
80
+
81
+ def run(command_line)
82
+ capture_stdout do
83
+ begin
84
+ Heroku::CLI.start(*command_line.split(" "))
85
+ rescue SystemExit
86
+ end
87
+ end
88
+ end
89
+
90
+ alias heroku run
91
+
92
+ def capture_stderr(&block)
93
+ original_stderr = $stderr
94
+ $stderr = captured_stderr = StringIO.new
95
+ begin
96
+ yield
97
+ ensure
98
+ $stderr = original_stderr
99
+ end
100
+ captured_stderr.string
101
+ end
102
+
103
+ def capture_stdout(&block)
104
+ original_stdout = $stdout
105
+ $stdout = captured_stdout = StringIO.new
106
+ begin
107
+ yield
108
+ ensure
109
+ $stdout = original_stdout
110
+ end
111
+ captured_stdout.string
112
+ end
113
+
114
+ def fail_command(message)
115
+ raise_error(Heroku::Command::CommandFailed, message)
116
+ end
117
+
118
+ def stub_core
119
+ @stubbed_core ||= begin
120
+ stubbed_core = nil
121
+ any_instance_of(Heroku::Client) do |core|
122
+ stubbed_core = stub(core)
123
+ end
124
+ stub(Heroku::Auth).user.returns("email@example.com")
125
+ stub(Heroku::Auth).password.returns("pass")
126
+ stub(Heroku::Client).auth.returns("apikey01")
127
+ stubbed_core
128
+ end
129
+ end
130
+
131
+ def stub_pg
132
+ @stubbed_pg ||= begin
133
+ stubbed_pg = nil
134
+ any_instance_of(Heroku::Client::HerokuPostgresql) do |pg|
135
+ stubbed_pg = stub(pg)
136
+ end
137
+ stubbed_pg
138
+ end
139
+ end
140
+
141
+ def stub_pgbackups
142
+ @stubbed_pgbackups ||= begin
143
+ stubbed_pgbackups = nil
144
+ any_instance_of(Heroku::Client::Pgbackups) do |pgbackups|
145
+ stubbed_pgbackups = stub(pgbackups)
146
+ end
147
+ stubbed_pgbackups
148
+ end
149
+ end
150
+
151
+ def stub_rendezvous
152
+ @stubbed_rendezvous ||= begin
153
+ stubbed_rendezvous = nil
154
+ any_instance_of(Heroku::Client::Rendezvous) do |rendezvous|
155
+ stubbed_rendezvous = stub(rendezvous)
156
+ end
157
+ stubbed_rendezvous
158
+ end
159
+ end
160
+
161
+ def with_blank_git_repository(&block)
162
+ sandbox = File.join(Dir.tmpdir, "heroku", Process.pid.to_s)
163
+ FileUtils.mkdir_p(sandbox)
164
+
165
+ old_dir = Dir.pwd
166
+ Dir.chdir(sandbox)
167
+
168
+ `git init`
169
+ block.call
170
+
171
+ FileUtils.rm_rf(sandbox)
172
+ ensure
173
+ Dir.chdir(old_dir)
174
+ end
175
+
176
+ def taps_available?
177
+ begin
178
+ require "taps/operation"
179
+ true
180
+ rescue LoadError
181
+ false
182
+ end
183
+ end
184
+
185
+ module SandboxHelper
186
+ def bash(cmd)
187
+ `#{cmd}`
188
+ end
189
+ end
190
+
191
+ require "heroku/helpers"
192
+ module Heroku::Helpers
193
+ @home_directory = Dir.mktmpdir
194
+ undef_method :home_directory
195
+ def home_directory
196
+ @home_directory
197
+ end
198
+ end
199
+
200
+ require "support/display_message_matcher"
201
+
202
+ RSpec.configure do |config|
203
+ config.color_enabled = true
204
+ config.include DisplayMessageMatcher
205
+ config.order = 'rand'
206
+ config.before { Heroku::Helpers.error_with_failure = false }
207
+ config.after { RR.reset }
208
+ end
209
+