Class: Shacho::Account
- Inherits:
-
Object
show all
- Defined in:
- lib/shacho/account.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
65
66
67
|
# File 'lib/shacho/account.rb', line 65
def method_missing(sym, *args, &block)
Runner.error("Unsupported action. Run `shacho help` for more information")
end
|
Class Method Details
.clear(options) ⇒ Object
55
56
57
58
59
|
# File 'lib/shacho/account.rb', line 55
def self.clear(options)
accounts.each do |account|
remove([File.basename(account)])
end
end
|
.create(options) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/shacho/account.rb', line 5
def self.create(options)
name = options.first
filename = account_folder(name)
if !File.exists?(filename) || !File.directory?(filename)
FileUtils.mkdir_p(filename)
end
update_credentials(name)
Key.generate(name)
end
|
.edit(options) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/shacho/account.rb', line 36
def self.edit(options)
name = options.first
Runner.error account_not_found(name) if !exists?(name)
update_credentials(name)
end
|
.list(options) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/shacho/account.rb', line 28
def self.list(options)
accounts.each do |account|
account_name = File.basename(account)
puts account_name if !(["..", "."].include?(account))
end
end
|
.remove(options) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/shacho/account.rb', line 44
def self.remove(options)
name = options.first
Runner.error account_not_found(name) if !exists?(name)
FileUtils.rm_r account_folder(name)
end
|
.use(options) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/shacho/account.rb', line 16
def self.use(options)
name = options.first
Runner.error account_not_found(name) if !exists?(name)
credential_file = "#{account_folder(name)}/credentials"
heroku_credentials = "#{HEROKU_PREFIX}/credentials"
FileUtils.ln_sf credential_file, heroku_credentials
Key.use(name)
end
|
.which(options) ⇒ Object
61
62
63
|
# File 'lib/shacho/account.rb', line 61
def self.which(options)
puts current_credentials
end
|