heroswitch 0.0.1 → 0.0.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.
- data/heroswitch.gemspec +9 -7
- data/lib/heroswitch/cli.rb +8 -13
- data/lib/heroswitch/credentials.rb +48 -47
- data/lib/heroswitch/version.rb +3 -0
- metadata +5 -4
data/heroswitch.gemspec
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
+
require 'lib/heroswitch/version'
|
2
|
+
|
1
3
|
spec = Gem::Specification.new do |s|
|
2
4
|
s.name = 'heroswitch'
|
3
|
-
s.version =
|
5
|
+
s.version = Heroswitch::VERSION
|
4
6
|
s.author = "John Ford"
|
5
7
|
s.email = "jwford@gmail.com"
|
6
8
|
s.summary = "Easily switch between multiple heroku accounts."
|
7
9
|
s.description = %{Switch between multiple Heroku accounts.}
|
8
10
|
s.files = Dir['lib/**/*.rb'] + Dir['test/**/*.rb'] + Dir['tasks/**/*.rb'] + %w[
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
PostInstall.txt
|
12
|
+
Rakefile
|
13
|
+
heroswitch.gemspec
|
14
|
+
README.rdoc
|
15
|
+
]
|
14
16
|
s.require_path = 'lib'
|
15
17
|
s.autorequire = 'heroswitch'
|
16
18
|
s.has_rdoc = false
|
17
19
|
s.homepage = "http://github.com/JohnFord/heroswitch"
|
18
|
-
|
20
|
+
s.executables = ['heroswitch']
|
19
21
|
end
|
data/lib/heroswitch/cli.rb
CHANGED
@@ -3,7 +3,6 @@ require 'optparse'
|
|
3
3
|
module Heroswitch
|
4
4
|
class CLI
|
5
5
|
def self.execute(stdout, arguments=[])
|
6
|
-
|
7
6
|
parser = OptionParser.new do |opts|
|
8
7
|
opts.banner = <<-BANNER.gsub(/^ /,'')
|
9
8
|
Switch easily between multiple heroku envinments.
|
@@ -15,8 +14,8 @@ module Heroswitch
|
|
15
14
|
Options are:
|
16
15
|
BANNER
|
17
16
|
opts.separator ""
|
18
|
-
|
19
|
-
|
17
|
+
#opts.on("-l", "--list", "List accounts and exit") { options[:list_credentials] = true }
|
18
|
+
opts.on("-l", "--list", "List accounts and exit") { Heroswitch::Credentials.list_credentials; exit }
|
20
19
|
opts.on("-h", "--help", "Show this help message.") { stdout.puts opts; exit }
|
21
20
|
opts.parse!(arguments)
|
22
21
|
opts.banner = <<-BANNER.gsub(/^ /,'')
|
@@ -26,17 +25,13 @@ module Heroswitch
|
|
26
25
|
|
27
26
|
Options are:
|
28
27
|
BANNER
|
29
|
-
|
30
28
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Heroswitch::Credentials.show_credentials
|
38
|
-
end
|
39
|
-
|
29
|
+
account = ARGV[0]
|
30
|
+
if account
|
31
|
+
Heroswitch::Credentials.switch account
|
32
|
+
else
|
33
|
+
Heroswitch::Credentials.show_credentials
|
34
|
+
end
|
40
35
|
end
|
41
36
|
end
|
42
37
|
end
|
@@ -1,57 +1,58 @@
|
|
1
|
-
require "
|
1
|
+
require "fileutils"
|
2
|
+
|
2
3
|
module Heroswitch
|
3
4
|
class Credentials
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
HEROKU_HOME = File.join ENV["HOME"], ".heroku"
|
6
|
+
CREDENTIALS_FILE = "credentials"
|
7
|
+
|
8
|
+
def self.show_credentials
|
9
|
+
credentials_path = File.join HEROKU_HOME, CREDENTIALS_FILE
|
10
|
+
if File.exists? credentials_path
|
11
|
+
credentials = `cat #{credentials_path}`.split "\n"
|
12
|
+
puts "\nYour active Heroku credentials are:\n\n"
|
13
|
+
puts credentials.first
|
14
|
+
puts '*' * credentials.last.size
|
15
|
+
puts "\n"
|
16
|
+
else
|
17
|
+
puts "ERROR: Heroku credentials not found!"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.list_credentials
|
22
|
+
puts "\nYou have credentials files for the following accounts in\n"
|
23
|
+
puts "#{HEROKU_HOME}\n\n"
|
24
|
+
Dir[HEROKU_HOME+"/*."+CREDENTIALS_FILE].each do |file|
|
25
|
+
puts " #{(File.basename file).gsub(/\.#{CREDENTIALS_FILE}/, "")}"
|
26
|
+
end
|
27
|
+
puts "\n"
|
28
|
+
end
|
28
29
|
|
29
30
|
def self.switch(account)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
account_path = File.join HEROKU_HOME, account + '.' + CREDENTIALS_FILE
|
32
|
+
credentials_path = File.join HEROKU_HOME, CREDENTIALS_FILE
|
33
|
+
puts "\nSwitching to the \"#{account}\" Heroku account..."
|
34
|
+
if File.exists? account_path
|
35
|
+
FileUtils.cp(account_path, credentials_path)
|
36
|
+
print_reminder account
|
37
|
+
else
|
38
|
+
puts "ERROR: Heroku account credentials do not exist!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.print_reminder(account)
|
43
|
+
puts <<-OUT.gsub(/^ /,'')
|
43
44
|
|
44
45
|
\033[31mRemember to add an entry in your ~/.ssh/config file like:\033[0m
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
Host \033[33m#{account}\033[0m.heroku.com
|
47
|
+
HostName heroku.com
|
48
|
+
User git
|
49
|
+
IdentityFile ~/.ssh/path/to/#{account}/account/private_key.identity
|
50
|
+
IdentitiesOnly yes
|
50
51
|
|
51
52
|
\033[31mAlso, use \033[33m#{account}.heroku.com\033[31m when setting up your heroku remote in git:\033[0m
|
52
|
-
|
53
|
+
$ git remote add heroku git@\033[33m#{account}.heroku.com\033[0m:MyApp.git
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
OUT
|
56
|
+
end
|
57
|
+
end
|
57
58
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroswitch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Ford
|
@@ -15,7 +15,7 @@ autorequire: heroswitch
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-26 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,6 +30,7 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- lib/heroswitch/cli.rb
|
32
32
|
- lib/heroswitch/credentials.rb
|
33
|
+
- lib/heroswitch/version.rb
|
33
34
|
- lib/heroswitch.rb
|
34
35
|
- test/test_helper.rb
|
35
36
|
- test/test_heroswitch.rb
|