shacho 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -26,7 +26,7 @@
26
26
  ```
27
27
 
28
28
  # what
29
- A command-line utility that helps manage all your accounts and associated keys for heroku.
29
+ A command-line utility that helps manage all your accounts and associated keys (eventually) for heroku.
30
30
 
31
31
  # why
32
32
  [heroku_plus](https://github.com/bkuhlmann/heroku_plus) is pretty cool
@@ -44,9 +44,10 @@ shacho action params
44
44
  ```
45
45
 
46
46
  Where `action` is one of the standard CRUDy actions:
47
- * create
48
- * use
49
- * list
47
+
48
+ - create
49
+ - use
50
+ - list
50
51
 
51
52
  `params` refers to any additional parameters you might want to pass in. For now, that's just the name of the account you want to create
52
53
 
@@ -65,4 +66,36 @@ shacho use default
65
66
  ```
66
67
  #List:
67
68
  shacho list
69
+ ```
70
+
71
+ # details of implementation
72
+
73
+ `shacho` creates folders in your `~/.heroku` that correspond to the account name you passsed into the command. The following call:
74
+
75
+ ```
76
+ shacho create default
77
+ ```
78
+
79
+ Would result in the following file structure:
80
+
81
+ ```
82
+ /home/your_username/.heroku
83
+ └── accounts
84
+ └── default
85
+ └── credentials
86
+ ```
87
+
88
+ When you `use` an account, `shacho` creates a symbolic link from the credentials file generated during the `create` step to the one heroku reads at `~/.heroku/credentials`
89
+
90
+ You can now use heroku account-specific commands by simply firing off a `shacho use` :3
91
+
92
+ # don't believe me?
93
+
94
+ I got your tests right here:
95
+
96
+ ```
97
+ git clone git@github.com:kellydunn/shacho
98
+ cd shacho
99
+ bundle install
100
+ rspec spec
68
101
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -5,19 +5,19 @@ module Shacho
5
5
  def self.create(options)
6
6
  # TODO Throw error for incorrect params
7
7
  name = options.first
8
- filename = "#{HEROKU_PREFIX}/accounts/#{name}"
8
+ filename = account_folder(name)
9
9
  if !File.exists?(filename) || !File.directory?(filename)
10
10
  FileUtils.mkdir_p(filename)
11
- credential = Credential.new
12
- credential.prompt(name)
13
- credential.write(filename)
14
11
  end
12
+ update_credentials(name)
15
13
  end
16
14
 
17
15
  def self.use(options)
18
16
  # TODO Throw error for incorrect params
17
+ # TODO check to see if account is created
19
18
  name = options.first
20
- credential_file = "#{HEROKU_PREFIX}/accounts/#{name}/credentials"
19
+
20
+ credential_file = "#{account_folder(name)}/credentials"
21
21
  heroku_credentials = "#{HEROKU_PREFIX}/credentials"
22
22
  FileUtils.ln_sf credential_file, heroku_credentials
23
23
  end
@@ -30,8 +30,26 @@ module Shacho
30
30
  end
31
31
  end
32
32
 
33
+ def self.edit(options)
34
+ # TODO Throw error for incorrect params
35
+ # TODO check to see if account is created
36
+ name = options.first
37
+ update_credentials(name)
38
+ end
39
+
33
40
  def method_missing(sym, *args, &block)
34
41
  Runner.error("Unsupported action. Run `shacho help` for more information")
35
42
  end
43
+
44
+ private
45
+ def self.account_folder(name)
46
+ return "#{HEROKU_PREFIX}/accounts/#{name}"
47
+ end
48
+
49
+ def self.update_credentials(name)
50
+ credential = Credential.new
51
+ credential.prompt(name)
52
+ credential.write(account_folder(name))
53
+ end
36
54
  end
37
55
  end
data/lib/shacho.rb CHANGED
@@ -7,5 +7,5 @@ module Shacho
7
7
 
8
8
  # TODO only need to use actions
9
9
  # method_missing willl help with error handling
10
- COMMANDS = ["create", "use", "list", "help"]
10
+ COMMANDS = ["create", "use", "list", "edit", "help"]
11
11
  end
data/shacho.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "shacho"
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kelly"]
@@ -30,10 +30,10 @@ Gem::Specification.new do |s|
30
30
  "lib/shacho.rb",
31
31
  "lib/shacho/account.rb",
32
32
  "lib/shacho/credential.rb",
33
- "lib/shacho/key.rb",
34
33
  "lib/shacho/runner.rb",
35
34
  "lib/shacho/util.rb",
36
35
  "shacho.gemspec",
36
+ "spec/accounts/edit_account_spec.rb",
37
37
  "spec/accounts/list_account_spec.rb",
38
38
  "spec/accounts/new_account_spec.rb",
39
39
  "spec/accounts/use_account_spec.rb",
@@ -0,0 +1,18 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "Editing an account" do
4
+ include CoreHelper
5
+
6
+ before :each do
7
+ create_account
8
+ end
9
+
10
+ it "should be able to edit the account's credentials" do
11
+ STDIN.stubs(:gets).returns("newtest@test.com", "newpassword")
12
+ Shacho::Account.edit(["test"])
13
+ contents = get_credentials "#{Shacho::HEROKU_PREFIX}/accounts/test"
14
+ email_test = contents[0] == "newtest@test.com"
15
+ password_test = contents[1] == "newpassword"
16
+ (email_test && password_test).should == true
17
+ end
18
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'mocha'
5
-
6
5
  require 'shacho'
7
6
 
8
7
  Shacho::HEROKU_PREFIX = "#{File.dirname(__FILE__)}/helpers"
@@ -11,8 +10,16 @@ Dir["#{File.dirname(__FILE__)}/helpers/**/*.rb"].each {|f| require f}
11
10
 
12
11
  RSpec.configure do |config|
13
12
  config.mock_with :mocha
13
+
14
+ config.before :each do
15
+ STDOUT.stubs(:puts)
16
+ STDOUT.stubs(:print)
17
+ end
14
18
 
15
19
  config.after :each do
20
+ STDOUT.unstub(:puts)
21
+ STDOUT.unstub(:print)
22
+
16
23
  if File.exists?("#{File.dirname(__FILE__)}/helpers/accounts")
17
24
  FileUtils.rm_r("#{File.dirname(__FILE__)}/helpers/accounts")
18
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shacho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: heroku
16
- requirement: &25855980 !ruby/object:Gem::Requirement
16
+ requirement: &10617660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25855980
24
+ version_requirements: *10617660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &25855260 !ruby/object:Gem::Requirement
27
+ requirement: &10617000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.3.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *25855260
35
+ version_requirements: *10617000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-debug19
38
- requirement: &25854480 !ruby/object:Gem::Requirement
38
+ requirement: &10616320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *25854480
46
+ version_requirements: *10616320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &25853600 !ruby/object:Gem::Requirement
49
+ requirement: &10615640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *25853600
57
+ version_requirements: *10615640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &25852760 !ruby/object:Gem::Requirement
60
+ requirement: &10614980 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *25852760
68
+ version_requirements: *10614980
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &25850780 !ruby/object:Gem::Requirement
71
+ requirement: &10614080 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *25850780
79
+ version_requirements: *10614080
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &25849760 !ruby/object:Gem::Requirement
82
+ requirement: &10613480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *25849760
90
+ version_requirements: *10613480
91
91
  description: manages keysets for multiple heroku accounts
92
92
  email: defaultstring@gmail.com
93
93
  executables:
@@ -109,10 +109,10 @@ files:
109
109
  - lib/shacho.rb
110
110
  - lib/shacho/account.rb
111
111
  - lib/shacho/credential.rb
112
- - lib/shacho/key.rb
113
112
  - lib/shacho/runner.rb
114
113
  - lib/shacho/util.rb
115
114
  - shacho.gemspec
115
+ - spec/accounts/edit_account_spec.rb
116
116
  - spec/accounts/list_account_spec.rb
117
117
  - spec/accounts/new_account_spec.rb
118
118
  - spec/accounts/use_account_spec.rb
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  segments:
136
136
  - 0
137
- hash: 2478917913112979594
137
+ hash: -4466314350427891853
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
data/lib/shacho/key.rb DELETED
@@ -1,4 +0,0 @@
1
- module Shacho
2
- class Key
3
- end
4
- end