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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0065161946c5d55306c092ba55545c0e995b56dd
4
- data.tar.gz: 7cba228886d2e997021199e05d362c285a071eec
3
+ metadata.gz: 88abaeefb34d2ed7fa56c5c4fd0755082f0b04aa
4
+ data.tar.gz: 4cfbdd601f39cea7ecc51ae244accad438dcbddf
5
5
  SHA512:
6
- metadata.gz: eb5d5eb7951503766edc13158912e40b8559f6fe943a48df8efce11afd94f79c9f36aa0f13eae3a00f88b1779cec804368b939cf775927891a0123a18ee43b5b
7
- data.tar.gz: cc61f3cef91f6f703428ad5fbbb76c21e1a017ae4f780626ad533ad703c2b18cbf89bffddaeb01d693292126545ac57f27a32ec2e0b7707583feff0ef2983ec3
6
+ metadata.gz: 4d5c34de18f7d9223782e10321bbbc3c2a557734390841c6a90741d7d06eb774fda8f33d0285a26a74c7ed8614ad1170c71ec74aba607d5f4447890b88c21cd2
7
+ data.tar.gz: 896ac0df214551851941ef814c03a54cfeb8c0961143c96ba9caf7c3f19d60e914960a1f9749bb7905f999575a140b4aa807f3ff61e5f3a5d7585b44e66b0d28
data/db/colors.txt ADDED
@@ -0,0 +1,12 @@
1
+ red
2
+ blue
3
+ pink
4
+ purple
5
+ mauve
6
+ yellow
7
+ orange
8
+ red
9
+ turquoise
10
+ black
11
+ white
12
+ gray
@@ -1,7 +1,7 @@
1
1
  class FakePerson
2
2
 
3
- def favourite_activity
4
- @favourite_activity ||= self.class.activities.sample
3
+ def favorite_activity
4
+ @favorite_activity ||= self.class.activities.sample
5
5
  end
6
6
 
7
7
  def self.activities
@@ -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
@@ -1,7 +1,7 @@
1
1
  class FakePerson
2
2
 
3
- def favourite_food
4
- @favourite_food ||= self.class.foods.sample
3
+ def favorite_food
4
+ @favorite_food ||= self.class.foods.sample
5
5
  end
6
6
 
7
7
  def self.foods
@@ -3,11 +3,11 @@ class FakePerson
3
3
  def likes(count=3)
4
4
  @likes ||= begin
5
5
  if count == 1
6
- [favourite_activity]
6
+ [favorite_activity]
7
7
  elsif count == 2
8
- [favourite_activity, favourite_food]
8
+ [favorite_activity, favorite_food]
9
9
  else
10
- [favourite_activity, favourite_food] + activities_and_foods(count - 2, @dislikes)
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
@@ -6,4 +6,6 @@ require 'fake_person/date_of_birth'
6
6
  require 'fake_person/email'
7
7
  require 'fake_person/activities'
8
8
  require 'fake_person/foods'
9
- require 'fake_person/likes'
9
+ require 'fake_person/likes'
10
+ require 'fake_person/color'
11
+ require 'fake_person/avatar'
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.1
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