namae 0.8.3 → 0.8.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.
- checksums.yaml +4 -4
- data/lib/namae/name.rb +54 -45
- data/lib/namae/version.rb +1 -1
- data/namae.gemspec +4 -4
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24ebdab9dcba1587795fd5a50f17f76024e7260e
|
4
|
+
data.tar.gz: e9782ac717a00aa60aa4d752413fa1aecfbd9c49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10711cdb7d8a966ef4ee07d048ff8243947942ca8b7c9e7d763ab6d6a8fcd5580f25b89b3ec0275d2387a36664d13028779afd83630c571d91bf35f54338a3cf
|
7
|
+
data.tar.gz: e9723eaf26f61219868c8f28ea155d8f036fb68fb017cf0d454e69af82dba96a99d3886365f6b342f67133263415451bafcdd555051514e43353b0f8fb860592
|
data/lib/namae/name.rb
CHANGED
@@ -1,5 +1,56 @@
|
|
1
1
|
module Namae
|
2
2
|
|
3
|
+
# NameFormatting can be mixed in by an object providing individual
|
4
|
+
# name parts (family, given, suffix, particle, etc.) to add support
|
5
|
+
# for name formatting.
|
6
|
+
module NameFormatting
|
7
|
+
|
8
|
+
# @return [String] the name in sort order
|
9
|
+
def sort_order(delimiter = ', ')
|
10
|
+
[family_part, given_part].reject(&:empty?).join(delimiter)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] the name in display order
|
14
|
+
def display_order
|
15
|
+
[given_part, family_part].reject(&:empty?).join(' ')
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param options [Hash] the options to create the initials
|
19
|
+
#
|
20
|
+
# @option options [true,false] :expand (false) whether or not to expand the family name
|
21
|
+
# @option options [true,false] :dots (true) whether or not to print dots between the initials
|
22
|
+
# @option options [true,false] :spaces (false) whether or not to print spaces between the initals
|
23
|
+
#
|
24
|
+
# @return [String] the name's initials.
|
25
|
+
def initials(options = {})
|
26
|
+
options = Name.defaults[:initials].merge(options)
|
27
|
+
|
28
|
+
if options[:expand]
|
29
|
+
[initials_of(given_part, options), family].compact.join(' ')
|
30
|
+
else
|
31
|
+
initials_of([given_part, family_part].join(' '), options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def family_part
|
38
|
+
[particle, family].compact.join(' ')
|
39
|
+
end
|
40
|
+
|
41
|
+
def given_part
|
42
|
+
[given, dropping_particle].compact.join(' ')
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param name [String] a name or part of a name
|
46
|
+
# @return [String] the initials of the passed-in name
|
47
|
+
def initials_of(name, options = {})
|
48
|
+
i = name.gsub(/([[:upper:]])[[:lower:]]+/, options[:dots] ? '\1.' : '\1')
|
49
|
+
i.gsub!(/\s+/, '') unless options[:spaces]
|
50
|
+
i
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
3
54
|
# A Name represents a single personal name, exposing its constituent
|
4
55
|
# parts (e.g., family name, given name etc.). Name instances are typically
|
5
56
|
# created and returned from {Namae.parse Namae.parse}.
|
@@ -13,7 +64,9 @@ module Namae
|
|
13
64
|
class Name < Struct.new :family, :given, :suffix, :particle,
|
14
65
|
:dropping_particle, :nick, :appellation, :title
|
15
66
|
|
16
|
-
|
67
|
+
include NameFormatting
|
68
|
+
|
69
|
+
# RBX compatibility
|
17
70
|
@parts = members.map(&:to_sym).freeze
|
18
71
|
|
19
72
|
@defaults = {
|
@@ -64,16 +117,6 @@ module Namae
|
|
64
117
|
end
|
65
118
|
end
|
66
119
|
|
67
|
-
# @return [String] the name in sort order
|
68
|
-
def sort_order(delimiter = ', ')
|
69
|
-
[family_part, given_part].reject(&:empty?).join(delimiter)
|
70
|
-
end
|
71
|
-
|
72
|
-
# @return [String] the name in display order
|
73
|
-
def display_order
|
74
|
-
[given_part, family_part].reject(&:empty?).join(' ')
|
75
|
-
end
|
76
|
-
|
77
120
|
# @return [Boolean] whether or not all the name components are nil.
|
78
121
|
def empty?
|
79
122
|
values.compact.empty?
|
@@ -95,22 +138,6 @@ module Namae
|
|
95
138
|
self
|
96
139
|
end
|
97
140
|
|
98
|
-
# @param options [Hash] the options to create the initials
|
99
|
-
#
|
100
|
-
# @option options [true,false] :expand (false) whether or not to expand the family name
|
101
|
-
# @option options [true,false] :dots (true) whether or not to print dots between the initials
|
102
|
-
# @option options [true,false] :spaces (false) whether or not to print spaces between the initals
|
103
|
-
#
|
104
|
-
# @return [String] the name's initials.
|
105
|
-
def initials(options = {})
|
106
|
-
options = Name.defaults[:initials].merge(options)
|
107
|
-
|
108
|
-
if options[:expand]
|
109
|
-
[initials_of(given_part, options), family].compact.join(' ')
|
110
|
-
else
|
111
|
-
initials_of([given_part, family_part].join(' '), options)
|
112
|
-
end
|
113
|
-
end
|
114
141
|
|
115
142
|
# @overload values_at(selector, ... )
|
116
143
|
# Returns an array containing the elements in self corresponding to
|
@@ -135,23 +162,5 @@ module Namae
|
|
135
162
|
|
136
163
|
alias to_s display_order
|
137
164
|
|
138
|
-
private
|
139
|
-
|
140
|
-
def family_part
|
141
|
-
[particle, family].compact.join(' ')
|
142
|
-
end
|
143
|
-
|
144
|
-
def given_part
|
145
|
-
[given, dropping_particle].compact.join(' ')
|
146
|
-
end
|
147
|
-
|
148
|
-
# @param name [String] a name or part of a name
|
149
|
-
# @return [String] the initials of the passed-in name
|
150
|
-
def initials_of(name, options = {})
|
151
|
-
i = name.gsub(/([[:upper:]])[[:lower:]]+/, options[:dots] ? '\1.' : '\1')
|
152
|
-
i.gsub!(/\s+/, '') unless options[:spaces]
|
153
|
-
i
|
154
|
-
end
|
155
|
-
|
156
165
|
end
|
157
166
|
end
|
data/lib/namae/version.rb
CHANGED
data/namae.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: namae 0.8.
|
5
|
+
# stub: namae 0.8.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "namae"
|
9
|
-
s.version = "0.8.
|
9
|
+
s.version = "0.8.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Sylvester Keil", "Dan Collis-Puro"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-03-17"
|
15
15
|
s.description = " Namae (\u{540d}\u{524d}) is a parser for human names. It recognizes personal names of various cultural backgrounds and tries to split them into their component parts (e.g., given and family names, honorifics etc.). "
|
16
16
|
s.email = ["sylvester@keil.or.at", "dan@collispuro.com"]
|
17
17
|
s.extra_rdoc_files = [
|
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
]
|
52
52
|
s.homepage = "https://github.com/berkmancenter/namae"
|
53
53
|
s.licenses = ["AGPL"]
|
54
|
-
s.rubygems_version = "2.2.
|
54
|
+
s.rubygems_version = "2.2.2"
|
55
55
|
s.summary = "Namae (\u{540d}\u{524d}) parses personal names and splits them into their component parts."
|
56
56
|
|
57
57
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
@@ -9,48 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: simplecov
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0.8'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0.8'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rubinius-coverage
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: coveralls
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0.7'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0.7'
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -67,9 +67,9 @@ dependencies:
|
|
67
67
|
- - '='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 1.4.9
|
70
|
-
description:
|
70
|
+
description: ' Namae (名前) is a parser for human names. It recognizes personal names
|
71
71
|
of various cultural backgrounds and tries to split them into their component parts
|
72
|
-
(e.g., given and family names, honorifics etc.).
|
72
|
+
(e.g., given and family names, honorifics etc.). '
|
73
73
|
email:
|
74
74
|
- sylvester@keil.or.at
|
75
75
|
- dan@collispuro.com
|
@@ -78,13 +78,13 @@ extensions: []
|
|
78
78
|
extra_rdoc_files:
|
79
79
|
- README.md
|
80
80
|
files:
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
81
|
+
- .autotest
|
82
|
+
- .coveralls.yml
|
83
|
+
- .document
|
84
|
+
- .rspec
|
85
|
+
- .simplecov
|
86
|
+
- .travis.yml
|
87
|
+
- .yardopts
|
88
88
|
- AGPL
|
89
89
|
- BSDL
|
90
90
|
- Gemfile
|
@@ -118,17 +118,17 @@ require_paths:
|
|
118
118
|
- lib
|
119
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- -
|
121
|
+
- - '>='
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
|
-
- -
|
126
|
+
- - '>='
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.2.
|
131
|
+
rubygems_version: 2.2.2
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Namae (名前) parses personal names and splits them into their component parts.
|