shacho 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -49,6 +49,7 @@ Where `action` is one of the standard CRUDy actions:
49
49
  - use
50
50
  - list
51
51
  - edit
52
+ - remove
52
53
 
53
54
  `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
54
55
 
@@ -65,22 +66,27 @@ shacho use default
65
66
  ```
66
67
 
67
68
  ```
68
- #List:
69
+ # List:
69
70
  shacho list
70
71
  ```
71
72
 
72
73
  ```
73
- #Edit:
74
+ # Edit:
74
75
  shacho edit default
75
76
  ```
76
77
 
78
+ ```
79
+ # Remove:
80
+ shacho remove default
81
+ ```
82
+
77
83
  # details of implementation
78
84
 
79
85
  `shacho` creates folders in your `~/.heroku` that correspond to the account name you passsed into the command. The following call:
80
86
 
81
87
  ```
82
88
  shacho create default
83
- ```
89
+ ```
84
90
 
85
91
  Would result in the following file structure:
86
92
 
@@ -104,4 +110,4 @@ git clone git@github.com:kellydunn/shacho
104
110
  cd shacho
105
111
  bundle install
106
112
  rspec spec
107
- ```
113
+ ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.1.0
@@ -39,6 +39,17 @@ module Shacho
39
39
  update_credentials(name)
40
40
  end
41
41
 
42
+ def self.remove(options)
43
+ # TODO Throw error for incorrect params
44
+ # TODO Refactor
45
+ name = options.first
46
+ Runner.error account_not_found(name) if !exists?(name)
47
+
48
+ # TODO Account for a 'corrupted' ~/.heroku/credentials
49
+ # i.e. pointing to deleted account
50
+ FileUtils.rm_r account_folder(name)
51
+ end
52
+
42
53
  def method_missing(sym, *args, &block)
43
54
  Runner.error("Unsupported action. Run `shacho help` for more information")
44
55
  end
data/lib/shacho/util.rb CHANGED
@@ -20,11 +20,13 @@ module Shacho
20
20
  def self.help
21
21
  puts "USAGE"
22
22
  puts " shacho action params"
23
- puts
23
+ puts
24
24
  puts " where `action` is one of the standard CRUDy actions: "
25
25
  puts " create"
26
26
  puts " use"
27
27
  puts " list"
28
+ puts " edit"
29
+ puts " remove"
28
30
  puts
29
31
  puts " `params` refers to any additional parmeters you might want to pass in."
30
32
  puts " For now, that's just the name of the account"
@@ -33,6 +35,8 @@ module Shacho
33
35
  puts " shacho create default"
34
36
  puts " shacho use default"
35
37
  puts " shacho list"
38
+ puts " shacho edit default"
39
+ puts " shacho remove default"
36
40
  end
37
41
  end
38
42
  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", "edit", "help"]
10
+ COMMANDS = ["create", "use", "list", "edit", "remove", "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.7"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kelly"]
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  "spec/accounts/edit_account_spec.rb",
37
37
  "spec/accounts/list_account_spec.rb",
38
38
  "spec/accounts/new_account_spec.rb",
39
+ "spec/accounts/remove_account_spec.rb",
39
40
  "spec/accounts/use_account_spec.rb",
40
41
  "spec/helpers/core.rb",
41
42
  "spec/shacho_spec.rb",
@@ -7,7 +7,7 @@ describe "Editing an account" do
7
7
  before :each do
8
8
  create_account
9
9
  end
10
-
10
+
11
11
  it "should be able to edit the account's credentials" do
12
12
  STDIN.stubs(:gets).returns("newtest@test.com", "newpassword")
13
13
  Shacho::Account.edit(["test"])
@@ -17,14 +17,11 @@ describe "Editing an account" do
17
17
  (email_test && password_test).should == true
18
18
  end
19
19
  end
20
-
20
+
21
21
  context "non-existing accounts" do
22
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
23
+ error = run_command("edit", ["rainbows"])
24
+ error.class.should == RuntimeError
28
25
  end
29
26
  end
30
27
  end
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "Removing an account" do
4
+ include CoreHelper
5
+
6
+ context "existing accounts" do
7
+ before :each do
8
+ create_account
9
+ end
10
+
11
+ it "should be able to remove the account" do
12
+ Shacho::Account.remove(["test"])
13
+
14
+ # TODO test private methods of shacho
15
+ Shacho::Account.exists?("test").should == false
16
+ end
17
+ end
18
+
19
+ context "non-existing accounts" do
20
+ it "should not be able to remove" do
21
+ error = run_command("remove", ["rainbows"])
22
+ error.class.should == RuntimeError
23
+ end
24
+ end
25
+ end
@@ -7,9 +7,9 @@ describe "Using an account" do
7
7
  before :each do
8
8
  create_account
9
9
  end
10
-
10
+
11
11
  it "should be able to use an account" do
12
- Shacho::Account.use(["test"])
12
+ Shacho::Account.use(["test"])
13
13
  current_creds = get_credentials("#{Shacho::HEROKU_PREFIX}")
14
14
  account_creds = get_credentials("#{Shacho::HEROKU_PREFIX}/accounts/test/")
15
15
  current_creds.should == account_creds
@@ -18,11 +18,8 @@ describe "Using an account" do
18
18
 
19
19
  context "a non-existing account" do
20
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
21
+ error = run_command("use", ["rainbows"])
22
+ error.class.should == RuntimeError
26
23
  end
27
24
  end
28
25
  end
data/spec/helpers/core.rb CHANGED
@@ -20,4 +20,12 @@ module CoreHelper
20
20
  end
21
21
  fake.string
22
22
  end
23
+
24
+ def run_command(action, params)
25
+ begin
26
+ Shacho::Account.send(action, params)
27
+ rescue RuntimeError => e
28
+ end
29
+ return e || true
30
+ end
23
31
  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.7
4
+ version: 0.1.0
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: &24813820 !ruby/object:Gem::Requirement
16
+ requirement: &17015060 !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: *24813820
24
+ version_requirements: *17015060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &24812880 !ruby/object:Gem::Requirement
27
+ requirement: &17014360 !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: *24812880
35
+ version_requirements: *17014360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-debug19
38
- requirement: &24812060 !ruby/object:Gem::Requirement
38
+ requirement: &17013660 !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: *24812060
46
+ version_requirements: *17013660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &24811180 !ruby/object:Gem::Requirement
49
+ requirement: &17012980 !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: *24811180
57
+ version_requirements: *17012980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &24809960 !ruby/object:Gem::Requirement
60
+ requirement: &17012200 !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: *24809960
68
+ version_requirements: *17012200
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &24808460 !ruby/object:Gem::Requirement
71
+ requirement: &17004040 !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: *24808460
79
+ version_requirements: *17004040
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &24807440 !ruby/object:Gem::Requirement
82
+ requirement: &17003180 !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: *24807440
90
+ version_requirements: *17003180
91
91
  description: commandline heroku account manager
92
92
  email: defaultstring@gmail.com
93
93
  executables:
@@ -115,6 +115,7 @@ files:
115
115
  - spec/accounts/edit_account_spec.rb
116
116
  - spec/accounts/list_account_spec.rb
117
117
  - spec/accounts/new_account_spec.rb
118
+ - spec/accounts/remove_account_spec.rb
118
119
  - spec/accounts/use_account_spec.rb
119
120
  - spec/helpers/core.rb
120
121
  - spec/shacho_spec.rb
@@ -134,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
135
  version: '0'
135
136
  segments:
136
137
  - 0
137
- hash: -2450151473856936424
138
+ hash: 734393450952432892
138
139
  required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  none: false
140
141
  requirements: