dohruby 0.2.1 → 0.3
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.
- data/CHANGELOG +8 -0
- data/bin/config.rb +61 -0
- data/bin/create_database.rb +13 -6
- data/bin/gendata.rb +37 -0
- data/bin/migrate.rb +66 -0
- data/bin/{rcov-preprocess-files.rb → rcov_preprocess_files.rb} +1 -1
- data/bin/run_tests.rb +15 -5
- data/bin/update_rdoc.rb +28 -0
- data/dohapp_home +0 -0
- data/lib/doh/app/activate_database.rb +5 -12
- data/lib/doh/app/activate_logger.rb +29 -13
- data/lib/doh/app/config.rb +18 -0
- data/lib/doh/app/home.rb +3 -8
- data/lib/doh/app/init_runnable.rb +39 -8
- data/lib/doh/app/init_script.rb +19 -0
- data/lib/doh/app/init_unit_test.rb +4 -1
- data/lib/doh/app_no_stdio.rb +1 -1
- data/lib/doh/boot/app.rb +2 -0
- data/lib/doh/boot/app_pwd.rb +2 -0
- data/lib/doh/boot/find_dohruby.rb +5 -0
- data/lib/doh/boot/find_dohruby_18.rb +37 -0
- data/lib/doh/boot/find_dohruby_19.rb +58 -0
- data/lib/doh/boot/init_runnable.rb +2 -0
- data/lib/doh/boot/options.rb +2 -0
- data/lib/doh/core/array.rb +10 -0
- data/lib/doh/core/bigdecimal.rb +15 -0
- data/lib/doh/core/date.rb +73 -0
- data/lib/doh/core/deep_dup.rb +12 -0
- data/lib/doh/core/hash.rb +21 -0
- data/lib/doh/core/object.rb +6 -0
- data/lib/doh/core/require_local.rb +5 -0
- data/lib/doh/core/socket.rb +25 -0
- data/lib/doh/core/string.rb +34 -4
- data/lib/doh/core.rb +4 -1
- data/lib/doh/data/basic.rb +24 -19
- data/lib/doh/data/bulk.rb +28 -88
- data/lib/doh/data/catalog.rb +44 -0
- data/lib/doh/data/human.rb +50 -42
- data/lib/doh/data/make_global.rb +3 -0
- data/lib/doh/data/require_datagen.rb +2 -1
- data/lib/doh/home.rb +16 -0
- data/lib/doh/logger/email_acceptor.rb +6 -3
- data/lib/doh/logger/event.rb +19 -6
- data/lib/doh/logger/formatter.rb +22 -16
- data/lib/doh/logger/interface.rb +13 -0
- data/lib/doh/logger/iostream_acceptor.rb +3 -2
- data/lib/doh/logger/null_interface.rb +1 -0
- data/lib/doh/logger/proxy.rb +53 -0
- data/lib/doh/logger/socket_acceptor.rb +53 -0
- data/lib/doh/logger/socket_viewer.rb +64 -0
- data/lib/doh/logger/standard_interface.rb +46 -17
- data/lib/doh/logger/util.rb +18 -0
- data/lib/doh/logger.rb +2 -1
- data/lib/doh/logger_configure.rb +1 -1
- data/lib/doh/merb/db_session.rb +136 -0
- data/lib/doh/merb/form_helpers.rb +16 -0
- data/lib/doh/merb/login.rb +27 -12
- data/lib/doh/merb/merb_dohsession.rb +4 -0
- data/lib/doh/merb/notify_on_exception.rb +1 -1
- data/lib/doh/merb/session.rb +7 -0
- data/lib/doh/merb/source_ip.rb +10 -0
- data/lib/doh/merb.rb +0 -1
- data/lib/doh/mysql/abstract_row.rb +81 -0
- data/lib/doh/mysql/cache_connector.rb +11 -8
- data/lib/doh/mysql/connector_instance.rb +32 -5
- data/lib/doh/mysql/connector_util.rb +1 -0
- data/lib/doh/mysql/convert.rb +18 -0
- data/lib/doh/mysql/database_creator.rb +18 -5
- data/lib/doh/mysql/db_date.rb +2 -2
- data/lib/doh/mysql/default_type_guesser.rb +21 -4
- data/lib/doh/mysql/error.rb +3 -2
- data/lib/doh/mysql/handle.rb +144 -18
- data/lib/doh/mysql/hash_row.rb +13 -0
- data/lib/doh/mysql/load_sql.rb +1 -0
- data/lib/doh/mysql/metadata_util.rb +60 -19
- data/lib/doh/mysql/migrate.rb +122 -0
- data/lib/doh/mysql/migrate_check.rb +139 -0
- data/lib/doh/mysql/parse.rb +2 -0
- data/lib/doh/mysql/readonly_row.rb +11 -48
- data/lib/doh/mysql/require_dbtypes.rb +8 -0
- data/lib/doh/mysql/smart_row.rb +156 -0
- data/lib/doh/mysql/to_sql.rb +12 -0
- data/lib/doh/mysql/typed_row_builder.rb +4 -3
- data/lib/doh/mysql/types.rb +33 -0
- data/lib/doh/mysql/unquoted.rb +8 -0
- data/lib/doh/mysql/version.rb +102 -0
- data/lib/doh/mysql/virtual.rb +17 -0
- data/lib/doh/mysql/writable_row.rb +58 -0
- data/lib/doh/mysql.rb +2 -1
- data/lib/doh/paypal/paypal.rb +20 -0
- data/lib/doh/paypal/pdt.rb +14 -0
- data/lib/doh/paypal.rb +1 -0
- data/lib/doh/rails/form_helpers.rb +53 -0
- data/lib/doh/rails/login.rb +143 -0
- data/lib/doh/test/error_acceptor.rb +1 -1
- data/lib/doh/test/run_tests.rb +48 -43
- data/lib/doh/test/setup_once.rb +15 -0
- data/lib/doh/test/test_result.rb +7 -0
- data/lib/doh/unit_test.rb +6 -0
- data/lib/doh/util/banking_workday.rb +16 -12
- data/lib/doh/util/class_basename.rb +10 -0
- data/lib/doh/util/current_date.rb +18 -41
- data/lib/doh/util/doh_socket.rb +56 -0
- data/lib/doh/util/email.rb +18 -0
- data/lib/doh/util/file_edit.rb +64 -0
- data/lib/doh/util/http_helper.rb +107 -0
- data/lib/doh/util/internal_ip.rb +1 -1
- data/lib/doh/util/jsval.rb +13 -0
- data/lib/doh/util/post_hash.rb +14 -0
- data/lib/doh/util/xml_util.rb +48 -0
- data/test/core/tc_array.rb +12 -0
- data/test/core/tc_date.rb +53 -0
- data/test/core/tc_deep_dup.rb +69 -0
- data/test/core/tc_hash.rb +28 -0
- data/test/core/tc_socket.rb +30 -0
- data/test/core/tc_string.rb +15 -22
- data/test/local_tests.rb +3 -0
- data/test/local_tests_including_slow.rb +4 -0
- data/test/logger/tc_acceptor.rb +23 -6
- data/test/logger/tc_event.rb +1 -1
- data/test/logger/tc_formatter.rb +3 -2
- data/test/logger/tc_socket_viewer_acceptor.rb +48 -0
- data/test/mysql/001_down.sql +1 -0
- data/test/mysql/001_up.sql +4 -0
- data/test/mysql/002_down.sql +1 -0
- data/test/mysql/002_up.sql +1 -0
- data/test/mysql/tc_connector_instance.rb +8 -8
- data/test/mysql/tc_convert.rb +45 -0
- data/test/mysql/tc_handle.rb +94 -2
- data/test/mysql/tc_metadata_util.rb +50 -0
- data/test/mysql/tc_migrate.rb +50 -0
- data/test/mysql/tc_parse.rb +3 -1
- data/test/mysql/tc_readonly_row.rb +14 -10
- data/test/mysql/tc_smart_row.rb +22 -0
- data/test/mysql/tc_to_sql.rb +20 -0
- data/test/mysql/tc_types.rb +32 -0
- data/test/mysql/tc_unquoted.rb +1 -0
- data/test/mysql/tc_writable_row.rb +22 -0
- data/test/ts_core.rb +4 -0
- data/test/ts_logger.rb +4 -0
- data/test/ts_mysql.rb +6 -0
- data/test/ts_util.rb +6 -0
- data/test/util/slow_doh_socket.rb +102 -0
- data/test/util/tc_banking_workday.rb +18 -0
- data/test/util/tc_file_edit.rb +54 -0
- data/test/util/tc_jsval.rb +12 -0
- data/test/util/tc_to_display.rb +14 -0
- data/test/util/tc_xml_util.rb +17 -0
- metadata +130 -39
- data/README +0 -4
- data/lib/doh/merb/post_hash.rb +0 -26
- data/lib/doh/mysql/db_null.rb +0 -24
- data/lib/doh/mysql/hash_util.rb +0 -56
- data/test/mysql/tc_hash_util.rb +0 -23
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
### right now this works for two cases
|
|
2
|
+
###
|
|
3
|
+
### case 1 is: dohruby/bin/run_tests.rb, list of files in call stack is this:
|
|
4
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/find_dohruby_19.rb
|
|
5
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/find_dohruby.rb
|
|
6
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/find_dohruby.rb
|
|
7
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/options.rb
|
|
8
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/options.rb
|
|
9
|
+
### .../src/dohruby/bin/run_tests.rb
|
|
10
|
+
|
|
11
|
+
## case 2 is:
|
|
12
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/find_dohruby_19.rb
|
|
13
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/find_dohruby.rb
|
|
14
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/find_dohruby.rb
|
|
15
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/init_runnable.rb
|
|
16
|
+
### /usr/local/lib/ruby/gems/1.9.1/gems/dohboot-1/lib/doh/boot/init_runnable.rb
|
|
17
|
+
### /rails/app/path/config/environment.rb
|
|
18
|
+
|
|
19
|
+
module DohBoot
|
|
20
|
+
|
|
21
|
+
current_caller = caller
|
|
22
|
+
seen_doh_boot = false
|
|
23
|
+
# puts "*** starting trace"
|
|
24
|
+
current_caller.each_with_index do |path, index|
|
|
25
|
+
current_caller[index] =~ /^([^:]*):/
|
|
26
|
+
currentfile = $1
|
|
27
|
+
has_doh_boot = false
|
|
28
|
+
if currentfile =~ /doh\/boot/ then
|
|
29
|
+
has_doh_boot = true
|
|
30
|
+
end
|
|
31
|
+
seen_doh_boot ||= has_doh_boot
|
|
32
|
+
# puts currentfile + "; has == #{has_doh_boot}; seen == #{seen_doh_boot}"
|
|
33
|
+
if !has_doh_boot && seen_doh_boot then
|
|
34
|
+
@@start_path = currentfile
|
|
35
|
+
break
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
# puts "*** ending trace"
|
|
39
|
+
|
|
40
|
+
def self.find_dohruby_in_parents(dir, max_tries = 20)
|
|
41
|
+
path = File.expand_path(dir)
|
|
42
|
+
raise "unable to find dohruby" if (path == '/') || (max_tries <= 0)
|
|
43
|
+
|
|
44
|
+
if File.exist?(File.join(path, 'dohruby'))
|
|
45
|
+
return File.join(path, 'dohruby')
|
|
46
|
+
else
|
|
47
|
+
return find_dohruby_in_parents(File.join(path, '..'), max_tries - 1)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
if !$LOAD_PATH.find {|dir| dir =~ /dohruby\/lib/}
|
|
52
|
+
dohruby_path = DohBoot::find_dohruby_in_parents(File.dirname(@@start_path))
|
|
53
|
+
if File.exist?(dohruby_path)
|
|
54
|
+
$LOAD_PATH.push(File.join(dohruby_path, 'lib'))
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
data/lib/doh/core/bigdecimal.rb
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
require 'bigdecimal'
|
|
2
|
+
require 'bigdecimal/util'
|
|
3
|
+
|
|
4
|
+
class Integer
|
|
5
|
+
def to_d
|
|
6
|
+
to_s.to_d
|
|
7
|
+
end
|
|
8
|
+
end
|
|
2
9
|
|
|
3
10
|
class BigDecimal
|
|
4
11
|
alias :_doh_original_to_s :to_s
|
|
@@ -6,6 +13,14 @@ class BigDecimal
|
|
|
6
13
|
_doh_original_to_s(format)
|
|
7
14
|
end
|
|
8
15
|
|
|
16
|
+
def to_d
|
|
17
|
+
self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def inspect
|
|
21
|
+
to_s
|
|
22
|
+
end
|
|
23
|
+
|
|
9
24
|
def to_dig(digits_after_decimal = 2)
|
|
10
25
|
raise ArgumentError.new("digits_after_decimal must be > 0") unless digits_after_decimal > 0
|
|
11
26
|
return '0.' + ('0' * digits_after_decimal) if nan? || infinite?
|
data/lib/doh/core/date.rb
CHANGED
|
@@ -6,6 +6,28 @@ class Date
|
|
|
6
6
|
civil(year, month, -1).mday
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
def self.smart_parse(datestr)
|
|
10
|
+
if datestr =~ /\A(\d\d)\/(\d\d)\/(\d\d)\z/
|
|
11
|
+
month = $1.to_i
|
|
12
|
+
mday = $2.to_i
|
|
13
|
+
year = $3.to_i
|
|
14
|
+
result = Date.new(year, month, mday)
|
|
15
|
+
else
|
|
16
|
+
result = Date.parse(datestr)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
if result.year < 50
|
|
20
|
+
result = Date.new(result.year + 2000, result.month, result.day)
|
|
21
|
+
elsif result.year < 100
|
|
22
|
+
result = Date.new(result.year + 1900, result.month, result.day)
|
|
23
|
+
end
|
|
24
|
+
result
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def inspect
|
|
28
|
+
strftime('%F')
|
|
29
|
+
end
|
|
30
|
+
|
|
9
31
|
def weekday?
|
|
10
32
|
(wday > 0) && (wday < 6)
|
|
11
33
|
end
|
|
@@ -18,10 +40,61 @@ class Date
|
|
|
18
40
|
@@short_days_of_week ||= Time::RFC2822_DAY_NAME.collect {|day| day.downcase}
|
|
19
41
|
@@short_days_of_week.index(weekday.downcase)
|
|
20
42
|
end
|
|
43
|
+
|
|
44
|
+
def years_since(date)
|
|
45
|
+
years_diff = year - date.year
|
|
46
|
+
if month < date.month || (month == date.month && day < date.day)
|
|
47
|
+
years_diff -= 1
|
|
48
|
+
end
|
|
49
|
+
years_diff
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def make_datetime(hour = 0, min = 0, sec = 0)
|
|
53
|
+
DateTime.new(year, month, mday, hour, min, sec)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def add_months(months, new_day = nil)
|
|
57
|
+
total_month = month + months
|
|
58
|
+
new_month = total_month % 12
|
|
59
|
+
new_month = 12 if new_month == 0
|
|
60
|
+
new_year = year + ((total_month - 1) / 12)
|
|
61
|
+
calc_day = [mday, Date.days_in_month(new_year, new_month)].min
|
|
62
|
+
Date.new(new_year, new_month, new_day || calc_day)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def add_years(years)
|
|
66
|
+
new_year = year + years
|
|
67
|
+
calc_day = [mday, Date.days_in_month(new_year, month)].min
|
|
68
|
+
Date.new(new_year, month, calc_day)
|
|
69
|
+
end
|
|
21
70
|
end
|
|
22
71
|
|
|
23
72
|
class DateTime
|
|
73
|
+
SECONDS_IN_DAY = (24 * 60 * 60).freeze
|
|
74
|
+
|
|
75
|
+
def self.zow
|
|
76
|
+
obj = now
|
|
77
|
+
new(obj.year, obj.month, obj.mday, obj.hour, obj.min, obj.sec)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def inspect
|
|
81
|
+
strftime('%F %X')
|
|
82
|
+
end
|
|
83
|
+
|
|
24
84
|
def date_only
|
|
25
85
|
Date.new(year, month, mday)
|
|
26
86
|
end
|
|
87
|
+
|
|
88
|
+
def add_seconds(seconds)
|
|
89
|
+
self + Rational(seconds, SECONDS_IN_DAY)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def sub_seconds(seconds)
|
|
93
|
+
add_seconds(-seconds)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# subtract another DateTime object, return difference in seconds
|
|
97
|
+
def sub_dt(other)
|
|
98
|
+
((self - other) * SECONDS_IN_DAY).to_i
|
|
99
|
+
end
|
|
27
100
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class Class
|
|
2
|
+
def deep_dup(*syms)
|
|
3
|
+
return if syms.empty?
|
|
4
|
+
code = "def initialize_copy(orig); "
|
|
5
|
+
code << "super(orig); "
|
|
6
|
+
syms.each do |elem|
|
|
7
|
+
code << "@#{elem} = @#{elem}.nil? ? nil : @#{elem}.dup; "
|
|
8
|
+
end
|
|
9
|
+
code << "end\n"
|
|
10
|
+
class_eval code
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
def to_h
|
|
3
|
+
self
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def setnew(key, value)
|
|
7
|
+
store(key, value) unless key?(key)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def merge_with_remove(hash)
|
|
11
|
+
self.dup.merge_with_remove!(hash)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#merges the given hash with the current
|
|
15
|
+
#then removes any elements from the merged hash that have
|
|
16
|
+
#a value of nil in the hash argument
|
|
17
|
+
def merge_with_remove!(hash)
|
|
18
|
+
self.merge!(hash).reject! {|elem, value| hash.key?(elem) && hash[elem].nil?}
|
|
19
|
+
self
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'socket'
|
|
2
|
+
|
|
3
|
+
class BasicSocket
|
|
4
|
+
def read_with_amount_header
|
|
5
|
+
lenstr = self.read(8)
|
|
6
|
+
self.read(lenstr.to_i)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def write_with_amount_header(message)
|
|
10
|
+
lenstr = message.size.to_s.ljust(8)
|
|
11
|
+
self.write(lenstr)
|
|
12
|
+
self.write(message)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# it should be noted that in order to use read_object and write_object, the object versions
|
|
16
|
+
# on the client and server side must be identical
|
|
17
|
+
def read_object
|
|
18
|
+
Marshal.load(read_with_amount_header)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def write_object(obj)
|
|
22
|
+
write_with_amount_header(Marshal.dump(obj))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
data/lib/doh/core/string.rb
CHANGED
|
@@ -39,11 +39,41 @@ class String
|
|
|
39
39
|
slice(Range.new(-limit, -1)) || self
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
# replaces with replace_str, or yields (and replaces with the returned value) the values found between each occurance of beginstr and endstr
|
|
43
|
+
# within the string
|
|
44
|
+
# an assumption is made that the string data between 'beginstr' and 'endstr' will not have either delimiter within it
|
|
45
|
+
# if it does, the result is undefined right now
|
|
46
|
+
def gsub_between(beginstr, endstr, replace_str = nil)
|
|
47
|
+
curpos = 0
|
|
48
|
+
result = self.dup
|
|
49
|
+
while true
|
|
50
|
+
begpos = result.index(beginstr, curpos)
|
|
51
|
+
endpos = result.index(endstr, begpos + beginstr.length) if begpos
|
|
52
|
+
if begpos && endpos
|
|
53
|
+
use_str = replace_str
|
|
54
|
+
if !replace_str
|
|
55
|
+
use_str = yield(result[(begpos+beginstr.length)..(endpos-1)])
|
|
56
|
+
end
|
|
57
|
+
result[(begpos+beginstr.length)..(endpos-1)] = use_str
|
|
58
|
+
curpos = begpos + beginstr.length + endstr.length + use_str.length
|
|
59
|
+
else
|
|
60
|
+
break
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
result
|
|
44
64
|
end
|
|
45
65
|
|
|
46
|
-
def
|
|
47
|
-
|
|
66
|
+
def equals_ignore_whitespace(str2)
|
|
67
|
+
self.normalize_all_whitespace == str2.normalize_all_whitespace
|
|
48
68
|
end
|
|
69
|
+
|
|
70
|
+
#this method strips the string, then combines all whitespace > 1 character into a single space
|
|
71
|
+
def normalize_all_whitespace
|
|
72
|
+
result = self.strip.gsub("\n", ' ').gsub("\t", ' ')
|
|
73
|
+
while result =~ /\s\s/
|
|
74
|
+
result = result.gsub(' ', ' ')
|
|
75
|
+
end
|
|
76
|
+
result
|
|
77
|
+
end
|
|
78
|
+
|
|
49
79
|
end
|
data/lib/doh/core.rb
CHANGED
data/lib/doh/data/basic.rb
CHANGED
|
@@ -1,51 +1,56 @@
|
|
|
1
1
|
module DohData
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
#implemented here so random behavior can be overridden by end user
|
|
4
|
+
def random_int(max)
|
|
5
|
+
rand(max)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def random_characters(count, values_string)
|
|
4
9
|
retval = ''
|
|
5
|
-
count.times {retval += values_string.slice(
|
|
10
|
+
count.times {retval += values_string.slice(random_int(values_string.size), 1)}
|
|
6
11
|
retval
|
|
7
12
|
end
|
|
8
13
|
|
|
9
|
-
def
|
|
14
|
+
def random_letters(count)
|
|
10
15
|
random_characters(count, 'abcdefghijklmnopqrstuvwxyz')
|
|
11
16
|
end
|
|
12
17
|
|
|
13
|
-
def
|
|
18
|
+
def random_digits(count)
|
|
14
19
|
random_characters(count, '0123456789')
|
|
15
20
|
end
|
|
16
21
|
|
|
17
|
-
def
|
|
22
|
+
def random_alnum(count)
|
|
18
23
|
random_characters(count, 'abcdefghijklmnopqrstuvwxyz0123456789')
|
|
19
24
|
end
|
|
20
25
|
|
|
21
|
-
def
|
|
22
|
-
(
|
|
26
|
+
def random_range(min, max, multiplier = 1)
|
|
27
|
+
(random_int(max + 1 - min) + min) * multiplier
|
|
23
28
|
end
|
|
24
29
|
|
|
25
|
-
def
|
|
26
|
-
array[
|
|
30
|
+
def random_array_element(array)
|
|
31
|
+
array[random_int(array.size)]
|
|
27
32
|
end
|
|
28
33
|
|
|
29
|
-
def
|
|
34
|
+
def random_element(*args)
|
|
30
35
|
flat = args.flatten
|
|
31
|
-
flat[
|
|
36
|
+
flat[random_int(flat.size)]
|
|
32
37
|
end
|
|
33
38
|
|
|
34
|
-
def
|
|
39
|
+
def random_bool
|
|
35
40
|
random_element(true, false)
|
|
36
41
|
end
|
|
37
42
|
|
|
38
|
-
def
|
|
39
|
-
(
|
|
43
|
+
def random_amount(max, multiplier = 1)
|
|
44
|
+
(random_int(max) + 1) * multiplier
|
|
40
45
|
end
|
|
41
46
|
|
|
42
|
-
def
|
|
43
|
-
|
|
47
|
+
def random_percent(percent)
|
|
48
|
+
random_int(100) < percent
|
|
44
49
|
end
|
|
45
50
|
|
|
46
|
-
def
|
|
47
|
-
diff = max-min
|
|
48
|
-
min +
|
|
51
|
+
def random_date(min, max)
|
|
52
|
+
diff = (max + 1 - min)
|
|
53
|
+
min + random_int(diff)
|
|
49
54
|
end
|
|
50
55
|
|
|
51
56
|
end
|
data/lib/doh/data/bulk.rb
CHANGED
|
@@ -1,114 +1,54 @@
|
|
|
1
1
|
module DohData
|
|
2
2
|
|
|
3
3
|
@@last_names = \
|
|
4
|
-
['smith','johnson','williams','jones','brown','davis','miller','wilson','moore','
|
|
5
|
-
,'martin','thompson','
|
|
4
|
+
['smith','johnson','williams','jones','brown','davis','miller','wilson','moore','anderson','thomas','jackson','white','harris'\
|
|
5
|
+
,'martin','thompson','robinson','clark','lewis','lee','walker','hall','young' \
|
|
6
6
|
,'king','wright','hill','scott','green','adams','baker','nelson','carter','mitchell','roberts','turner' \
|
|
7
7
|
,'phillips','campbell','parker','evans','edwards','collins','stewart','morris','rogers','reed','cook','morgan','bell','murphy' \
|
|
8
|
-
,'bailey','rivera','
|
|
9
|
-
,'price','bennett','wood','barnes','ross','henderson','coleman','jenkins','perry','powell','long','patterson','hughes','
|
|
8
|
+
,'bailey','rivera','richardson','cox','howard','ward','peterson','gray','james','watson','brooks','kelly','sanders' \
|
|
9
|
+
,'price','bennett','wood','barnes','ross','henderson','coleman','jenkins','perry','powell','long','patterson','hughes','washington' \
|
|
10
10
|
,'butler','simmons','foster','bryant','alexander','russell','griffin','hayes','myers','ford','hamilton','graham','sullivan' \
|
|
11
|
-
,'wallace','woods','cole','west','jordan','owens','reynolds','fisher','ellis','harrison','
|
|
11
|
+
,'wallace','woods','cole','west','jordan','owens','reynolds','fisher','ellis','harrison','mcdonald' \
|
|
12
12
|
,'murray','freeman','wells','webb','simpson','stevens','tucker','porter','hunter','hicks','crawford','henry','boyd','mason','morales','kennedy' \
|
|
13
|
-
,'warren','dixon','ramos','
|
|
14
|
-
,'knight','ferguson','rose','stone','hawkins','dunn','perkins','hudson','spencer','gardner','stephens','payne','pierce','berry'
|
|
13
|
+
,'warren','dixon','ramos','burns','gordon','holmes','rice','robertson','hunt','black','daniels','palmer','mills','nichols','grant' \
|
|
14
|
+
,'knight','ferguson','rose','stone','hawkins','dunn','perkins','hudson','spencer','gardner','stephens','payne','pierce','berry' \
|
|
15
15
|
,'arnold','wagner','willis','ray','watkins','olson','carroll','duncan','snyder' \
|
|
16
16
|
]
|
|
17
17
|
|
|
18
|
-
@@first_names
|
|
19
|
-
['james','
|
|
20
|
-
,'
|
|
21
|
-
,'
|
|
22
|
-
,'roger','joe','juan','jack','albert','jonathan','justin','terry','gerald','keith','
|
|
23
|
-
,'bruce','brandon','
|
|
24
|
-
,'
|
|
25
|
-
,'tony','
|
|
26
|
-
,'jeff','chad','jacob','lee','alfred','kyle','francis','bradley','herbert','frederick','ray','
|
|
27
|
-
,'randall','barry','
|
|
28
|
-
,'alex','jon','mary','
|
|
29
|
-
,'
|
|
30
|
-
,'amy','anna','rebecca','virginia','kathleen','pamela','
|
|
31
|
-
,'ann','joyce','diane','alice','julie','heather','teresa','doris','
|
|
18
|
+
@@first_names= \
|
|
19
|
+
['james','thomas','christopher','paul','mark','donald' \
|
|
20
|
+
,'brian','ronald','anthony','kevin','jason','matthew','gary','timothy','larry','jeffrey','frank','scott' \
|
|
21
|
+
,'andrew','raymond','gregory','jerry','dennis','peter','carl','arthur','ryan' \
|
|
22
|
+
,'roger','joe','juan','jack','albert','jonathan','justin','terry','gerald','keith','willie','ralph','lawrence','nicholas' \
|
|
23
|
+
,'bruce','brandon','harry','fred','wayne','steve','louis','jeremy','aaron','howard','eugene','russell','bobby' \
|
|
24
|
+
,'ernest','phillip','todd','jesse','craig','alan','shawn','clarence','sean','philip','chris','earl','jimmy','danny','bryan' \
|
|
25
|
+
,'tony','leonard','nathan','dale','rodney','curtis','norman','allen','marvin','vincent','glenn','jeffery','travis' \
|
|
26
|
+
,'jeff','chad','jacob','lee','alfred','kyle','francis','bradley','herbert','frederick','ray','don','eddie','troy' \
|
|
27
|
+
,'randall','barry','bernard','leroy','marcus','micheal','theodore','clifford','jim','calvin' \
|
|
28
|
+
,'alex','jon','mary','linda','barbara','jennifer','susan','margaret','dorothy','lisa','betty','helen' \
|
|
29
|
+
,'donna','carol','ruth','sharon','michelle','laura','sarah','kimberly','deborah','jessica','shirley','cynthia','angela','melissa','brenda' \
|
|
30
|
+
,'amy','anna','rebecca','virginia','kathleen','pamela','debra','amanda','stephanie','carolyn','christine','marie','janet','catherine','frances' \
|
|
31
|
+
,'ann','joyce','diane','alice','julie','heather','teresa','doris','evelyn','jean','cheryl','mildred','katherine','joan','ashley','judith' \
|
|
32
32
|
,'rose','janice','kelly','nicole','judy','christina','kathy','theresa','beverly','denise','tammy','irene','jane','lori','rachel','marilyn','andrea' \
|
|
33
|
-
,'kathryn','louise','sara','anne','jacqueline','wanda','bonnie','julia','ruby','lois','tina','phyllis','norma','paula','
|
|
34
|
-
,'peggy','crystal','
|
|
35
|
-
,'sherry','sylvia','josephine','thelma','shannon','sheila','ethel','ellen','elaine','marjorie','carrie','charlotte','
|
|
36
|
-
,'
|
|
33
|
+
,'kathryn','louise','sara','anne','jacqueline','wanda','bonnie','julia','ruby','lois','tina','phyllis','norma','paula','annie','lillian','emily','robin' \
|
|
34
|
+
,'peggy','crystal','rita','dawn','connie','florence','tracy','tiffany','carmen','rosa','cindy','wendy','victoria','edith','kim' \
|
|
35
|
+
,'sherry','sylvia','josephine','thelma','shannon','sheila','ethel','ellen','elaine','marjorie','carrie','charlotte','esther','pauline','emma' \
|
|
36
|
+
,'rhonda','hazel','amber','eva','debbie','april','leslie','clara','lucille','joanne','eleanor','valerie','danielle','megan' \
|
|
37
37
|
,'alicia','suzanne','michele','gail','bertha','darlene','veronica','jill','erin','geraldine','lauren','cathy','joann','lorraine','lynn','sally','regina' \
|
|
38
38
|
,'erica','beatrice','dolores','bernice','audrey','yvonne','annette','june','samantha','marion','dana','stacy','ana','renee','ida','vivian','roberta' \
|
|
39
39
|
,'holly','brittany','melanie','loretta','yolanda','jeanette','laurie','katie','kristen','vanessa','alma','sue','elsie','beth','jeanne','vicki','carla' \
|
|
40
|
-
,'tara','rosemary','eileen','terri','gertrude','lucy','tonya'
|
|
40
|
+
,'tara','rosemary','eileen','terri','gertrude','lucy','tonya' \
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
@@ssn_group_order = [1,3,5,7,9,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,2,4,6,8,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99]
|
|
44
44
|
|
|
45
|
-
@@
|
|
46
|
-
[[1,[752,753]] \
|
|
47
|
-
,[3,[588,761,762,763]] \
|
|
48
|
-
,[4,[2,3,222,349,350,351,352,353,354,355,356,357,358,359,360,361]] \
|
|
49
|
-
,[5,[756,757,758,759,760]] \
|
|
50
|
-
,[6,[1,7,221,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348]] \
|
|
51
|
-
,[7,[691,692,693,694,695,696,697,698,699,751]] \
|
|
52
|
-
,[8,[4,5,6,48,49,637,638,639,640,641,642,643,644,645]] \
|
|
53
|
-
,[9,[732,733,750]] \
|
|
54
|
-
,[10,[727,729,730,731]] \
|
|
55
|
-
,[11,[40,41,42,43,44,45,46,47,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,627,628,629,630,631,632,633,634,635,636]] \
|
|
56
|
-
,[12,[678,679,682,683,684,685,686,687,688,689,690]] \
|
|
57
|
-
,[13,[268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285]] \
|
|
58
|
-
,[14,[661,662,663,664,665,676,677,681,728]] \
|
|
59
|
-
,[16,[659,660]] \
|
|
60
|
-
,[17,[144,145,146,147,148,149,150,151,152,153,154,155,156,157,158]] \
|
|
61
|
-
,[18,[700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,725,726]] \
|
|
62
|
-
,[19,[135,136,137,138,139,140,141,142,143]] \
|
|
63
|
-
,[21,[447,448]] \
|
|
64
|
-
,[23,[440,441,442,443,444,445,446,496,497,498,499,500]] \
|
|
65
|
-
,[24,[658]] \
|
|
66
|
-
,[25,[486,487,488,489,490,491,492,493,494,495]] \
|
|
67
|
-
,[26,[654,655,656,657]] \
|
|
68
|
-
,[27,[393,394,395,396,397,398,399,509,510,511,512,513,514,515]] \
|
|
69
|
-
,[28,[724]] \
|
|
70
|
-
,[29,[387,388,389,390,391,392]] \
|
|
71
|
-
,[31,[304,305,306,307,308,309,310,311,312,313,314,315,316,317]] \
|
|
72
|
-
,[32,[674,675]] \
|
|
73
|
-
,[33,[303,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,501,502]] \
|
|
74
|
-
,[34,[667,668,669,670,671,672,673]] \
|
|
75
|
-
,[35,[362,363,364,485]] \
|
|
76
|
-
,[37,[478,479,480,481,482,483,484,580]] \
|
|
77
|
-
,[39,[504]] \
|
|
78
|
-
,[41,[503]] \
|
|
79
|
-
,[43,[517,579]] \
|
|
80
|
-
,[44,[648,649,652,653]] \
|
|
81
|
-
,[45,[516,577,578]] \
|
|
82
|
-
,[46,[650,651]] \
|
|
83
|
-
,[49,[470,471,472,473,474,475,476,477,574]] \
|
|
84
|
-
,[51,[468,469,506,507,508]] \
|
|
85
|
-
,[53,[232,233,234,235,236,505,520]] \
|
|
86
|
-
,[61,[416,417,418,419,420,421,422,423,424,532,533,534,535,536,537,538,539,586]] \
|
|
87
|
-
,[62,[768,769,770,771,772]] \
|
|
88
|
-
,[63,[531,615,616,617,618,619,620,621,622,623,624,625,626]] \
|
|
89
|
-
,[64,[766,767]] \
|
|
90
|
-
,[65,[407,602,603,604,605,606,607,608,609,610,611,612,613,614]] \
|
|
91
|
-
,[67,[400,401,402,403,404,405,406]] \
|
|
92
|
-
,[70,[39]] \
|
|
93
|
-
,[72,[35,36,37,38]] \
|
|
94
|
-
,[73,[540,541,542,543,544]] \
|
|
95
|
-
,[77,[218,219,220,518,519]] \
|
|
96
|
-
,[79,[212,213,214,215,216,217]] \
|
|
97
|
-
,[80,[764,765]] \
|
|
98
|
-
,[82,[180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,599]] \
|
|
99
|
-
,[84,[159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,596,597,598]] \
|
|
100
|
-
,[88,[28,29,30,31,32,33,34]] \
|
|
101
|
-
,[90,[8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,680]] \
|
|
102
|
-
,[94,[114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,647]] \
|
|
103
|
-
,[96,[50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,646]] \
|
|
104
|
-
,[99,[223,224,225,226,227,228,229,230,231,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,408,409,410,411,412,413,414,415,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,521,522,523,524,525,526,527,528,529,530,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,575,576,581,582,583,584,585,587,589,590,591,592,593,594,595,600,601]] \
|
|
105
|
-
]
|
|
45
|
+
@@ssn_area_highgroups = {1=>98,2=>98,3=>98,4=>4,5=>4,6=>4,7=>4,8=>86,9=>86,10=>86,11=>86,12=>86,13=>86,14=>86,15=>86,16=>86,17=>86,18=>86,19=>86,20=>86,21=>86,22=>86,23=>86,24=>86,25=>86,26=>86,27=>86,28=>86,29=>86,30=>86,31=>86,32=>86,33=>86,34=>84,35=>70,36=>70,37=>68,38=>68,39=>68,40=>6,41=>6,42=>6,43=>6,44=>6,45=>6,46=>4,47=>4,48=>4,49=>4,50=>92,51=>92,52=>92,53=>92,54=>92,55=>92,56=>92,57=>92,58=>92,59=>92,60=>92,61=>92,62=>92,63=>92,64=>92,65=>92,66=>92,67=>92,68=>92,69=>92,70=>92,71=>92,72=>92,73=>92,74=>92,75=>92,76=>92,77=>92,78=>92,79=>92,80=>92,81=>92,82=>92,83=>92,84=>92,85=>92,86=>92,87=>92,88=>92,89=>92,90=>92,91=>92,92=>92,93=>92,94=>92,95=>92,96=>92,97=>92,98=>92,99=>92,100=>92,101=>92,102=>92,103=>92,104=>92,105=>92,106=>92,107=>92,108=>92,109=>92,110=>92,111=>92,112=>92,113=>92,114=>92,115=>92,116=>92,117=>92,118=>92,119=>92,120=>92,121=>92,122=>92,123=>92,124=>92,125=>92,126=>92,127=>90,128=>90,129=>90,130=>90,131=>90,132=>90,133=>90,134=>90,135=>13,136=>13,137=>13,138=>13,139=>13,140=>13,141=>13,142=>13,143=>13,144=>13,145=>13,146=>13,147=>11,148=>11,149=>11,150=>11,151=>11,152=>11,153=>11,154=>11,155=>11,156=>11,157=>11,158=>11,159=>82,160=>82,161=>82,162=>82,163=>80,164=>80,165=>80,166=>80,167=>80,168=>80,169=>80,170=>80,171=>80,172=>80,173=>80,174=>80,175=>80,176=>80,177=>80,178=>80,179=>80,180=>80,181=>80,182=>80,183=>80,184=>80,185=>80,186=>80,187=>80,188=>80,189=>80,190=>80,191=>80,192=>80,193=>80,194=>80,195=>80,196=>80,197=>80,198=>80,199=>80,200=>80,201=>80,202=>80,203=>80,204=>80,205=>80,206=>80,207=>80,208=>80,209=>80,210=>80,211=>80,212=>67,213=>67,214=>67,215=>67,216=>67,217=>67,218=>67,219=>67,220=>65,221=>98,222=>96,223=>97,224=>97,225=>97,226=>97,227=>97,228=>97,229=>95,230=>95,231=>95,232=>51,233=>49,234=>49,235=>49,236=>49,237=>99,238=>99,239=>99,240=>99,241=>99,242=>99,243=>99,244=>99,245=>99,246=>99,247=>99,248=>99,249=>99,250=>99,251=>99,252=>99,253=>99,254=>99,255=>99,256=>99,257=>99,258=>99,259=>99,260=>99,261=>99,262=>99,263=>99,264=>99,265=>99,266=>99,267=>99,268=>8,269=>8,270=>8,271=>8,272=>8,273=>8,274=>8,275=>8,276=>8,277=>8,278=>8,279=>8,280=>8,281=>8,282=>8,283=>8,284=>8,285=>8,286=>8,287=>8,288=>8,289=>6,290=>6,291=>6,292=>6,293=>6,294=>6,295=>6,296=>6,297=>6,298=>6,299=>6,300=>6,301=>6,302=>6,303=>27,304=>27,305=>27,306=>27,307=>27,308=>27,309=>27,310=>27,311=>25,312=>25,313=>25,314=>25,315=>25,316=>25,317=>25,318=>2,319=>2,320=>2,321=>2,322=>2,323=>2,324=>2,325=>2,326=>2,327=>2,328=>2,329=>2,330=>2,331=>2,332=>2,333=>2,334=>2,335=>2,336=>2,337=>2,338=>2,339=>2,340=>2,341=>2,342=>2,343=>2,344=>2,345=>2,346=>2,347=>2,348=>2,349=>2,350=>98,351=>98,352=>98,353=>98,354=>98,355=>98,356=>98,357=>98,358=>98,359=>98,360=>98,361=>98,362=>29,363=>29,364=>29,365=>29,366=>29,367=>29,368=>29,369=>29,370=>29,371=>29,372=>29,373=>29,374=>29,375=>29,376=>29,377=>29,378=>29,379=>29,380=>29,381=>27,382=>27,383=>27,384=>27,385=>27,386=>27,387=>25,388=>23,389=>23,390=>23,391=>23,392=>23,393=>23,394=>23,395=>23,396=>23,397=>23,398=>23,399=>23,400=>61,401=>61,402=>61,403=>61,404=>61,405=>59,406=>59,407=>59,408=>97,409=>95,410=>95,411=>95,412=>95,413=>95,414=>95,415=>95,416=>57,417=>55,418=>55,419=>55,420=>55,421=>55,422=>55,423=>55,424=>55,425=>93,426=>93,427=>93,428=>93,429=>99,430=>99,431=>99,432=>99,433=>99,434=>99,435=>99,436=>99,437=>99,438=>99,439=>99,440=>19,441=>19,442=>17,443=>17,444=>17,445=>17,446=>17,447=>17,448=>17,449=>99,450=>99,451=>99,452=>99,453=>99,454=>99,455=>99,456=>99,457=>99,458=>99,459=>99,460=>99,461=>99,462=>99,463=>99,464=>99,465=>99,466=>99,467=>99,468=>43,469=>43,470=>43,471=>43,472=>43,473=>43,474=>43,475=>41,476=>41,477=>41,478=>33,479=>33,480=>33,481=>33,482=>33,483=>33,484=>31,485=>31,486=>21,487=>21,488=>21,489=>21,490=>21,491=>21,492=>19,493=>19,494=>19,495=>19,496=>19,497=>19,498=>19,499=>19,500=>19,501=>29,502=>29,503=>35,504=>35,505=>47,506=>45,507=>45,508=>45,509=>23,510=>23,511=>23,512=>21,513=>21,514=>21,515=>21,516=>39,517=>37,518=>67,519=>67,520=>47,521=>99,522=>99,523=>99,524=>99,525=>99,526=>99,527=>99,528=>99,529=>99,530=>99,531=>53,532=>53,533=>53,534=>53,535=>51,536=>51,537=>51,538=>51,539=>51,540=>65,541=>65,542=>65,543=>65,544=>63,545=>99,546=>99,547=>99,548=>99,549=>99,550=>99,551=>99,552=>99,553=>99,554=>99,555=>99,556=>99,557=>99,558=>99,559=>99,560=>99,561=>99,562=>99,563=>99,564=>99,565=>99,566=>99,567=>99,568=>99,569=>99,570=>99,571=>99,572=>99,573=>99,574=>39,575=>97,576=>97,577=>37,578=>35,579=>35,580=>35,581=>99,582=>99,583=>99,584=>99,585=>99,586=>51,587=>93,589=>99,590=>99,591=>99,592=>99,593=>99,594=>99,595=>99,596=>74,597=>74,598=>72,599=>72,600=>99,601=>99,602=>41,603=>41,604=>41,605=>41,606=>41,607=>41,608=>41,609=>41,610=>41,611=>41,612=>41,613=>41,614=>41,615=>41,616=>41,617=>41,618=>41,619=>41,620=>41,621=>41,622=>39,623=>39,624=>39,625=>39,626=>39,627=>88,628=>88,629=>88,630=>88,631=>88,632=>88,633=>88,634=>88,635=>88,636=>88,637=>88,638=>88,639=>88,640=>88,641=>88,642=>86,643=>86,644=>86,645=>86,646=>72,647=>72,648=>32,649=>30,650=>28,651=>28,652=>28,653=>28,654=>16,655=>16,656=>16,657=>14,658=>14,659=>9,660=>9,661=>7,662=>7,663=>7,664=>7,665=>7,667=>20,668=>20,669=>20,670=>20,671=>20,672=>20,673=>18,674=>18,675=>18,676=>7,677=>5,678=>5,679=>5,680=>52,681=>3,682=>3,683=>3,684=>1,685=>1,686=>1,687=>3,688=>1,689=>1,690=>1,700=>18,701=>18,702=>18,703=>18,704=>18,705=>18,706=>18,707=>18,708=>18,709=>18,710=>18,711=>18,712=>18,713=>18,714=>18,715=>18,716=>18,717=>18,718=>18,719=>18,720=>18,721=>18,722=>18,723=>18,724=>28,725=>18,726=>18,727=>10,728=>14,729=>1,730=>1,731=>1,764=>36,765=>34,766=>24,767=>24,768=>24,769=>24,770=>24,771=>22,772=>22}.freeze
|
|
106
46
|
|
|
107
47
|
@@email_domains = \
|
|
108
48
|
['yahoo', 'gmail', 'aol', 'hotmail', 'gmail', 'inbox', 'juno', 'email', 'fastmail', 'slowmail', 'netmail', 'gmail','xmission','earthlink','secret','blah' \
|
|
109
49
|
,'geekland','techworld','lavaland','moonsarecool','excite','bellsouth','netzero','sbcglobal','netscape','charter','hushmail','comcast','msn','verizon','att' \
|
|
110
50
|
,'peoplepc'
|
|
111
|
-
]
|
|
51
|
+
].freeze
|
|
112
52
|
|
|
113
53
|
@@email_tlds = ['com','net','org','info','biz','tv','us','name','cc','cn','com.cn','net.cn','org.cn','ws']
|
|
114
54
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'doh/util/class_basename'
|
|
2
|
+
|
|
3
|
+
module DohData
|
|
4
|
+
|
|
5
|
+
@@catalog = {'all' => {}}
|
|
6
|
+
def self.catalog
|
|
7
|
+
@@catalog
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.catalog=(key, value)
|
|
11
|
+
@@catalog[key]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.catalog_list(group = nil)
|
|
15
|
+
@@catalog[group || 'all'].values.collect do |klass|
|
|
16
|
+
text = Doh::class_basename(klass)
|
|
17
|
+
if klass.respond_to?('description')
|
|
18
|
+
text += ' - ' + klass.description
|
|
19
|
+
end
|
|
20
|
+
text
|
|
21
|
+
end.sort
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.add_to_catalog(klass, *groups_ary)
|
|
25
|
+
lookup_str = Doh::class_basename(klass).downcase
|
|
26
|
+
raise "can't add class #{klass.inspect} - there's already a class registered with a lookup string of '#{lookup_str}'" if @@catalog['all'].key?(lookup_str)
|
|
27
|
+
@@catalog['all'][lookup_str] = klass
|
|
28
|
+
groups_ary.each do |group|
|
|
29
|
+
@@catalog[group] ||= {}
|
|
30
|
+
@@catalog[group][lookup_str] = klass
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.search_catalog(text)
|
|
35
|
+
@@catalog['all'][text.strip.downcase]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Class
|
|
41
|
+
def dohdata_catalog(*groups_ary)
|
|
42
|
+
DohData::add_to_catalog(self, *groups_ary)
|
|
43
|
+
end
|
|
44
|
+
end
|