ruser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66d6e7ac951762522daa3c1555b480fa0467c5e7
4
+ data.tar.gz: d079425789e9f7797009c984d49f552adb4ffd82
5
+ SHA512:
6
+ metadata.gz: 549a23b7444b88a3d390ad6e0a973a8510368bb62b0099392dae9f23dde199a3f866aae95fca0b9da41b28c0292a473ef2b4801aed06fc2955c4883e5d00a3a0
7
+ data.tar.gz: bb792c050ef150617928fdc8047df9238793b9c0971b7cef9733680b77ab15024fb8e7bf61a7c8204b27ffb6bf59a2623217256b8fba6d94b1683473cde7b59e
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2014 Simple App Group LLC <info@simpleappgroup.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # RUser
2
+
3
+ RUser is a simple Ruby Gem to communicate with the randomuser.me API.
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)
6
+
7
+
8
+ ## Installation
9
+
10
+ First:
11
+
12
+ gem install ruser
13
+
14
+ or in your Gemfile
15
+
16
+ gem 'ruser'
17
+
18
+
19
+ ## Usage
20
+
21
+ Using RUser in it's simplest form is as easy as calling:
22
+
23
+ require 'ruser'
24
+
25
+ ruser = RUser::Person.new
26
+ user = ruser.random
27
+
28
+ puts "This user is a #{user.gender}!"
29
+
30
+ Then you can access any of the following user attributes:
31
+
32
+ - gender
33
+ - name
34
+ - first\_name
35
+ - last\_name
36
+ - title
37
+ - location
38
+ - street
39
+ - city
40
+ - state
41
+ - zip
42
+ - email
43
+ - username
44
+ - password
45
+ - salt
46
+ - md5
47
+ - sha1
48
+ - sha256
49
+ - registered
50
+ - dob
51
+ - phone
52
+ - cell
53
+ - ssn
54
+ - picture
55
+ - seed
56
+
57
+ If you want to request a male or female user specifically, call either the `.man` or `.woman` methods like so:
58
+
59
+ require 'ruser'
60
+
61
+ ruser = RUser::Person.new
62
+ man = ruser.man
63
+
64
+ woman = ruser.woman
65
+
66
+ If you want to request a specific user by their seed, simply call the `.lookup` method:
67
+
68
+ require 'ruser'
69
+
70
+ ruser = RUser::Person.new
71
+ alberto = ruser.lookup('lazyWolf')
72
+
73
+ ## Contributing & Development
74
+
75
+ $ git clone https://github.com/simpleappgroup/ruser && cd ruser
76
+ $ bundle install
77
+
78
+ * Fork the project.
79
+ * Make your feature addition or bug fix. All specs should pass.
80
+ * Add specs for your changes. This is important so I don't break it in a future version unintentionally.
81
+ * Commit, do not mess with version, or history. If you want to have your own version, that is fine but bump version in a commit by itself in another branch so a maintainer ignore it when your pull request is merged.
82
+ * Send a pull request. Bonus points for topic branches.
83
+
84
+ ## License & Copyright
85
+
86
+ See LICENSE for details.
data/lib/ruser/api.rb ADDED
@@ -0,0 +1,6 @@
1
+ module RUser
2
+ module Api
3
+ Url = 'http://api.randomuser.me'
4
+ Version = '0.3.2'
5
+ end
6
+ end
@@ -0,0 +1,65 @@
1
+ require 'rest_client'
2
+ require 'multi_json'
3
+ require 'hashie'
4
+
5
+ module RUser
6
+ class Person
7
+
8
+ def initialize
9
+ self
10
+ end
11
+
12
+ def random
13
+ self.fetch
14
+ end
15
+
16
+ def man
17
+ options = { "gender" => "male" }
18
+ self.fetch(options)
19
+ end
20
+
21
+ def woman
22
+ options = { "gender" => "female" }
23
+ self.fetch(options)
24
+ end
25
+
26
+ def lookup(seed = "")
27
+ options = { "seed" => seed }
28
+ self.fetch(options)
29
+ end
30
+
31
+ def fetch(options = {})
32
+ params = options.map { |k,v| "#{k}=#{v}" }
33
+ data = Hashie::Mash.new(MultiJson.load(RestClient.get [
34
+ RUser::Api::Url,
35
+ RUser::Api::Version,
36
+ "?" + params.join('&')
37
+ ].join('/'))['results'][0])
38
+
39
+ Hashie::Mash.new({
40
+ "gender" => data.user.gender,
41
+ "location" => data.user.location,
42
+ "name" => {
43
+ "title" => data.user.name.title,
44
+ "first_name" => data.user.name['first'],
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,
61
+ })
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module RUser
2
+ Version = '0.0.1'
3
+ end
data/lib/ruser.rb ADDED
@@ -0,0 +1,5 @@
1
+ module RUser
2
+ autoload :Version, 'ruser/version'
3
+ autoload :Api, 'ruser/api'
4
+ autoload :Person, 'ruser/person'
5
+ end
@@ -0,0 +1,57 @@
1
+ require 'ruser'
2
+ require 'spec_helper'
3
+
4
+ describe 'Person' do
5
+ before do
6
+ @person = RUser::Person.new
7
+ end
8
+
9
+ describe '.man' do
10
+ before do
11
+ @man = @person.man
12
+ end
13
+
14
+ it 'should return a male user' do
15
+ expect(@man.gender).to eql('male')
16
+ end
17
+ end
18
+
19
+ describe '.woman' do
20
+ before do
21
+ @woman = @person.woman
22
+ end
23
+
24
+ it 'should return a female user' do
25
+ expect(@woman.gender).to eql('female')
26
+ end
27
+ end
28
+
29
+ describe '.random' do
30
+ before do
31
+ @user = @person.random
32
+ end
33
+
34
+ it 'should return a gendered user' do
35
+ expect(@user.gender).to be_instance_of(String)
36
+ end
37
+ end
38
+
39
+ describe '.lookup' do
40
+ before do
41
+ @user = @person.lookup('lazyWolf')
42
+ end
43
+
44
+ it 'should have the first name alberto' do
45
+ expect(@user.name.first_name).to eql('alberto')
46
+ end
47
+
48
+ it 'should have the last name holland' do
49
+ expect(@user.name.last_name).to eql('holland')
50
+ end
51
+
52
+ it 'should return a male user' do
53
+ expect(@user.gender).to eql('male')
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+
5
+ SimpleCov.start
6
+ Coveralls.wear!
7
+
8
+ RSpec.configure do |config|
9
+ config.order = "random"
10
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Kendall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem to interact with the randomuser.me API.
14
+ email: josh@simpleappgroup.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/ruser.rb
22
+ - lib/ruser/api.rb
23
+ - lib/ruser/person.rb
24
+ - lib/ruser/version.rb
25
+ - spec/functional/person_spec.rb
26
+ - spec/spec_helper.rb
27
+ homepage: http://github.com/simpleappgroup/ruser
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.2.2
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Random User Generator API
51
+ test_files: []