person-name 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/README.markdown +2 -0
- data/Rakefile +7 -0
- data/lib/person-name.rb +1 -0
- data/lib/person_name/has_person_name.rb +7 -5
- data/lib/person_name/name_splitter.rb +1 -1
- data/lib/person_name/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +3 -16
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -7,6 +7,8 @@ If you have to fill in a name for somebody, you have to display all those fields
|
|
7
7
|
The goal is to make one field that can split up the name and assign it to the correct fields automatically.
|
8
8
|
You can also still use the more precise input if necessary.
|
9
9
|
|
10
|
+
[![build status](http://travis-ci.org/matthijsgroen/person-name.png)](http://travis-ci.org/matthijsgroen/person-name)
|
11
|
+
|
10
12
|
Installation
|
11
13
|
============
|
12
14
|
in your Gemfile:
|
data/Rakefile
CHANGED
data/lib/person-name.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
require "active_support/core_ext/class/inheritable_attributes"
|
2
|
+
|
1
3
|
module PersonName
|
2
4
|
|
3
5
|
module ActiveRecord
|
4
6
|
|
5
7
|
def self.included(base) # :nodoc:
|
6
8
|
base.extend ClassMethods
|
9
|
+
base.class_attribute :name_types
|
7
10
|
end
|
8
11
|
|
9
12
|
module ClassMethods
|
@@ -17,10 +20,9 @@ module PersonName
|
|
17
20
|
name_types << :name if name_types.empty?
|
18
21
|
|
19
22
|
if has_person_names?
|
20
|
-
|
23
|
+
self.name_types = (self.name_types + name_types).uniq
|
21
24
|
else
|
22
|
-
|
23
|
-
class_inheritable_reader(:name_types)
|
25
|
+
self.name_types = name_types
|
24
26
|
|
25
27
|
class_eval do
|
26
28
|
def self.has_person_names?
|
@@ -102,7 +104,7 @@ module PersonName
|
|
102
104
|
# the field should make sure the values are comparable (eg. the separated values combined
|
103
105
|
# should be equal to the aggregated one). If this is the case, the separated fields
|
104
106
|
# will rule over the aggregated one, since it is more detailed and adds up to the same result.
|
105
|
-
def attributes=(new_attributes
|
107
|
+
def attributes=(new_attributes)
|
106
108
|
return unless new_attributes.is_a?(Hash)
|
107
109
|
attributes = new_attributes.stringify_keys
|
108
110
|
|
@@ -152,7 +154,7 @@ module PersonName
|
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
155
|
-
super attributes
|
157
|
+
super attributes
|
156
158
|
end
|
157
159
|
|
158
160
|
private
|
@@ -155,7 +155,7 @@ module PersonName
|
|
155
155
|
|
156
156
|
part_score = O[part.to_sym]
|
157
157
|
if part_values.include? value
|
158
|
-
part_score = O[:first_name] if stage == O[:prefix] and part
|
158
|
+
part_score = O[:first_name] if stage == O[:prefix] and part == :middle_name
|
159
159
|
new_stage = part_score if part_score > new_stage
|
160
160
|
return new_stage
|
161
161
|
end
|
data/lib/person_name/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -32,6 +32,7 @@ end
|
|
32
32
|
ENV['DB'] ||= 'sqlite3'
|
33
33
|
|
34
34
|
database_yml = File.expand_path('../database.yml', __FILE__)
|
35
|
+
database_yml = File.expand_path('../database.yml.sample', __FILE__) unless File.exists?(database_yml)
|
35
36
|
if File.exists?(database_yml)
|
36
37
|
active_record_configuration = YAML.load_file(database_yml)[ENV['DB']]
|
37
38
|
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: person-name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 1
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 11
|
10
|
-
version: 0.2.11
|
5
|
+
version: 0.2.12
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Matthijs Groen
|
@@ -15,8 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
13
|
+
date: 2011-09-19 00:00:00 Z
|
20
14
|
dependencies: []
|
21
15
|
|
22
16
|
description: Manages all person name fields (prefix, first name, middle name, intercalation, last name, suffix)
|
@@ -49,7 +43,6 @@ files:
|
|
49
43
|
- spec/person_name/has_person_name_spec.rb
|
50
44
|
- spec/schema.rb
|
51
45
|
- spec/spec_helper.rb
|
52
|
-
has_rdoc: true
|
53
46
|
homepage: http://github.com/matthijsgroen/person-name
|
54
47
|
licenses: []
|
55
48
|
|
@@ -63,23 +56,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
56
|
requirements:
|
64
57
|
- - ">="
|
65
58
|
- !ruby/object:Gem::Version
|
66
|
-
hash: 3
|
67
|
-
segments:
|
68
|
-
- 0
|
69
59
|
version: "0"
|
70
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
61
|
none: false
|
72
62
|
requirements:
|
73
63
|
- - ">="
|
74
64
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 3
|
76
|
-
segments:
|
77
|
-
- 0
|
78
65
|
version: "0"
|
79
66
|
requirements: []
|
80
67
|
|
81
68
|
rubyforge_project: person-name
|
82
|
-
rubygems_version: 1.
|
69
|
+
rubygems_version: 1.8.10
|
83
70
|
signing_key:
|
84
71
|
specification_version: 3
|
85
72
|
summary: Easy editing of person names.
|