fake_person 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/colors.txt +12 -0
- data/lib/fake_person/activities.rb +2 -2
- data/lib/fake_person/avatar.rb +16 -0
- data/lib/fake_person/color.rb +15 -0
- data/lib/fake_person/foods.rb +2 -2
- data/lib/fake_person/likes.rb +3 -3
- data/lib/fake_person.rb +3 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88abaeefb34d2ed7fa56c5c4fd0755082f0b04aa
|
4
|
+
data.tar.gz: 4cfbdd601f39cea7ecc51ae244accad438dcbddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5c34de18f7d9223782e10321bbbc3c2a557734390841c6a90741d7d06eb774fda8f33d0285a26a74c7ed8614ad1170c71ec74aba607d5f4447890b88c21cd2
|
7
|
+
data.tar.gz: 896ac0df214551851941ef814c03a54cfeb8c0961143c96ba9caf7c3f19d60e914960a1f9749bb7905f999575a140b4aa807f3ff61e5f3a5d7585b44e66b0d28
|
data/db/colors.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class FakePerson
|
2
|
+
|
3
|
+
AVATAR_QUANTITIES = {:male => 76, :female => 65}
|
4
|
+
AVATAR_SIZE_GROUPS = [128, 256, 512]
|
5
|
+
|
6
|
+
def avatar_identifier
|
7
|
+
@avatar_identifier ||= rand(AVATAR_QUANTITIES[self.gender])
|
8
|
+
end
|
9
|
+
|
10
|
+
def avatar_url(options = {})
|
11
|
+
options[:size] ||= 128
|
12
|
+
closest_size = AVATAR_SIZE_GROUPS.select {|s| s >= options[:size]}.first
|
13
|
+
"#{options[:secure] == false ? 'http' : 'https'}://s3-eu-west-1.amazonaws.com/fakepeople/#{gender}/#{closest_size}/#{avatar_identifier}.png"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class FakePerson
|
2
|
+
|
3
|
+
def favorite_color
|
4
|
+
self.class.colors.sample
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.colors
|
8
|
+
@colors ||= begin
|
9
|
+
path = File.expand_path(File.join('..', '..', '..', 'db', "colors.txt"), __FILE__)
|
10
|
+
File.read(path).split("\n").compact.map(&:capitalize)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
data/lib/fake_person/foods.rb
CHANGED
data/lib/fake_person/likes.rb
CHANGED
@@ -3,11 +3,11 @@ class FakePerson
|
|
3
3
|
def likes(count=3)
|
4
4
|
@likes ||= begin
|
5
5
|
if count == 1
|
6
|
-
[
|
6
|
+
[favorite_activity]
|
7
7
|
elsif count == 2
|
8
|
-
[
|
8
|
+
[favorite_activity, favorite_food]
|
9
9
|
else
|
10
|
-
[
|
10
|
+
[favorite_activity, favorite_food] + activities_and_foods(count - 2, @dislikes)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/fake_person.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_person
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -18,12 +18,15 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- db/activities.txt
|
21
|
+
- db/colors.txt
|
21
22
|
- db/foods.txt
|
22
23
|
- db/given_names.female.txt
|
23
24
|
- db/given_names.male.txt
|
24
25
|
- db/surnames.txt
|
25
26
|
- lib/fake_person.rb
|
26
27
|
- lib/fake_person/activities.rb
|
28
|
+
- lib/fake_person/avatar.rb
|
29
|
+
- lib/fake_person/color.rb
|
27
30
|
- lib/fake_person/date_of_birth.rb
|
28
31
|
- lib/fake_person/email.rb
|
29
32
|
- lib/fake_person/foods.rb
|