Module: Mocloud::Utils
- Defined in:
- lib/mocloud/utils.rb,
lib/mocloud/utils/credentials.rb,
lib/mocloud/utils/redirect_follower.rb
Defined Under Namespace
Classes: Credentials, RedirectFollower
Class Method Summary
collapse
Class Method Details
.get_password(prompt = "Password: ") ⇒ Object
7
8
9
10
|
# File 'lib/mocloud/utils.rb', line 7
def Utils.get_password(prompt="Password: ")
print prompt
STDIN.noecho(&:gets).chomp
end
|
.handle_error(res, prepend) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/mocloud/utils.rb', line 29
def Utils.handle_error(res, prepend)
if (res[:status] != "200")
begin
result = JSON.parse(res[:body]);
puts "#{prepend}: #{result['reason']}"
rescue
puts "#{prepend}: #{res[:body]}"
end
exit!
end
end
|
.http_get(url, params) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/mocloud/utils.rb', line 17
def Utils.http_get(url, params)
req = RedirectFollower.new ("#{url}?#{params.to_query}")
res = req.resolve
{
:status => res.status,
:body => res.body
}
end
|