randomuser 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f629a1ae617982207be3f267b7b28676db37395
4
+ data.tar.gz: dd1dc063fbfbfd0e6490c85fd3c7f04675c410f6
5
+ SHA512:
6
+ metadata.gz: 40f9509653a12a3daf989a64c85456e6f8815154e87636d62a004a712920938e07bd8e3204b5e61f2426ebda092fb630ecd2bebba20cd914d891e2c4b6eb5028
7
+ data.tar.gz: ad8e5d44226d4f6c675858d00192949cb3322159416af3e61c5c03b7321ca7e88f6a0c90849968bcc0a5293537df3e4efa729231b61413ac75c432e9f0b7a8e1
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in randomuser.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dominic Giglio
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Randomuser
2
+
3
+ This gem returns simple JSON/hash responses from the [Random User Generator](http://randomuser.me) API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'randomuser'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install randomuser
18
+
19
+ ## Usage
20
+
21
+ To request a single random user:
22
+
23
+ ```
24
+ Randomuser.generate
25
+ ```
26
+
27
+ To request multiple random users:
28
+
29
+ ```
30
+ Randomuser.generate('results=5')
31
+ ```
32
+
33
+ To request a specific gender:
34
+
35
+ ```
36
+ Randomuser.generate('gender=female')
37
+ ```
38
+
39
+ To request a specific gender with multiple results:
40
+
41
+ ```
42
+ Randomuser.generate('results=5&gender=female')
43
+ ```
44
+
45
+ To request a specific user:
46
+
47
+ ```
48
+ Randomuser.generate('seed=smallPanda')
49
+ ```
50
+
51
+ For more information on how to customize requests, please see the [Random User Generator](http://randomuser.me) site.
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ desc 'Generate gem documentation'
5
+ task :doc do
6
+ system 'rm -rf doc/'
7
+ system 'rdoc --exclude=/spec/'
8
+ end
9
+
10
+ namespace :minitest do
11
+ Rake::TestTask.new(:all) do |t|
12
+ t.libs << 'spec'
13
+ t.test_files = FileList['spec/*_spec.rb']
14
+ end
15
+ end
16
+
17
+ task :default => 'minitest:all'
18
+
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
3
+
4
+ puts 'Loading randomuser gem'
5
+ libs = ' -r irb/completion'
6
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/randomuser'}"
7
+ exec "#{irb} #{libs} --simple-prompt"
data/lib/randomuser.rb ADDED
@@ -0,0 +1,29 @@
1
+ # Randomuser Ruby Library
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'json'
5
+ require 'randomuser/version'
6
+
7
+ module Randomuser
8
+ @@api_base = 'http://randomuser.me/g/'
9
+
10
+ def self.api_url(query='')
11
+ "#{@@api_base}?#{query}"
12
+ end
13
+
14
+ def self.generate(query='')
15
+
16
+ # create the http connection object
17
+ uri = URI.parse(self.api_url(query))
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+
20
+ # open our HTTP connection and send the appropriate request type
21
+ # the block will automatically close our connection so we don't have to
22
+ http.start do |connection|
23
+ response = connection.send_request(:get, uri.request_uri)
24
+ response = JSON.parse(response.body, symbolize_names: true)
25
+ response[:results]
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Randomuser
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'randomuser/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+
9
+ #-- author info
10
+ gem.authors = ['Dominic Giglio']
11
+ gem.email = ['humanshell@gmail.com']
12
+ gem.homepage = 'http://developr.me'
13
+
14
+ #-- gem info
15
+ gem.name = 'randomuser'
16
+ gem.version = Randomuser::VERSION
17
+ gem.license = 'MIT'
18
+ gem.summary = %q{Access Random User Generator API}
19
+ gem.description = %q{This gem returns simple JSON/hash responses from the Random User Generator API.}
20
+
21
+ gem.files = `git ls-files`.split($/)
22
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
+ gem.require_paths = ['lib']
25
+
26
+ #-- development dependencies
27
+ gem.add_development_dependency 'minitest'
28
+ gem.add_development_dependency 'bundler', '~> 1.3'
29
+ gem.add_development_dependency 'rake'
30
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: randomuser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dominic Giglio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem returns simple JSON/hash responses from the Random User Generator
56
+ API.
57
+ email:
58
+ - humanshell@gmail.com
59
+ executables:
60
+ - randomuser-console
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .gitignore
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/randomuser-console
70
+ - lib/randomuser.rb
71
+ - lib/randomuser/version.rb
72
+ - randomuser.gemspec
73
+ homepage: http://developr.me
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Access Random User Generator API
97
+ test_files: []