ruser 0.0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -13
- data/lib/ruser/api.rb +6 -1
- data/lib/ruser/person.rb +85 -41
- data/lib/ruser/version.rb +1 -1
- data/spec/functional/person_spec.rb +4 -7
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a09f150d33f23b3afc41a2d279ce186bc9e99e
|
4
|
+
data.tar.gz: da507723153984d0981079707c2ae46fd49fb449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb8ae5407bc1a926feebcaab64968d92c7e8bbe618c34a1586afec84596ec3e418261da8f61970fa492afd1ba5b86f38215eda6022d8a92526e66663757563eb
|
7
|
+
data.tar.gz: acacf827c86755890d62e4fc0005e6b455df1735121cdd88fbc79db4ee71fc9ca3d9682338b834c59380168eebf22cfd4baccea2e21209cf1bc4fcc413eab74d
|
data/README.md
CHANGED
@@ -2,13 +2,11 @@
|
|
2
2
|
|
3
3
|
RUser is a simple Ruby Gem to communicate with the randomuser.me API.
|
4
4
|
|
5
|
-
[![Build Status](https://travis-ci.org/simpleappgroup/ruser.png)](https://travis-ci.org/simpleappgroup/ruser) [![Coverage Status](https://coveralls.io/repos/simpleappgroup/ruser/badge.png?branch=master)](https://coveralls.io/r/simpleappgroup/ruser?branch=master) [![Code Climate](https://codeclimate.com/github/simpleappgroup/ruser.png)](https://codeclimate.com/github/simpleappgroup/ruser)
|
5
|
+
[![Build Status](https://travis-ci.org/simpleappgroup/ruser.png)](https://travis-ci.org/simpleappgroup/ruser) [![Coverage Status](https://coveralls.io/repos/simpleappgroup/ruser/badge.png?branch=master)](https://coveralls.io/r/simpleappgroup/ruser?branch=master) [![Code Climate](https://codeclimate.com/github/simpleappgroup/ruser.png)](https://codeclimate.com/github/simpleappgroup/ruser) [![Dependency Status](https://gemnasium.com/simpleappgroup/ruser.svg)](https://gemnasium.com/simpleappgroup/ruser)
|
6
6
|
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
First:
|
11
|
-
|
12
10
|
gem install ruser
|
13
11
|
|
14
12
|
or in your Gemfile
|
@@ -16,16 +14,19 @@ or in your Gemfile
|
|
16
14
|
gem 'ruser'
|
17
15
|
|
18
16
|
|
19
|
-
##
|
17
|
+
## Documentation
|
18
|
+
|
19
|
+
[rdoc.info/github/simpleappgroup/ruser](http://rdoc.info/github/simpleappgroup/ruser)
|
20
|
+
|
21
|
+
## Quickstart
|
20
22
|
|
21
23
|
Using RUser in it's simplest form is as easy as calling:
|
22
24
|
|
23
25
|
require 'ruser'
|
24
26
|
|
25
27
|
ruser = RUser::Person.new
|
26
|
-
user = ruser.random
|
27
28
|
|
28
|
-
puts "This user is a #{user.gender}!"
|
29
|
+
puts "This user is a #{user.gender} named #{user.name.first_name}!"
|
29
30
|
|
30
31
|
Then you can access any of the following user attributes:
|
31
32
|
|
@@ -54,21 +55,19 @@ Then you can access any of the following user attributes:
|
|
54
55
|
- picture
|
55
56
|
- seed
|
56
57
|
|
57
|
-
If you want to request a
|
58
|
+
If you want to request a female or male user specifically, specify the `:gender` key in the options hash passed to `new`:
|
58
59
|
|
59
60
|
require 'ruser'
|
60
61
|
|
61
|
-
|
62
|
-
man = ruser.man
|
62
|
+
woman = RUser::Person.new({:gender => 'female'})
|
63
63
|
|
64
|
-
|
64
|
+
man = RUser::Person.new({:gender => 'male'})
|
65
65
|
|
66
|
-
If you want to request a specific user by their seed,
|
66
|
+
If you want to request a specific user by their seed, specify the `:seed` key in the options hash passed to `new`:
|
67
67
|
|
68
68
|
require 'ruser'
|
69
69
|
|
70
|
-
|
71
|
-
alberto = ruser.lookup('lazyWolf')
|
70
|
+
lazyWolf = RUser::Person.new({:seed => 'lazyWolf'})
|
72
71
|
|
73
72
|
## Contributing & Development
|
74
73
|
|
data/lib/ruser/api.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module RUser
|
2
|
+
# This module defines the RandomUser.me API constants used by classes.
|
3
|
+
# @author Simple App Group, LLC.
|
2
4
|
module Api
|
3
|
-
|
5
|
+
# The URL for the API.
|
6
|
+
Url = 'http://api.randomuser.me'
|
7
|
+
|
8
|
+
# The version of the API that is used.
|
4
9
|
Version = '0.3.2'
|
5
10
|
end
|
6
11
|
end
|
data/lib/ruser/person.rb
CHANGED
@@ -3,32 +3,78 @@ require 'multi_json'
|
|
3
3
|
require 'hashie'
|
4
4
|
|
5
5
|
module RUser
|
6
|
+
# This class allows the creation of new users from the RandomUser.me API.
|
7
|
+
# @author Simple App Group, LLC.
|
6
8
|
class Person
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
10
|
+
# @return [String] the user's gender, either male or female.
|
11
|
+
attr_reader :gender
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
13
|
+
# @return [Hash] the user's location including containing the :street, :city, :state, and :zip.
|
14
|
+
attr_reader :location
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
self.fetch(options)
|
19
|
-
end
|
16
|
+
# @return [Hash] the user's name including :title (Mr, Mrs, etc.), :first_name, and :last_name.
|
17
|
+
attr_reader :name
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
self.fetch(options)
|
24
|
-
end
|
19
|
+
# @return [String] the user's email address.
|
20
|
+
attr_reader :email
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
# @return [String] the user's username.
|
23
|
+
attr_reader :username
|
24
|
+
|
25
|
+
# @return [String] the user's password.
|
26
|
+
attr_reader :password
|
27
|
+
|
28
|
+
# @return [String] the user's password salt.
|
29
|
+
attr_reader :salt
|
30
|
+
|
31
|
+
# @return [String] the md5 hash of the user's salted password.
|
32
|
+
attr_reader :md5
|
33
|
+
|
34
|
+
# @return [String] the sha1 hash of the user's salted password.
|
35
|
+
attr_reader :sha1
|
36
|
+
|
37
|
+
# @return [String] the sha256 hash of the user's salted password.
|
38
|
+
attr_reader :sha256
|
39
|
+
|
40
|
+
# @return [String] the date of the user's registration.
|
41
|
+
attr_reader :registered
|
42
|
+
|
43
|
+
# @return [String] the user's date of birth.
|
44
|
+
attr_reader :dob
|
45
|
+
|
46
|
+
# @return [String] the user's phone number.
|
47
|
+
attr_reader :phone
|
48
|
+
|
49
|
+
# @return [String] the user's cell phone number.
|
50
|
+
attr_reader :cell
|
51
|
+
|
52
|
+
# @return [String] the user's social security number.
|
53
|
+
attr_reader :ssn
|
54
|
+
|
55
|
+
# @return [String] the user's profile picture url.
|
56
|
+
attr_reader :picture
|
57
|
+
|
58
|
+
# @return [String] the user's unique seed which allows future calls for the same user.
|
59
|
+
attr_reader :seed
|
30
60
|
|
31
|
-
|
61
|
+
# Creates a new person object
|
62
|
+
#
|
63
|
+
# @param [Hash] options a set of options to pass to the template
|
64
|
+
#
|
65
|
+
# @option options [String] :gender (nil) the user's gender
|
66
|
+
# @option options [String] :seed (nil) the user's unique seed value
|
67
|
+
#
|
68
|
+
# @example Create a random user
|
69
|
+
# Person.new()
|
70
|
+
# @example Create a male user
|
71
|
+
# Person.new({:gender => 'male'})
|
72
|
+
# @example Create a female user
|
73
|
+
# Person.new({:gender => 'female'})
|
74
|
+
# @example Create a specific user from a seed
|
75
|
+
# Person.new({:seed => 'lazyWolf'})
|
76
|
+
# @return [Person]
|
77
|
+
def initialize(options = {})
|
32
78
|
params = options.map { |k,v| "#{k}=#{v}" }
|
33
79
|
data = Hashie::Mash.new(MultiJson.load(RestClient.get [
|
34
80
|
RUser::Api::Url,
|
@@ -36,29 +82,27 @@ module RUser
|
|
36
82
|
"?" + params.join('&')
|
37
83
|
].join('/'))['results'][0])
|
38
84
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
"
|
43
|
-
|
44
|
-
|
45
|
-
"last_name" => data.user.name['last'],
|
46
|
-
},
|
47
|
-
"email" => data.user.email,
|
48
|
-
"username" => data.user.username,
|
49
|
-
"password" => data.user.password,
|
50
|
-
"salt" => data.user.salt,
|
51
|
-
"md5" => data.user.md5,
|
52
|
-
"sha1" => data.user.sha1,
|
53
|
-
"sha256" => data.user.sha256,
|
54
|
-
"registered" => data.user.registered,
|
55
|
-
"dob" => data.user.dob,
|
56
|
-
"phone" => data.user.phone,
|
57
|
-
"cell" => data.user.cell,
|
58
|
-
"ssn" => data.user.SSN,
|
59
|
-
"picture" => data.user.picture,
|
60
|
-
"seed" => data.seed,
|
85
|
+
@gender = data.user.gender
|
86
|
+
@location = data.user.location
|
87
|
+
@name = Hashie::Mash.new({
|
88
|
+
"title" => data.user.name.title,
|
89
|
+
"first_name" => data.user.name['first'],
|
90
|
+
"last_name" => data.user.name['last']
|
61
91
|
})
|
92
|
+
@email = data.user.email
|
93
|
+
@username = data.user.username
|
94
|
+
@password = data.user.password
|
95
|
+
@salt = data.user.salt
|
96
|
+
@md5 = data.user.md5
|
97
|
+
@sha1 = data.user.sha1
|
98
|
+
@sha256 = data.user.sha256
|
99
|
+
@registered = data.user.registered
|
100
|
+
@dob = data.user.dob
|
101
|
+
@phone = data.user.phone
|
102
|
+
@cell = data.user.cell
|
103
|
+
@ssn = data.user.SSN
|
104
|
+
@picture = data.user.picture
|
105
|
+
@seed = data.seed
|
62
106
|
end
|
63
107
|
|
64
108
|
end
|
data/lib/ruser/version.rb
CHANGED
@@ -2,13 +2,10 @@ require 'ruser'
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe 'Person' do
|
5
|
-
before do
|
6
|
-
@person = RUser::Person.new
|
7
|
-
end
|
8
5
|
|
9
6
|
describe '.man' do
|
10
7
|
before do
|
11
|
-
@man =
|
8
|
+
@man = RUser::Person.new(gender: 'male')
|
12
9
|
end
|
13
10
|
|
14
11
|
it 'should return a male user' do
|
@@ -18,7 +15,7 @@ describe 'Person' do
|
|
18
15
|
|
19
16
|
describe '.woman' do
|
20
17
|
before do
|
21
|
-
@woman =
|
18
|
+
@woman = RUser::Person.new(gender: 'female')
|
22
19
|
end
|
23
20
|
|
24
21
|
it 'should return a female user' do
|
@@ -28,7 +25,7 @@ describe 'Person' do
|
|
28
25
|
|
29
26
|
describe '.random' do
|
30
27
|
before do
|
31
|
-
@user =
|
28
|
+
@user = RUser::Person.new()
|
32
29
|
end
|
33
30
|
|
34
31
|
it 'should return a gendered user' do
|
@@ -38,7 +35,7 @@ describe 'Person' do
|
|
38
35
|
|
39
36
|
describe '.lookup' do
|
40
37
|
before do
|
41
|
-
@user =
|
38
|
+
@user = RUser::Person.new(seed: 'lazyWolf')
|
42
39
|
end
|
43
40
|
|
44
41
|
it 'should have the first name alberto' do
|
metadata
CHANGED
@@ -1,73 +1,73 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Kendall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.9'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.9.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.9'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.9.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: hashie
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ~>
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '2.0'
|
40
|
-
- -
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 2.0.5
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '2.0'
|
50
|
-
- -
|
50
|
+
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 2.0.5
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rest-client
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - ~>
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '1.6'
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 1.6.7
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - ~>
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.6'
|
70
|
-
- -
|
70
|
+
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 1.6.7
|
73
73
|
description: A gem to interact with the randomuser.me API.
|
@@ -94,18 +94,19 @@ require_paths:
|
|
94
94
|
- lib
|
95
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.2.
|
107
|
+
rubygems_version: 2.2.0
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Random User Generator API
|
111
111
|
test_files: []
|
112
|
+
has_rdoc:
|