peter-mueller 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == Version 1.0.2 - 4-MAY-2012
2
+
3
+ * some new methods for creating Email#user.
4
+ * Company#employee now creates the Email#user according to a typical schema.
5
+
1
6
  == Version 1.0.1 - 3-MAY-2012
2
7
 
3
8
  * new methods Company#name= and Company#domain=
@@ -58,6 +58,7 @@ module PeterMueller
58
58
  p = Person.new
59
59
  p.office_phonenumber = Phonenumber.new(@phonenumber.prefix, phonenumber.number, @last_ext.to_s)
60
60
  p.office_email = Email.new(p)
61
+ p.office_email.user_from_names(p, ".")
61
62
  p.office_email.host = @domain
62
63
  p
63
64
  end
@@ -11,22 +11,22 @@ module PeterMueller
11
11
  # Creates a new email address.
12
12
  def initialize(person = Person.new, owndomain = (rand(1..50) == 2))
13
13
  if owndomain
14
- @user = [
15
- user_from_names(person),
16
- user_from_firstname(person, ""),
17
- user_from_initials(person, ""),
18
- ].sample
14
+ [
15
+ lambda{ user_from_names(person) },
16
+ lambda{ user_from_firstname(person, "") },
17
+ lambda{ user_from_initials(person, "") },
18
+ ].sample.call
19
19
 
20
20
  @host = [
21
- user_from_names(person),
21
+ from_names(person),
22
22
  TLD.sample,
23
23
  ].join(".")
24
24
  else
25
- @user = [
26
- user_from_names(person),
27
- user_from_firstname(person),
28
- user_from_initials(person),
29
- ].sample
25
+ [
26
+ lambda{ user_from_names(person) },
27
+ lambda{ user_from_firstname(person) },
28
+ lambda{ user_from_initials(person) },
29
+ ].sample.call
30
30
 
31
31
  @host = FREEMAIL_PROVIDER.sample
32
32
  end
@@ -48,24 +48,30 @@ module PeterMueller
48
48
  gsub("ß","ss")
49
49
  end
50
50
 
51
- private
51
+ # Generates the user-part from the names of a Person.
52
52
  def user_from_names(person, sepchar=["","_","."].sample)
53
- part1 = self.class.umlautfix(person.firstname).gsub(/[^a-zA-Z]/,"").downcase
54
- part2 = self.class.umlautfix(person.lastname).gsub(/[^a-zA-Z]/,"").downcase
55
- "#{part1}#{sepchar}#{part2}"
53
+ @user = from_names(person, sepchar)
56
54
  end
57
55
 
56
+ # Generates the user-part from the firstname and a number.
58
57
  def user_from_firstname(person, number = rand(1..9999).to_s)
59
58
  part = self.class.umlautfix(person.firstname).gsub(/[^a-zA-Z]/,"").downcase
60
- "#{part}#{number}"
59
+ @user = "#{part}#{number}"
61
60
  end
62
61
 
62
+ # Generates the user-part from the initials and a number.
63
63
  def user_from_initials(person, number = rand(1..9999).to_s)
64
64
  part1 = self.class.umlautfix(person.firstname).gsub(/[^a-zA-Z]/,"").downcase
65
65
  part2 = self.class.umlautfix(person.lastname).gsub(/[^a-zA-Z]/,"").downcase
66
- "#{part1[0]}#{part2[0]}#{number}"
66
+ @user = "#{part1[0]}#{part2[0]}#{number}"
67
67
  end
68
68
 
69
+ private
70
+ def from_names(person, sepchar=["","_","."].sample)
71
+ part1 = self.class.umlautfix(person.firstname).gsub(/[^a-zA-Z]/,"").downcase
72
+ part2 = self.class.umlautfix(person.lastname).gsub(/[^a-zA-Z]/,"").downcase
73
+ "#{part1}#{sepchar}#{part2}"
74
+ end
69
75
  end
70
76
 
71
77
  end
@@ -2,7 +2,7 @@ module PeterMueller
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peter-mueller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &16750960 !ruby/object:Gem::Requirement
16
+ requirement: &20824180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *16750960
24
+ version_requirements: *20824180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &16750180 !ruby/object:Gem::Requirement
27
+ requirement: &20823600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.9'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *16750180
35
+ version_requirements: *20823600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ZenTest
38
- requirement: &16746360 !ruby/object:Gem::Requirement
38
+ requirement: &20822980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 4.7.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *16746360
46
+ version_requirements: *20822980
47
47
  description: ! "A library for creating fictitious German address data.\n The
48
48
  addresses look real, though they are of pure random and fictitious origin."
49
49
  email: