person-name 0.2.3 → 0.2.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/VERSION +1 -1
- data/lib/person-name.rb +0 -3
- data/lib/person_name/migration_support.rb +11 -10
- data/spec/schema.rb +3 -3
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.4
|
data/lib/person-name.rb
CHANGED
|
@@ -9,9 +9,6 @@ require "person_name/migration_support"
|
|
|
9
9
|
|
|
10
10
|
$LOAD_PATH.shift
|
|
11
11
|
|
|
12
|
-
if defined?(ActiveRecord::ConnectionAdapters::TableDefinition)
|
|
13
|
-
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, PersonName::MigrationSupport
|
|
14
|
-
end
|
|
15
12
|
if defined?(ActiveRecord::Base)
|
|
16
13
|
ActiveRecord::Base.send :include, PersonName::ActiveRecord
|
|
17
14
|
end
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
require 'active_record/connection_adapters/abstract_adapter'
|
|
1
2
|
|
|
2
|
-
module
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module ConnectionAdapters
|
|
5
|
+
class TableDefinition
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
def person_name(name, *args)
|
|
8
|
+
options = args.extract_options!
|
|
9
|
+
name_parts = PersonName::NameSplitter::NAME_PARTS
|
|
10
|
+
name_parts.each do |part|
|
|
11
|
+
column("#{name}_#{part}".to_sym, :string, :null => true)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
7
14
|
|
|
8
|
-
def self.add_name_columns(table, prefix, *args)
|
|
9
|
-
options = args.extract_options!
|
|
10
|
-
name_parts = PersonName::NameSplitter::NAME_PARTS
|
|
11
|
-
name_parts.each do |part|
|
|
12
|
-
table.column("#{prefix}_#{part}".to_sym, :string, :null => true)
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
|
-
|
|
16
17
|
end
|
data/spec/schema.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ActiveRecord::Schema.define :version => 0 do
|
|
2
2
|
create_table "people", :force => true do |t|
|
|
3
|
-
|
|
3
|
+
t.person_name :name
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
create_table "person_without_names", :force => true do |t|
|
|
@@ -8,8 +8,8 @@ ActiveRecord::Schema.define :version => 0 do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
create_table "name_people", :force => true do |t|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
t.person_name :name
|
|
12
|
+
t.person_name :birth_name
|
|
13
13
|
t.boolean :female
|
|
14
14
|
end
|
|
15
15
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: person-name
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 31
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 4
|
|
10
|
+
version: 0.2.4
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Matthijs Groen
|