namor 0.5.2 → 0.5.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.
@@ -38,6 +38,12 @@ class Namor::Namor
38
38
  final_cleaning(scrub(name, opts))
39
39
  end
40
40
 
41
+ # scrub as above, but as a final stage, convert the result to a single term (no spaces or hyphens between bits)
42
+ def scrub_and_squash(name, opts = {})
43
+ s = scrub(name, opts)
44
+ s && s.gsub(/[- ]/, '')
45
+ end
46
+
41
47
  def demaiden(lastname)
42
48
  return [nil,nil] unless lastname && !lastname.empty?
43
49
  if lastname =~ /\-/
@@ -112,18 +118,13 @@ class Namor::Namor
112
118
  assemble(
113
119
  scrub(hash[:first]),
114
120
  scrub(hash[:middle]),
115
- scrub(hash[:last].upcase),
116
- scrub(demaiden(hash[:last].upcase).last)
121
+ scrub_and_squash(hash[:last].upcase),
122
+ scrub_and_squash(demaiden(hash[:last].upcase).last)
117
123
  )
118
124
  end
119
125
 
120
126
  def extract_from_pieces_with_cluster(hash)
121
- ary = assemble(
122
- scrub(hash[:first]),
123
- scrub(hash[:middle]),
124
- scrub(hash[:last]),
125
- scrub(demaiden(hash[:last]).last)
126
- )
127
+ ary = extract_from_pieces(hash)
127
128
  ary << ary[3].gsub(/\W/, '_')
128
129
  ary << ary[4].gsub(/\W/, '_')
129
130
  end
@@ -1,3 +1,3 @@
1
1
  module Namor
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -89,6 +89,8 @@ describe "name extract" do
89
89
  @namor.extract_from_pieces_with_cluster(:first => 'Susan', :last => 'Smith-Jones').should == ['SUSAN', nil, 'SMITHJONES', 'SMITHJONES,SUSAN', 'JONES,SUSAN', 'SMITHJONES_SUSAN', 'JONES_SUSAN']
90
90
 
91
91
  @namor.extract_from_pieces(:last => 'Smith').should == [nil,nil, 'SMITH', 'SMITH', 'SMITH']
92
+
93
+ @namor.extract_from_pieces(:first => 'Mary', :last => 'Smith Jones').should == ['MARY',nil, 'SMITHJONES', 'SMITHJONES,MARY', 'JONES,MARY']
92
94
  end
93
95
 
94
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: -483833370846785327
111
+ hash: -278780401687876131
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: -483833370846785327
120
+ hash: -278780401687876131
121
121
  requirements: []
122
122
  rubyforge_project:
123
123
  rubygems_version: 1.8.24