shacho 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/VERSION +1 -1
- data/lib/shacho/account.rb +13 -3
- data/lib/shacho/runner.rb +1 -2
- data/shacho.gemspec +1 -1
- data/spec/accounts/edit_account_spec.rb +23 -11
- data/spec/accounts/use_account_spec.rb +19 -7
- metadata +16 -16
data/README.md
CHANGED
@@ -48,6 +48,7 @@ Where `action` is one of the standard CRUDy actions:
|
|
48
48
|
- create
|
49
49
|
- use
|
50
50
|
- list
|
51
|
+
- edit
|
51
52
|
|
52
53
|
`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
|
53
54
|
|
@@ -68,6 +69,11 @@ shacho use default
|
|
68
69
|
shacho list
|
69
70
|
```
|
70
71
|
|
72
|
+
```
|
73
|
+
#Edit:
|
74
|
+
shacho edit default
|
75
|
+
```
|
76
|
+
|
71
77
|
# details of implementation
|
72
78
|
|
73
79
|
`shacho` creates folders in your `~/.heroku` that correspond to the account name you passsed into the command. The following call:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/shacho/account.rb
CHANGED
@@ -14,9 +14,10 @@ module Shacho
|
|
14
14
|
|
15
15
|
def self.use(options)
|
16
16
|
# TODO Throw error for incorrect params
|
17
|
-
# TODO
|
17
|
+
# TODO Refactor
|
18
18
|
name = options.first
|
19
|
-
|
19
|
+
Runner.error account_not_found(name) if !exists?(name)
|
20
|
+
|
20
21
|
credential_file = "#{account_folder(name)}/credentials"
|
21
22
|
heroku_credentials = "#{HEROKU_PREFIX}/credentials"
|
22
23
|
FileUtils.ln_sf credential_file, heroku_credentials
|
@@ -32,8 +33,9 @@ module Shacho
|
|
32
33
|
|
33
34
|
def self.edit(options)
|
34
35
|
# TODO Throw error for incorrect params
|
35
|
-
# TODO
|
36
|
+
# TODO Refactor
|
36
37
|
name = options.first
|
38
|
+
Runner.error account_not_found(name) if !exists?(name)
|
37
39
|
update_credentials(name)
|
38
40
|
end
|
39
41
|
|
@@ -51,5 +53,13 @@ module Shacho
|
|
51
53
|
credential.prompt(name)
|
52
54
|
credential.write(account_folder(name))
|
53
55
|
end
|
56
|
+
|
57
|
+
def self.exists?(name)
|
58
|
+
File.exists?(account_folder(name))
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.account_not_found(name)
|
62
|
+
"Error: '#{name}' not found. Create account with: shacho create #{name}"
|
63
|
+
end
|
54
64
|
end
|
55
65
|
end
|
data/lib/shacho/runner.rb
CHANGED
data/shacho.gemspec
CHANGED
@@ -2,17 +2,29 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe "Editing an account" do
|
4
4
|
include CoreHelper
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
create_account
|
8
|
-
end
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
context "existing accounts" do
|
7
|
+
before :each do
|
8
|
+
create_account
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to edit the account's credentials" do
|
12
|
+
STDIN.stubs(:gets).returns("newtest@test.com", "newpassword")
|
13
|
+
Shacho::Account.edit(["test"])
|
14
|
+
contents = get_credentials "#{Shacho::HEROKU_PREFIX}/accounts/test"
|
15
|
+
email_test = contents[0] == "newtest@test.com"
|
16
|
+
password_test = contents[1] == "newpassword"
|
17
|
+
(email_test && password_test).should == true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "non-existing accounts" do
|
22
|
+
it "should not be able to edit" do
|
23
|
+
begin
|
24
|
+
results = capture_stdout { Shacho::Account.edit(["rainbows"]) }
|
25
|
+
rescue RuntimeError => e
|
26
|
+
end
|
27
|
+
e.class.should == RuntimeError
|
28
|
+
end
|
17
29
|
end
|
18
30
|
end
|
@@ -3,14 +3,26 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "Using an account" do
|
4
4
|
include CoreHelper
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
context "an existing account" do
|
7
|
+
before :each do
|
8
|
+
create_account
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to use an account" do
|
12
|
+
Shacho::Account.use(["test"])
|
13
|
+
current_creds = get_credentials("#{Shacho::HEROKU_PREFIX}")
|
14
|
+
account_creds = get_credentials("#{Shacho::HEROKU_PREFIX}/accounts/test/")
|
15
|
+
current_creds.should == account_creds
|
16
|
+
end
|
8
17
|
end
|
9
18
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
context "a non-existing account" do
|
20
|
+
it "should not be able to use" do
|
21
|
+
begin
|
22
|
+
results = capture_stdout { Shacho::Account.use(["rainbows"]) }
|
23
|
+
rescue RuntimeError => e
|
24
|
+
end
|
25
|
+
e.class.should == RuntimeError
|
26
|
+
end
|
15
27
|
end
|
16
28
|
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
|
+
version: 0.0.6
|
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: &
|
16
|
+
requirement: &26210340 !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: *
|
24
|
+
version_requirements: *26210340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &26209540 !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: *
|
35
|
+
version_requirements: *26209540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ruby-debug19
|
38
|
-
requirement: &
|
38
|
+
requirement: &26208700 !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: *
|
46
|
+
version_requirements: *26208700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: mocha
|
49
|
-
requirement: &
|
49
|
+
requirement: &26207700 !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: *
|
57
|
+
version_requirements: *26207700
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &26206060 !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: *
|
68
|
+
version_requirements: *26206060
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &26205120 !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: *
|
79
|
+
version_requirements: *26205120
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rcov
|
82
|
-
requirement: &
|
82
|
+
requirement: &26203800 !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: *
|
90
|
+
version_requirements: *26203800
|
91
91
|
description: manages keysets for multiple heroku accounts
|
92
92
|
email: defaultstring@gmail.com
|
93
93
|
executables:
|
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
segments:
|
136
136
|
- 0
|
137
|
-
hash: -
|
137
|
+
hash: -3235613918651740108
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|