prettyusers 0.0.1 → 0.0.2

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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmZhY2YyYTRhMjAxNjMyYTdmYWQxNTQ5YjBjYzU0N2Q5MjQ3ZmU3ZQ==
5
- data.tar.gz: !binary |-
6
- YWUzODI1MGVjZjVkYTNiODY2MWE0NDhmNTBlYzlmZmNiODkxNzk2Yw==
2
+ SHA1:
3
+ metadata.gz: e2ebf969fa50ea1a07a1b82b8abf21ce1edd80c6
4
+ data.tar.gz: 89efdec0658b3c7d1aed63215152a8a992f6b879
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZjNlY2RiNTBhYTIxNzlkMzY2NzMwNDY1NTNmNWE1NjgyMTQ2YjliYzQ5Y2Iw
10
- YWVjZmYxZmI2ZTMzNTA2MTQxYjk4ZjY0NWJmYmUzZWViM2MzMWM3MGQwNjhl
11
- MDA3MDNhZWU0ZDVhY2I2MjA1ZTk0NmExYjA4Y2EzMWE0OWQ5ZGI=
12
- data.tar.gz: !binary |-
13
- OThhZmUzMDhlMGU2N2FjYjM3MzUwMTEyM2RkMDUwZWMxZDVmNmE1MTUwZjli
14
- YjkzYjliMTU2ZTkyZWViNDUzMGY4ZWMxNTU4MzUyYzhkYzg0Zjg4MDdiZmE0
15
- MWY0MTQwYjg1MzAzN2I2NDIwM2FiZjQxZDBmNDEzZmVmYTVkMjE=
6
+ metadata.gz: ce1c710009bbd62901e74a08c7d2b5df3b5a42a6a817bb03ce1b14f21b4b04e9f8b099c461deaa80f73d160a6c6857c52b2791b0360d53f9da9338522acd66b1
7
+ data.tar.gz: a8bdf032c0ad44ee8468199f5f6c35062d0fc1e9b8941426709e630173b2860ee07bcd3f2a7f77f41f9783d99785e5afd1c92c8e8f7fbfdfd46ca25efca0bf76
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 medyo_hp
1
+ Copyright (c) 2015 medyo_hp
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # Prettyusers
1
+ # Pretty Users
2
+ ![Preview](https://raw.github.com/medyo/prettyusers/master/demo_prettyusers.png)
2
3
 
3
- TODO: Write a gem description
4
+ This gem allows you to generate pretty user's information with an avatar, name, password, email, gender, phone ...
5
+
6
+ Based on http://randomuser.me/ api
4
7
 
5
8
  ## Installation
6
9
 
@@ -15,10 +18,37 @@ And then execute:
15
18
  Or install it yourself as:
16
19
 
17
20
  $ gem install prettyusers
18
-
21
+
19
22
  ## Usage
20
23
 
21
- TODO: Write usage instructions here
24
+ ### One Random user ###
25
+ gender is optional (male or female)
26
+
27
+ ``` ruby
28
+ Prettyusers.random({:gender => 'male'})
29
+ ```
30
+
31
+ ### Multi users ###
32
+ Gender and count are optional
33
+
34
+ Gender accepts : male or female
35
+
36
+ Count accepts a value between 1 and 100
37
+
38
+
39
+ ``` ruby
40
+ Prettyusers.generate({:gender => 'female', :count => 3})
41
+ ```
42
+
43
+ ### Access data ###
44
+
45
+ ``` ruby
46
+ user = Prettyusers.random.email
47
+ users = Prettyusers.generate(:count => 2).first.email
48
+ ```
49
+
50
+ `name[:firtname]`, `name[:lastname]`,`picture`,`location[:street]`,`location[:city]`,`location[:zip]`,`location[:state]`, `gender`, `email`, `password`, `md5_password`, `sha1_hash`,`phone`,`cell`,`SSN`
51
+
22
52
 
23
53
  ## Contributing
24
54
 
Binary file
data/lib/prettyusers.rb CHANGED
@@ -6,6 +6,7 @@ module Prettyusers
6
6
  class User
7
7
  @@fields = [
8
8
  :gender,
9
+ :title,
9
10
  :name,
10
11
  :location,
11
12
  :email,
@@ -37,9 +38,9 @@ module Prettyusers
37
38
  (!gender.nil? and ['male','female'].include? gender.downcase) ? '&gender='+gender : ''
38
39
  end
39
40
 
40
- # Build Count of results Uri (Max 5)
41
+ # Build Count of results Uri (Max 100)
41
42
  def self.count_uri(count)
42
- (!count.nil? and (1..5).include?(count)) ? '?results='+count.to_s : '?results=1'
43
+ (!count.nil? and (1..100).include?(count)) ? '?results='+count.to_s : '?results=1'
43
44
  end
44
45
 
45
46
  # Exec the request
@@ -53,26 +54,32 @@ module Prettyusers
53
54
  end
54
55
 
55
56
  uri = URI.parse(uri)
56
- http = Net::HTTP.new(uri.host, uri.port)
57
57
 
58
- http.start do |connection|
59
- response = connection.send_request(:get, uri.request_uri)
60
- response = JSON.parse(response.body, symbolize_names: true)
58
+ response = Net::HTTP.start(uri.host) do |http|
59
+ http.get uri.request_uri, 'User-Agent' => 'PrettyUsers'
60
+ end
61
+
62
+ case response
63
+ when Net::HTTPRedirection
64
+ when Net::HTTPSuccess
65
+ response = JSON.parse(response.body, symbolize_names: true)
61
66
 
62
- if(response[:results].count>0)
63
- users = Array.new
64
- response[:results].each do |u|
67
+ if(response[:results].count>0)
68
+ users = Array.new
69
+ response[:results].each do |u|
65
70
 
66
- r = u[:user] # minifying :)
67
- name = {:firstname => r[:name][:first], :lastname => r[:name][:last]}
68
- location = {:street => r[:location][:street], :city =>r[:location][:city], :state => r[:location][:state], :zip => r[:location][:zip]}
69
-
70
- u = User.new({:name => name,:picture=>r[:picture],:gender => r[:gender],:location => location,:email => r[:email],:password =>r[:password], :md5_hash =>r[:md5_hash], :sha1_hash => r[:sha1_hash], :phone => r[:phone], :cell => r[:cell], :SSN => r[:SSN], })
71
- users.push(u)
71
+ r = u[:user] # minifying :)
72
+ name = {:title =>r[:title], :firstname => r[:name][:first], :lastname => r[:name][:last]}
73
+ location = {:street => r[:location][:street], :city =>r[:location][:city], :state => r[:location][:state], :zip => r[:location][:zip]}
74
+
75
+ u = User.new({:name => name,:picture=>r[:picture],:gender => r[:gender],:location => location,:email => r[:email],:password =>r[:password], :md5_password =>r[:md5], :sha1_hash => r[:sha1], :phone => r[:phone], :cell => r[:cell], :SSN => r[:SSN]})
76
+ users.push(u)
72
77
 
73
- end
74
- users.count == 1 ? users.first : users
75
- end
78
+ end
79
+ users.count == 1 ? users.first : users
80
+ end
81
+ else
82
+ response.error!
76
83
  end
77
84
 
78
85
 
@@ -1,3 +1,3 @@
1
1
  module Prettyusers
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/prettyusers.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["El Mehdi Sakout"]
10
10
  spec.email = ["elmehdi.sakout@gmail.com"]
11
11
  spec.description = %q{Generate pretty users for your tests}
12
- spec.summary = %q{This gem allows you to generate pretty user's information with an avatar, name, password, email, gender, phone ... }
12
+ spec.summary = %q{This Gem generate pretty user's information with an avatar, name, password, email, gender, phone ... }
13
13
  spec.homepage = "https://github.com/medyo/prettyusers"
14
14
  spec.license = "MIT"
15
15
 
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rake", '~> 0'
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prettyusers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - El Mehdi Sakout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-13 00:00:00.000000000 Z
11
+ date: 2015-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Generate pretty users for your tests
@@ -50,6 +50,7 @@ files:
50
50
  - LICENSE.txt
51
51
  - README.md
52
52
  - Rakefile
53
+ - demo_prettyusers.png
53
54
  - lib/prettyusers.rb
54
55
  - lib/prettyusers/version.rb
55
56
  - prettyusers.gemspec
@@ -63,19 +64,19 @@ require_paths:
63
64
  - lib
64
65
  required_ruby_version: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - ! '>='
67
+ - - '>='
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  requirements:
71
- - - ! '>='
72
+ - - '>='
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
75
  requirements: []
75
76
  rubyforge_project:
76
- rubygems_version: 2.1.1
77
+ rubygems_version: 2.2.2
77
78
  signing_key:
78
79
  specification_version: 4
79
- summary: This gem allows you to generate pretty user's information with an avatar,
80
- name, password, email, gender, phone ...
80
+ summary: This Gem generate pretty user's information with an avatar, name, password,
81
+ email, gender, phone ...
81
82
  test_files: []