dnsimple-ruby 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -0
- data/VERSION +1 -1
- data/lib/dnsimple.rb +1 -0
- data/lib/dnsimple/cli.rb +3 -0
- data/lib/dnsimple/commands/describe_user.rb +18 -0
- data/lib/dnsimple/user.rb +44 -0
- data/spec/user_spec.rb +22 -0
- metadata +8 -4
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/dnsimple.rb
CHANGED
data/lib/dnsimple/cli.rb
CHANGED
@@ -29,6 +29,8 @@ module DNSimple
|
|
29
29
|
|
30
30
|
def commands
|
31
31
|
{
|
32
|
+
'info' => DNSimple::Commands::DescribeUser,
|
33
|
+
|
32
34
|
'create' => DNSimple::Commands::CreateDomain,
|
33
35
|
'describe' => DNSimple::Commands::DescribeDomain,
|
34
36
|
'list' => DNSimple::Commands::ListDomains,
|
@@ -49,6 +51,7 @@ module DNSimple
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
54
|
+
require 'dnsimple/commands/describe_user'
|
52
55
|
require 'dnsimple/commands/create_domain'
|
53
56
|
require 'dnsimple/commands/describe_domain'
|
54
57
|
require 'dnsimple/commands/list_domains'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeUser
|
4
|
+
def execute(args, options={})
|
5
|
+
puts "Connecting to #{Client.base_uri}"
|
6
|
+
user = User.me
|
7
|
+
puts "User details:"
|
8
|
+
puts "\tID:#{user.id}"
|
9
|
+
puts "\tCreated: #{user.created_at}"
|
10
|
+
puts "\tEmail: #{user.email}"
|
11
|
+
puts "\tSuccessful logins: #{user.login_count}"
|
12
|
+
puts "\tFailed logins: #{user.failed_login_count}"
|
13
|
+
puts "\tDomains in account: #{user.domain_count}"
|
14
|
+
puts "\tDomains allowed: #{user.domain_limit}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module DNSimple
|
2
|
+
class User
|
3
|
+
include HTTParty
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
|
7
|
+
attr_accessor :created_at
|
8
|
+
|
9
|
+
attr_accessor :updated_at
|
10
|
+
|
11
|
+
attr_accessor :email
|
12
|
+
|
13
|
+
attr_accessor :login_count
|
14
|
+
|
15
|
+
attr_accessor :failed_login_count
|
16
|
+
|
17
|
+
attr_accessor :domain_count
|
18
|
+
|
19
|
+
attr_accessor :domain_limit
|
20
|
+
|
21
|
+
def initialize(attributes)
|
22
|
+
attributes.each do |key, value|
|
23
|
+
m = "#{key}=".to_sym
|
24
|
+
self.send(m, value) if self.respond_to?(m)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.me(options={})
|
29
|
+
options.merge!({:basic_auth => Client.credentials})
|
30
|
+
response = self.get("#{Client.base_uri}/users/me.json", options)
|
31
|
+
|
32
|
+
case response.code
|
33
|
+
when 200
|
34
|
+
return User.new(response["user"])
|
35
|
+
when 401
|
36
|
+
raise RuntimeError, "Authentication failed"
|
37
|
+
when 404
|
38
|
+
raise RuntimeError, "Could not find user"
|
39
|
+
else
|
40
|
+
raise RuntimeError, "Error: #{response.code} #{response.message}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/user_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
|
3
|
+
describe DNSimple::User do
|
4
|
+
describe ".me" do
|
5
|
+
before do
|
6
|
+
@user = DNSimple::User.me
|
7
|
+
end
|
8
|
+
it "returns the current user" do
|
9
|
+
@user.should_not be_nil
|
10
|
+
end
|
11
|
+
it "has attributes" do
|
12
|
+
@user.id.should_not be_nil
|
13
|
+
@user.created_at.should_not be_nil
|
14
|
+
@user.updated_at.should_not be_nil
|
15
|
+
@user.email.should_not be_nil
|
16
|
+
@user.login_count.should_not be_nil
|
17
|
+
@user.failed_login_count.should_not be_nil
|
18
|
+
@user.domain_count.should_not be_nil
|
19
|
+
@user.domain_limit.should_not be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Anthony Eden
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-18 00:00:00 -10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -59,17 +59,20 @@ files:
|
|
59
59
|
- lib/dnsimple/commands/delete_domain.rb
|
60
60
|
- lib/dnsimple/commands/delete_record.rb
|
61
61
|
- lib/dnsimple/commands/describe_domain.rb
|
62
|
+
- lib/dnsimple/commands/describe_user.rb
|
62
63
|
- lib/dnsimple/commands/list_domains.rb
|
63
64
|
- lib/dnsimple/commands/list_records.rb
|
64
65
|
- lib/dnsimple/domain.rb
|
65
66
|
- lib/dnsimple/error.rb
|
66
67
|
- lib/dnsimple/record.rb
|
67
68
|
- lib/dnsimple/template.rb
|
69
|
+
- lib/dnsimple/user.rb
|
68
70
|
- spec/README
|
69
71
|
- spec/domain_spec.rb
|
70
72
|
- spec/record_spec.rb
|
71
73
|
- spec/spec_helper.rb
|
72
74
|
- spec/template_spec.rb
|
75
|
+
- spec/user_spec.rb
|
73
76
|
has_rdoc: true
|
74
77
|
homepage: http://github.com/aetrion/dnsimple-ruby
|
75
78
|
licenses: []
|
@@ -105,3 +108,4 @@ test_files:
|
|
105
108
|
- spec/record_spec.rb
|
106
109
|
- spec/spec_helper.rb
|
107
110
|
- spec/template_spec.rb
|
111
|
+
- spec/user_spec.rb
|