dropmire 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Dropmire is a gem for collecting data from scanning a government issued Driver's License, and building a useful Ruby object based on the correct state.
4
4
 
5
+ *Note: Not yet ready for production applications.*
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -27,7 +29,7 @@ gem install dropmire
27
29
  Or add to Gemfile:
28
30
 
29
31
  ```bash
30
- gem 'dropmire'
32
+ gem 'dropmire', '~> 0.1.2'
31
33
  ```
32
34
 
33
35
  Do cool stuff
@@ -126,7 +126,7 @@ module Dropmire
126
126
  str = /=[0-9]*/.match(@text).to_s
127
127
  dob = str[5,8]
128
128
  year = dob[0,4]
129
- month = dob[4,2]
129
+ month = str[3,2]
130
130
  day = dob[6,2]
131
131
  @attrs[:date_of_birth] = "#{year}-#{month}-#{day}"
132
132
  end
@@ -1,3 +1,3 @@
1
1
  module Dropmire
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,55 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropmire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Connor Jacobsen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-10-05 00:00:00.000000000 Z
12
+ date: 2014-10-09 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '1.6'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.6'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - ">="
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  description: A simple way to collect data from US driver's licenses with a card reader.
@@ -59,56 +66,46 @@ executables: []
59
66
  extensions: []
60
67
  extra_rdoc_files: []
61
68
  files:
62
- - ".gitignore"
69
+ - .gitignore
63
70
  - Gemfile
64
71
  - LICENSE.txt
65
72
  - README.md
66
73
  - Rakefile
67
- - config/first_initial.yml
68
- - config/first_name.yml
69
- - config/middle_initial.yml
70
74
  - dropmire.gemspec
71
75
  - lib/dropmire.rb
72
76
  - lib/dropmire/ext/string.rb
73
77
  - lib/dropmire/identity.rb
74
- - lib/dropmire/name_encoder.rb
75
78
  - lib/dropmire/parser.rb
76
- - lib/dropmire/soundex.rb
77
79
  - lib/dropmire/version.rb
78
- - spec/demo.txt
79
80
  - spec/identity_spec.rb
80
- - spec/name_encoder_spec.rb
81
81
  - spec/parser_spec.rb
82
- - spec/soundex_spec.rb
83
82
  - spec/spec_helper.rb
84
83
  homepage: https://github.com/connorjacobsen/dropmire
85
84
  licenses:
86
85
  - Apache-2.0
87
- metadata: {}
88
86
  post_install_message:
89
87
  rdoc_options: []
90
88
  require_paths:
91
89
  - lib
92
90
  required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
93
92
  requirements:
94
- - - ">="
93
+ - - ! '>='
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
98
  requirements:
99
- - - ">="
99
+ - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.1.11
104
+ rubygems_version: 1.8.23
105
105
  signing_key:
106
- specification_version: 4
106
+ specification_version: 3
107
107
  summary: A simple way to collect data from US driver's licenses.
108
108
  test_files:
109
- - spec/demo.txt
110
109
  - spec/identity_spec.rb
111
- - spec/name_encoder_spec.rb
112
110
  - spec/parser_spec.rb
113
- - spec/soundex_spec.rb
114
111
  - spec/spec_helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 00aff84a94e0b3f608c8c246865fb43c2f1a6ace
