bougyman-name_parse 0.0.3 → 0.0.4
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/AUTHORS +1 -1
- data/CHANGELOG +8 -0
- data/Rakefile +1 -1
- data/lib/name_parse/parser.rb +11 -3
- data/lib/name_parse/version.rb +1 -1
- data/name_parse.gemspec +1 -1
- metadata +1 -1
data/AUTHORS
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
[5d85b44 | Thu May 07 03:14:31 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
2
|
+
|
3
|
+
* methodized when match target for first_name. TODO: make the other when matchers follow the same format
|
4
|
+
|
5
|
+
[09dee2a | Wed May 06 21:05:00 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
6
|
+
|
7
|
+
* Version 0.0.3
|
8
|
+
|
1
9
|
[9481b20 | Wed May 06 21:04:11 UTC 2009] Jayson Vaughn (thedonvaughn) <jayson.vaughn@gmail.com>
|
2
10
|
|
3
11
|
* added bacon task back from FSR, added Bacon.summary_on_exit to spec/helper.rb
|
data/Rakefile
CHANGED
@@ -31,7 +31,7 @@ GEMSPEC = Gem::Specification.new{|s|
|
|
31
31
|
s.email = 'bougy.man@gmail.com'
|
32
32
|
s.homepage = 'http://github.com/bougyman/name_parse'
|
33
33
|
s.platform = Gem::Platform::RUBY
|
34
|
-
s.version = (ENV['PROJECT_VERSION'] ||
|
34
|
+
s.version = (ENV['PROJECT_VERSION'] || Object.const_get(PROJECT_MODULE)::VERSION)
|
35
35
|
s.files = `git ls-files`.split("\n").sort.reject { |f| IGNORE_FILES.detect { |exp| f.match(exp) } }
|
36
36
|
s.has_rdoc = true
|
37
37
|
s.require_path = 'lib'
|
data/lib/name_parse/parser.rb
CHANGED
@@ -14,6 +14,15 @@ module NameParse
|
|
14
14
|
def first_name_re
|
15
15
|
/\w[-.'\w]+/
|
16
16
|
end
|
17
|
+
|
18
|
+
def first_last(match = nil)
|
19
|
+
if match.nil?
|
20
|
+
/^(#{first_name_re})\s+(#{last_name_re})$/
|
21
|
+
else
|
22
|
+
@matched = :first_last
|
23
|
+
@first, @last = match.to_a[1 .. 2]
|
24
|
+
end
|
25
|
+
end
|
17
26
|
|
18
27
|
def last_name_re
|
19
28
|
/(?:(?:v[ao]n(?:\s+der?)?|de\s+la)\s+)?\w[-.'\w]+/i
|
@@ -31,9 +40,8 @@ module NameParse
|
|
31
40
|
def parse(name)
|
32
41
|
case name
|
33
42
|
# just "Firstname Lastname"
|
34
|
-
when
|
35
|
-
|
36
|
-
@matched = :first_last
|
43
|
+
when first_last
|
44
|
+
first_last($~)
|
37
45
|
# Catch names with prefixes, no comma
|
38
46
|
when /^(#{prefix_re})\s+(#{first_name_re})\s+(#{last_name_re})$/
|
39
47
|
@prefix, @first, @last = $1, $2, $3
|
data/lib/name_parse/version.rb
CHANGED
data/name_parse.gemspec
CHANGED