peter-mueller 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,122 @@
1
+ = PeterMueller
2
+
3
+ {<img src="https://secure.travis-ci.org/tvw/peter-mueller.png?branch=master" alt="Build Status" />}[http://travis-ci.org/tvw/peter-mueller]
4
+
5
+ PeterMueller is a library for creating fictitious German address data. Though
6
+ pure fictitious, the address data look very real. The data is based on the
7
+ most used firstnames, lastnames, towns, streets etc. in Germany.
8
+
9
+ It can be used eg. to populate a database with fictitios data.
10
+
11
+
12
+ == Usage
13
+
14
+ === Installing the Gem
15
+
16
+
17
+ gem install peter-mueller
18
+
19
+ === Examples
20
+
21
+ Creating a new Person:
22
+
23
+ require 'peter-mueller'
24
+ include PeterMueller
25
+
26
+ person = Person.new
27
+
28
+ puts person
29
+
30
+ may result to:
31
+
32
+ Heinz-Werner Hagemann
33
+
34
+ Breslauer Str. 65
35
+ 24768 Rendsburg
36
+
37
+ Telefon: 04331-687536
38
+ E-Mail: heinzwerner7259@gmx.net
39
+
40
+
41
+ Creating a new Company:
42
+
43
+ company = Company.new
44
+ puts company
45
+
46
+ may result to:
47
+
48
+ Rauch GmbH
49
+
50
+ Einsteinstr. 120
51
+ 60439 Frankfurt
52
+
53
+ Telefon: 069-80095510-0
54
+ E-Mail: info@rauch-gmbh.de
55
+ WWW: www.rauch-gmbh.de
56
+
57
+ Now lets create 2 employees for the same company:
58
+
59
+ company.employees(2).each do |e|
60
+ puts "-" * 20
61
+ puts e
62
+ end
63
+
64
+ which results to:
65
+
66
+ --------------------
67
+ Hanna Fürst
68
+
69
+ Luisenstr. 95
70
+ 91126 Schwabach
71
+
72
+ Telefon: 09122-507532
73
+ Mobil: 01577-87047253
74
+ E-Mail: hanna2178@hotmail.com
75
+
76
+ Geschäftlich
77
+ Telefon: 069-80095510-100
78
+ E-Mail: hanna_fuerst@rauch-gmbh.de
79
+ --------------------
80
+ Claus-Dieter Wetzel
81
+
82
+ Eschstr. 28
83
+ 25980 Sylt
84
+
85
+ Telefon: 04651-9177484
86
+ Mobil: 0170-99988691
87
+
88
+ Geschäftlich
89
+ Telefon: 069-80095510-101
90
+ E-Mail: clausdieter9865@rauch-gmbh.de
91
+
92
+
93
+ == Why PeterMueller?
94
+
95
+ The generated addresses should not result in real addresses. Peter is probably
96
+ the most used German firstname and Müller the probably most popular
97
+ lastname. So PeterMueller stands for anybody and nobody. Something like that ;-)
98
+
99
+
100
+ == Author
101
+
102
+ Thomas Volkmar Worm <mailto:tvw@s4r.de>
103
+
104
+
105
+ == License
106
+
107
+ Copyright (c) 2012 Thomas Volkmar Worm <mailto:tvw@s4r.de>
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining a copy
110
+ of this software and associated documentation files (the "Software"), to deal
111
+ in the Software without restriction, including without limitation the rights
112
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
113
+ copies of the Software, and to permit persons to whom the Software is
114
+ furnished to do so, subject to the following conditions: The above copyright
115
+ notice and this permission notice shall be included in all copies or
116
+ substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS",
117
+ WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
118
+ THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
119
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
120
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
121
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
122
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rdoc/task'
4
+
5
+ task :default do
6
+ sh %Q{bundle install}
7
+ sh %Q{rake build}
8
+ sh %Q{rake install}
9
+ rm_rf "pkg"
10
+ end
11
+
12
+ Rake::RDocTask.new do |rd|
13
+ rd.main = "README.rdoc"
14
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
15
+ rd.rdoc_dir = "rdoc"
16
+ end
@@ -0,0 +1,35 @@
1
+ module PeterMueller
2
+
3
+ # A fictitious address. The address should look valid, but is not an existing address.
4
+ # The street might not even exist in the town. But, by accident, the address could exist.
5
+ class Address
6
+ # The zip code (PLZ).
7
+ attr_reader :zip
8
+
9
+ # Name of the town, the street and its numner.
10
+ attr_reader :town, :street_name, :street_number
11
+
12
+ # The landline phone prefix for the address. This can be used, when
13
+ # generating a Phonenumber which should fit with the address.
14
+ attr_reader :phone_prefix
15
+
16
+ # Creates a new Address.
17
+ def initialize
18
+ (@zip, @phone_prefix, @town) = TOWNS.sample.split("\t")
19
+ @street_name = STREETS.sample
20
+ @street_number = rand(1..120).to_s + (rand(30)==15 ? ('a'..'e').to_a.sample : "")
21
+ end
22
+
23
+ # The streetname and the streetnumber in one string.
24
+ def street
25
+ "#{@street_name} #{@street_number}"
26
+ end
27
+
28
+ # The string representation of the address.
29
+ def to_s
30
+ "#{street}\n#{zip} #{town}"
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,79 @@
1
+ module PeterMueller
2
+
3
+ # A fictitious company.
4
+ # This is how you create a company with 3 employees:
5
+ #
6
+ # c = Company.new
7
+ # puts c
8
+ # c.employees(3).each do |e|
9
+ # puts e
10
+ # end
11
+ class Company
12
+ # The company name.
13
+ attr_reader :name
14
+ # The Address of the company.
15
+ attr_reader :address
16
+ # The Phonenumber of the company.
17
+ attr_reader :phonenumber
18
+ # The second level domain of the company for generating internet addresses.
19
+ attr_reader :domain
20
+ # The Email of the company.
21
+ attr_reader :email
22
+ # The World-Wide-Web-address of the company.
23
+ attr_reader :www
24
+
25
+ # Creates a new company.
26
+ def initialize
27
+ @name = Person.new.lastname + ' ' + FORM_OF_ORGANISATION.sample
28
+ @address = Address.new
29
+ @phonenumber = Phonenumber.new(@address.phone_prefix)
30
+ @phonenumber.extension = "0"
31
+ @domain = domain_from_name(@name)
32
+ @email = Email.new
33
+ @email.host = domain
34
+ @email.user = "info"
35
+ @www = "www.#{@domain}"
36
+ @last_ext = 99
37
+ end
38
+
39
+ # Creates and returns a new employee.
40
+ def employee
41
+ @last_ext += 1
42
+ p = Person.new
43
+ p.office_phonenumber = Phonenumber.new(@phonenumber.prefix, phonenumber.number, @last_ext.to_s)
44
+ p.office_email = Email.new(p)
45
+ p.office_email.host = @domain
46
+ p
47
+ end
48
+
49
+ # Returns n employees as an array or via a block.
50
+ def employees(n)
51
+ return n.times.collect{ employee } unless block_given?
52
+ n.times{ yield employee }
53
+ end
54
+
55
+ # The string representation of the company.
56
+ def to_s
57
+ fields = []
58
+ fields << name
59
+ fields << ""
60
+ fields << address.to_s
61
+ fields << ""
62
+ fields << "Telefon: #{phonenumber}"
63
+ fields << "E-Mail: #{email}"
64
+ fields << "WWW: #{www}"
65
+ fields.join("\n")
66
+ end
67
+
68
+
69
+ private
70
+ def domain_from_name(name)
71
+ [
72
+ name.split(/\-|\s/).collect{|s| Email.umlautfix(s).gsub(/[^a-zA-Z]/,"").downcase }.join("-"),
73
+ TLD.sample,
74
+ ].join(".")
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,8 @@
1
+ aol.de
2
+ freenet.de
3
+ googlemail.com
4
+ gmx.de
5
+ gmx.net
6
+ t-online.de
7
+ hotmail.com
8
+ web.de
@@ -0,0 +1,53 @@
1
+ 1510
2
+ 1511
3
+ 1512
4
+ 1513
5
+ 1514
6
+ 1515
7
+ 1516
8
+ 1517
9
+ 1518
10
+ 1519
11
+ 160
12
+ 170
13
+ 171
14
+ 175
15
+ 1520
16
+ 1521
17
+ 1522
18
+ 1523
19
+ 1524
20
+ 1525
21
+ 1526
22
+ 1527
23
+ 1528
24
+ 1529
25
+ 162
26
+ 172
27
+ 173
28
+ 174
29
+ 1570
30
+ 1571
31
+ 1572
32
+ 1573
33
+ 1574
34
+ 1575
35
+ 1576
36
+ 1577
37
+ 1578
38
+ 1579
39
+ 163
40
+ 177
41
+ 178
42
+ 1590
43
+ 1591
44
+ 1592
45
+ 1593
46
+ 1594
47
+ 1595
48
+ 1596
49
+ 1597
50
+ 1598
51
+ 1599
52
+ 176
53
+ 179