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.
@@ -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 = '0.0.1'
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
- PostInstall.txt
10
- Rakefile
11
- heroswitch.gemspec
12
- README.rdoc
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
- s.executables = ['heroswitch']
20
+ s.executables = ['heroswitch']
19
21
  end
@@ -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
- #opts.on("-l", "--list", "List accounts and exit") { options[:list_credentials] = true }
19
- opts.on("-l", "--list", "List accounts and exit") { Heroswitch::Credentials.list_credentials; exit }
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
- account = ARGV[0]
33
-
34
- if account
35
- Heroswitch::Credentials.switch account
36
- else
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 "ftools"
1
+ require "fileutils"
2
+
2
3
  module Heroswitch
3
4
  class Credentials
4
- HEROKU_HOME = File.join ENV["HOME"], ".heroku"
5
- CREDENTIALS_FILE = "credentials"
6
-
7
- def self.show_credentials
8
- credentials_path = File.join HEROKU_HOME, CREDENTIALS_FILE
9
- if File.exists? credentials_path
10
- credentials = `cat #{credentials_path}`.split "\n"
11
- puts "\nYour active Heroku credentials are:\n\n"
12
- puts credentials.first
13
- puts '*' * credentials.last.size
14
- puts "\n"
15
- else
16
- puts "ERROR: Heroku credentials not found!"
17
- end
18
- end
19
-
20
- def self.list_credentials
21
- puts "\nYou have credentials files for the following accounts in\n"
22
- puts "#{HEROKU_HOME}\n\n"
23
- Dir[HEROKU_HOME+"/*."+CREDENTIALS_FILE].each do |file|
24
- puts " #{(File.basename file).gsub(/\.#{CREDENTIALS_FILE}/, "")}"
25
- end
26
- puts "\n"
27
- end
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
- account_path = File.join HEROKU_HOME, account + '.' + CREDENTIALS_FILE
31
- credentials_path = File.join HEROKU_HOME, CREDENTIALS_FILE
32
- puts "\nSwitching to the \"#{account}\" Heroku account..."
33
- if File.exists? account_path
34
- File.copy(account_path, credentials_path)
35
- print_reminder account
36
- else
37
- puts "ERROR: Heroku account credentials do not exist!"
38
- end
39
- end
40
-
41
- def self.print_reminder(account)
42
- puts <<-OUT.gsub(/^ /,'')
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
- Host \033[33m#{account}\033[0m.heroku.com
46
- HostName heroku.com
47
- User git
48
- IdentityFile ~/.ssh/path/to/#{account}/account/private_key.identity
49
- IdentitiesOnly yes
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
- $ git remote add heroku git@\033[33m#{account}.heroku.com\033[0m:MyApp.git
53
+ $ git remote add heroku git@\033[33m#{account}.heroku.com\033[0m:MyApp.git
53
54
 
54
- OUT
55
- end
56
- end
55
+ OUT
56
+ end
57
+ end
57
58
  end
@@ -0,0 +1,3 @@
1
+ module Heroswitch
2
+ VERSION = "0.0.2"
3
+ 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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
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-25 00:00:00 -04:00
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