4
- data.tar.gz: 2b7661d1934070955617c298abc748296e9025c7
5
- SHA512:
6
- metadata.gz: 29a80db72e40d488c6f3e0609b70af54251cf0a242f9754e4d617c79bc909c3c9985dd15c097836e8e1d78bd50a882cbb576cb9d3da009e5ec7780d366c8d53e
7
- data.tar.gz: dc30a3663d0f6ca55e97b8290ce73f3a202686f5ef4228f94ee2dd95f0eac09f72cf9a9ab90788bf1d9951499740eaf72f5af98dec3efddc31821562a82d5d46
@@ -1,26 +0,0 @@
1
- A: 0
2
- B: 60
3
- C: 100
4
- D: 160
5
- E: 200
6
- F: 240
7
- G: 280
8
- H: 320
9
- I: 400
10
- J: 420
11
- K: 500
12
- L: 520
13
- M: 540
14
- N: 620
15
- O: 640
16
- P: 660
17
- Q: 700
18
- R: 720
19
- S: 780
20
- T: 800
21
- U: 840
22
- V: 860
23
- W: 880
24
- X: 940
25
- Y: 960
26
- Z: 980
@@ -1,53 +0,0 @@
1
- albert: 20
2
- alice: 20
3
- ann: 40
4
- anna: 40
5
- annie: 40
6
- arthur: 40
7
- bernard: 80
8
- bette: 80
9
- bettie: 80
10
- betty: 80
11
- carl: 120
12
- catherine: 120
13
- charles: 140
14
- dorthy: 180
15
- edward: 220
16
- elizabeth: 220
17
- florence: 260
18
- donald: 180
19
- clara: 140
20
- frank: 260
21
- george: 300
22
- grace: 300
23
- harold: 340
24
- harriet: 340
25
- harry: 360
26
- hazel: 360
27
- helen: 380
28
- henry: 380
29
- james: 440
30
- jane: 440
31
- jayne: 440
32
- jean: 460
33
- joan: 480
34
- john: 460
35
- joseph: 480
36
- margaret: 560
37
- martin: 560
38
- marvin: 580
39
- mary: 580
40
- melvin: 600
41
- mildred: 600
42
- patricia: 680
43
- paul: 680
44
- richard: 740
45
- robert: 760
46
- ruby: 740
47
- ruth: 760
48
- thelma: 820
49
- thomas: 820
50
- walter: 900
51
- wanda: 900
52
- william: 920
53
- wilma: 920
@@ -1,26 +0,0 @@
1
- A: 1
2
- B: 2
3
- C: 3
4
- D: 4
5
- E: 5
6
- F: 6
7
- G: 7
8
- H: 8
9
- I: 9
10
- J: 10
11
- K: 11
12
- L: 12
13
- M: 13
14
- N: 14
15
- O: 14
16
- P: 15
17
- Q: 15
18
- R: 16
19
- S: 17
20
- T: 18
21
- U: 18
22
- V: 18
23
- W: 19
24
- X: 19
25
- Y: 19
26
- Z: 19
@@ -1,104 +0,0 @@
1
- require 'yaml'
2
-
3
- module Dropmire
4
- module NameEncoder
5
-
6
- class << self
7
- # :first and :middle are the first and middle names to encode.
8
- def encode(first, middle)
9
- raise "Cannot encode nil name" if first.nil? || middle.nil?
10
-
11
- fcode = generate_fcode(first.downcase)
12
- mcode = find(:middle_initials, initial(middle).upcase)
13
-
14
- "%3d" % (fcode + mcode)
15
- end
16
-
17
- def generate_fcode(name)
18
- val = find(:first_names, name.downcase)
19
-
20
- if val.nil?
21
- val = find(:first_initials, initial(name).upcase)
22
- end
23
-
24
- val
25
- end
26
-
27
- # get the corresponding initial for a given :name.
28
- def initial(name)
29
- return nil if name.nil?
30
- name[0].downcase
31
- end
32
-
33
- def load(filename)
34
- load_yaml_from(filename)
35
- end
36
-
37
- def first_names
38
- @first_names ||= load_first_names
39
- end
40
-
41
- def first_initials
42
- @first_initials ||= load_first_initials
43
- end
44
-
45
- def middle_initials
46
- @middle_initials ||= load_middle_initials
47
- end
48
-
49
- # searches the desired Hash (chosen by :method) for the :key
50
- def find(method, key)
51
- if allowed_find_methods.include? method
52
- self.send(method).fetch(key, nil)
53
- else
54
- raise "Illegal find method!"
55
- end
56
- end
57
-
58
- private
59
-
60
- def allowed_find_methods
61
- [ :first_names, :first_initials, :middle_initials ]
62
- end
63
-
64
- def load_first_names
65
- @first_names = load(first_name_yaml)
66
- end
67
-
68
- def load_first_initials
69
- @first_initials = load(first_initial_yaml)
70
- end
71
-
72
- def load_middle_initials
73
- @middle_initials = load(middle_initial_yaml)
74
- end
75
-
76
- def load_yaml_from(filename)
77
- parsed = begin
78
- YAML.load(File.open(filename))
79
- rescue ArgumentError => e
80
- puts "Could not parse YAML: #{e.message}"
81
- end
82
- end
83
-
84
- # YAML file name helpers #
85
-
86
- def yaml_dir
87
- 'config/'
88
- end
89
-
90
- def first_name_yaml
91
- yaml_dir + 'first_name.yml'
92
- end
93
-
94
- def first_initial_yaml
95
- yaml_dir + 'first_initial.yml'
96
- end
97
-
98
- def middle_initial_yaml
99
- yaml_dir + 'middle_initial.yml'
100
- end
101
- end
102
-
103
- end
104
- end
@@ -1,66 +0,0 @@
1
- # Implementation of the Soundex phonetic algorithm for indexing names
2
- # by sound, as pronounced in English.
3
- module Dropmire
4
- module Soundex
5
-
6
- class << self
7
-
8
- def soundex(str_or_arr)
9
- case str_or_arr
10
- when String
11
- build_code_for(str_or_arr)
12
- when Array
13
- str_or_arr.collect { |str| build_code_for(str) }
14
- else
15
- nil
16
- end
17
- end
18
-
19
- def build_code_for(str)
20
- str = str.upcase.gsub(/[^A-Z]/, '')
21
- return nil if str.empty?
22
-
23
- soundex_code = str[0]
24
- last_code = get_code str[0]
25
-
26
- len = str.length
27
- str[0..len].chars.each_index do |index|
28
- return soundex_code if soundex_code.length == 4
29
-
30
- code = get_code str[index]
31
- if code == '0'
32
- unless %w(W H).include? str[index]
33
- last_code = nil
34
- end
35
- elsif code != last_code
36
- soundex_code += code
37
- last_code = code
38
- end
39
- end
40
-
41
- return soundex_code.ljust(4, '0')
42
- end
43
-
44
- def get_code(char)
45
- case char
46
- when 'B', 'F', 'P', 'V'
47
- '1'
48
- when 'C', 'G', 'J', 'K', 'Q', 'S', 'X', 'Z'
49
- '2'
50
- when 'D', 'T'
51
- '3'
52
- when 'L'
53
- '4'
54
- when 'M', 'N'
55
- '5'
56
- when 'R'
57
- '6'
58
- else
59
- '0'
60
- end
61
- end
62
-
63
- end
64
-
65
- end
66
- end
data/spec/demo.txt DELETED
@@ -1,3 +0,0 @@
1
- %FLTALLAHASSEE^JACOBSEN$CONNOR$ALAN^6357 SINKOLA DR^ ?;6360101021210193207=1506199306070=?+! 323124522 E 1602 ECCECC00000?
2
-
3
- %CAENCINITAS^MEIER$ALAIN$PIERRE^2814 CRYSTAL RIDGE RD^?;636014064752956=190819930823?+!!92024 M602162BRNBRN I67620131125 [,/,_29’;2!?
@@ -1,168 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dropmire::NameEncoder do
4
-
5
- subject { Dropmire::NameEncoder }
6
-
7
- describe "#encode" do
8
- context "William Andrew Fakename" do
9
- it "returns correct value" do
10
- expect(subject.encode("William", "Andrew")).to eql "921"
11
- end
12
- end
13
-
14
- context "Connor Alan Jacobsen" do
15
- it "returns correct value" do
16
- expect(subject.encode("Connor", "Alan")).to eql "101"
17
- end
18
- end
19
- end
20
-
21
- describe "#generate_fcode" do
22
- context "first name NotFound" do
23
- it "uses first initial" do
24
- expect(subject.generate_fcode("Connor")).to eql 100
25
- end
26
- end
27
-
28
- context "first name found" do
29
- it "returns correct value" do
30
- expect(subject.generate_fcode("Alice")).to eql 20
31
- end
32
- end
33
- end
34
-
35
- describe "#initial" do
36
- context "when not nil" do
37
- it "returns a single char" do
38
- expect(subject.initial('Connor').size).to eql 1
39
- end
40
-
41
- it "returns the correct char" do
42
- expect(subject.initial('Connor')).to eql 'c'
43
- end
44
- end
45
-
46
- context "when nil" do
47
- it "returns nil" do
48
- expect(subject.initial(nil)).to eql nil
49
- end
50
- end
51
- end
52
-
53
- describe "#first_names" do
54
- it "has class Hash" do
55
- expect(subject.first_names.class).to eql Hash
56
- end
57
-
58
- it "is not empty" do
59
- expect(subject.first_names.empty?).to eql false
60
- end
61
-
62
- describe "sanity check" do
63
- context "alice" do
64
- it "returns 20" do
65
- expect(subject.first_names["alice"]).to eql 20
66
- end
67
- end
68
-
69
- context "donald" do
70
- it "returns 180" do
71
- expect(subject.first_names["donald"]).to eql 180
72
- end
73
- end
74
- end
75
- end
76
-
77
- describe "#first_initials" do
78
- it "has class Hash" do
79
- expect(subject.first_initials.class).to eql Hash
80
- end
81
-
82
- it "is not empty" do
83
- expect(subject.first_initials.empty?).to eql false
84
- end
85
-
86
- describe "sanity check" do
87
- context "C" do
88
- it "returns 100" do
89
- expect(subject.first_initials["C"]).to eql 100
90
- end
91
- end
92
-
93
- context "J" do
94
- it "returns 420" do
95
- expect(subject.first_initials["J"]).to eql 420
96
- end
97
- end
98
- end
99
- end
100
-
101
- describe "#middle_initials" do
102
- it "has class Hash" do
103
- expect(subject.middle_initials.class).to eql Hash
104
- end
105
-
106
- it "is not empty" do
107
- expect(subject.middle_initials.empty?).to eql false
108
- end
109
-
110
- describe "sanity check" do
111
- context "C" do
112
- it "returns 3" do
113
- expect(subject.middle_initials["C"]).to eql 3
114
- end
115
- end
116
-
117
- context "J" do
118
- it "returns 10" do
119
- expect(subject.middle_initials["J"]).to eql 10
120
- end
121
- end
122
- end
123
- end
124
-
125
- describe "#find" do
126
- context "first_names" do
127
- context "when in YAML" do
128
- it "returns correct value" do
129
- expect(subject.find(:first_names, "donald")).to eql 180
130
- end
131
- end
132
-
133
- context "when not in YAML" do
134
- it "returns nil" do
135
- expect(subject.find(:first_names, "connor")).to eql nil
136
- end
137
- end
138
- end
139
-
140
- context "first_initials" do
141
- context "when in YAML" do
142
- it "returns correct value" do
143
- expect(subject.find(:first_initials, "A")).to eql 0
144
- end
145
- end
146
-
147
- context "when not in YAML" do
148
- it "returns nil" do
149
- expect(subject.find(:first_initials, "AB")).to eql nil
150
- end
151
- end
152
- end
153
-
154
- context "middle_initials" do
155
- context "when in YAML" do
156
- it "returns correct value" do
157
- expect(subject.find(:middle_initials, "A")).to eql 1
158
- end
159
- end
160
-
161
- context "when not in YAML" do
162
- it "returns nil" do
163
- expect(subject.find(:middle_initials, "AB")).to eql nil
164
- end
165
- end
166
- end
167
- end
168
- end
data/spec/soundex_spec.rb DELETED
@@ -1,188 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dropmire::Soundex do
4
- describe "#soundex" do
5
- context "String" do
6
- context "Robert" do
7
- it "returns R163" do
8
- expect(Dropmire::Soundex.soundex("Robert")).to eql 'R163'
9
- end
10
- end
11
-
12
- context "Rupert" do
13
- it "returns R163" do
14
- expect(Dropmire::Soundex.soundex("Rupert")).to eql 'R163'
15
- end
16
- end
17
-
18
- context "Rubin" do
19
- it "returns R150" do
20
- expect(Dropmire::Soundex.soundex("Rubin")).to eql 'R150'
21
- end
22
- end
23
-
24
- context "Ashcraft" do
25
- it "returns A261" do
26
- expect(Dropmire::Soundex.soundex("Ashcraft")).to eql 'A261'
27
- end
28
- end
29
-
30
- context "Ashcroft" do
31
- it "returns A261" do
32
- expect(Dropmire::Soundex.soundex("Ashcroft")).to eql 'A261'
33
- end
34
- end
35
-
36
- context "Tymczak" do
37
- it "returns T522" do
38
- expect(Dropmire::Soundex.soundex("Tymczak")).to eql 'T522'
39
- end
40
- end
41
-
42
- context "Pfister" do
43
- it "returns P236" do
44
- expect(Dropmire::Soundex.soundex("Pfister")).to eql 'P236'
45
- end
46
- end
47
- end
48
-
49
- context "Array" do
50
- it "returns an Array of Soundexs" do
51
- name_ary = %w(Robert Rupin Ashcroft Pfister)
52
- answers = %w(R163 R150 A261 P236)
53
-
54
- expect(Dropmire::Soundex.soundex(name_ary)).to eql answers
55
- end
56
- end
57
- end
58
-
59
- describe "#build_code_for" do
60
- context "Robert" do
61
- it "returns R163" do
62
- expect(Dropmire::Soundex.build_code_for("Robert")).to eql 'R163'
63
- end
64
- end
65
-
66
- context "Rupert" do
67
- it "returns R163" do
68
- expect(Dropmire::Soundex.build_code_for("Rupert")).to eql 'R163'
69
- end
70
- end
71
-
72
- context "Rubin" do
73
- it "returns R150" do
74
- expect(Dropmire::Soundex.build_code_for("Rubin")).to eql 'R150'
75
- end
76
- end
77
-
78
- context "Ashcraft" do
79
- it "returns A261" do
80
- expect(Dropmire::Soundex.build_code_for("Ashcraft")).to eql 'A261'
81
- end
82
- end
83
-
84
- context "Ashcroft" do
85
- it "returns A261" do
86
- expect(Dropmire::Soundex.build_code_for("Ashcroft")).to eql 'A261'
87
- end
88
- end
89
-
90
- context "Tymczak" do
91
- it "returns T522" do
92
- expect(Dropmire::Soundex.build_code_for("Tymczak")).to eql 'T522'
93
- end
94
- end
95
-
96
- context "Pfister" do
97
- it "returns P236" do
98
- expect(Dropmire::Soundex.build_code_for("Pfister")).to eql 'P236'
99
- end
100
- end
101
- end
102
-
103
- describe "#get code" do
104
- context "when code is 1" do
105
- it "B" do
106
- expect(Dropmire::Soundex.get_code('B')).to eql '1'
107
- end
108
-
109
- it "F" do
110
- expect(Dropmire::Soundex.get_code('F')).to eql '1'
111
- end
112
-
113
- it "P" do
114
- expect(Dropmire::Soundex.get_code('P')).to eql '1'
115
- end
116
-
117
- it "V" do
118
- expect(Dropmire::Soundex.get_code('V')).to eql '1'
119
- end
120
- end
121
-
122
- context "when code is 2" do
123
- it "C" do
124
- expect(Dropmire::Soundex.get_code('C')).to eql '2'
125
- end
126
-
127
- it "G" do
128
- expect(Dropmire::Soundex.get_code('G')).to eql '2'
129
- end
130
-
131
- it "J" do
132
- expect(Dropmire::Soundex.get_code('J')).to eql '2'
133
- end
134
-
135
- it "K" do
136
- expect(Dropmire::Soundex.get_code('K')).to eql '2'
137
- end
138
-
139
- it "Q" do
140
- expect(Dropmire::Soundex.get_code('Q')).to eql '2'
141
- end
142
-
143
- it "S" do
144
- expect(Dropmire::Soundex.get_code('S')).to eql '2'
145
- end
146
-
147
- it "X" do
148
- expect(Dropmire::Soundex.get_code('X')).to eql '2'
149
- end
150
-
151
- it "Z" do
152
- expect(Dropmire::Soundex.get_code('Z')).to eql '2'
153
- end
154
- end
155
-
156
- context "when code is 3" do
157
- it "D" do
158
- expect(Dropmire::Soundex.get_code('D')).to eql '3'
159
- end
160
-
161
- it "T" do
162
- expect(Dropmire::Soundex.get_code('T')).to eql '3'
163
- end
164
- end
165
-
166
- context "when code is 4" do
167
- it "L" do
168
- expect(Dropmire::Soundex.get_code('L')).to eql '4'
169
- end
170
- end
171
-
172
- context "when code is 5" do
173
- it "M" do
174
- expect(Dropmire::Soundex.get_code('M')).to eql '5'
175
- end
176
-
177
- it "N" do
178
- expect(Dropmire::Soundex.get_code('N')).to eql '5'
179
- end
180
- end
181
-
182
- context "when code is 6" do
183
- it "R" do
184
- expect(Dropmire::Soundex.get_code('R')).to eql '6'
185
- end
186
- end
187
- end
188
- end