imposter 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/imposter.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{imposter}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Robert Hall"]
12
- s.date = %q{2009-12-11}
12
+ s.date = %q{2009-12-21}
13
13
  s.description = %q{Add generator and rake tasks via YAML based imposters for schema level data faking}
14
14
  s.email = %q{robert.hall@itatc.com}
15
15
  s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "lib/imposter/minerals_short.lst",
36
36
  "lib/imposter/noun.rb",
37
37
  "lib/imposter/noun.xx",
38
+ "lib/imposter/phone.rb",
38
39
  "lib/imposter/vegtable.rb",
39
40
  "lib/imposter/verb.rb",
40
41
  "lib/imposter/verb.xx",
data/lib/imposter.rb CHANGED
@@ -3,7 +3,7 @@ require 'faker'
3
3
  require 'fastercsv'
4
4
  require 'pathname'
5
5
  require 'date'
6
- require 'activesupport'
6
+ require 'active_support'
7
7
 
8
8
  require 'imposter/noun'
9
9
  require 'imposter/verb'
@@ -77,4 +77,16 @@ module Imposter
77
77
  length = [0, 75 - text.length].max
78
78
  write "== %s %s" % [text, "=" * length]
79
79
  end
80
+
81
+ def self.numerify(number_string)
82
+ number_string.gsub(/#/) { rand(10).to_s }
83
+ end
84
+
85
+ def self.letterify(letter_string)
86
+ letter_string.gsub(/\?/) { ('a'..'z').to_a.rand }
87
+ end
88
+
89
+ def self.bothify(string)
90
+ self.letterify(self.numerify(string))
91
+ end
80
92
  end
data/lib/imposter/csz.db CHANGED
Binary file
data/lib/imposter/csz.rb CHANGED
@@ -1,18 +1,29 @@
1
1
  require 'rubygems'
2
2
  require 'sqlite3'
3
3
 
4
- @db = SQLite3::Database.new('csz.db')
4
+ $csz_db = SQLite3::Database.new('csz.db')
5
+ $csz_db.results_as_hash = true
6
+ @@total_rows = $csz_db.execute2("select count(*) from us").to_s.to_i
5
7
 
6
- def postal(code=nil)
7
- case code
8
- when nil
9
- cnt = @db.get_first_value("select count(*) from us").to_i # could probably hardcode this since the data is static
10
- # but I didn't really see a speed difference without it
11
- @db.execute2("select * from us")[1+rand(cnt-1)]
12
- else
13
- @db.execute2("select * from us where postal = '" + code + "'")
14
- end
15
8
 
16
- end
9
+ module Imposter
10
+ class CSZ
11
+ class << self
12
+
13
+ def get
14
+ @@csz_get = $csz_db.execute2("select city,state,zip5 from us")[1+rand(@@total_rows-1)]
15
+ end
17
16
 
18
- puts postal
17
+ def zip5
18
+ @@csz_get['zip5']
19
+ end
20
+ def state(zip5=nil)
21
+ @@csz_get['state']
22
+ end
23
+
24
+ def city(zip5=nil)
25
+ @@csz_get['city']
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'imposter'
3
+
4
+ module Imposter
5
+
6
+ class Phone
7
+ class << self
8
+ def number(format=nil)
9
+ if not format.nil? then
10
+ Imposter.numerify(format)
11
+ else
12
+ Imposter.numerify(Formats.rand)
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ Formats = [
19
+ '###-###-####',
20
+ '(###)###-####',
21
+ '1-###-###-####',
22
+ '###.###.####',
23
+ '###-###-####',
24
+ '(###)###-####',
25
+ '1-###-###-####',
26
+ '###.###.####',
27
+ '###-###-#### x###',
28
+ '(###)###-#### x###',
29
+ '1-###-###-#### x###',
30
+ '###.###.#### x###',
31
+ '###-###-#### x####',
32
+ '(###)###-#### x####',
33
+ '1-###-###-#### x####',
34
+ '###.###.#### x####',
35
+ '###-###-#### x#####',
36
+ '(###)###-#### x#####',
37
+ '1-###-###-#### x#####',
38
+ '###.###.#### x#####'
39
+ ]
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imposter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Hall
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-11 00:00:00 -05:00
12
+ date: 2009-12-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -90,6 +90,7 @@ files:
90
90
  - lib/imposter/minerals_short.lst
91
91
  - lib/imposter/noun.rb
92
92
  - lib/imposter/noun.xx
93
+ - lib/imposter/phone.rb
93
94
  - lib/imposter/vegtable.rb
94
95
  - lib/imposter/verb.rb
95
96
  - lib/imposter/verb.xx