persondb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -5,9 +5,9 @@ Rakefile
5
5
  lib/persondb.rb
6
6
  lib/persondb/models/forward.rb
7
7
  lib/persondb/models/person.rb
8
- lib/persondb/models/worlddb/city.rb
9
- lib/persondb/models/worlddb/country.rb
10
- lib/persondb/models/worlddb/region.rb
8
+ lib/persondb/models/world/city.rb
9
+ lib/persondb/models/world/country.rb
10
+ lib/persondb/models/world/region.rb
11
11
  lib/persondb/reader.rb
12
12
  lib/persondb/schema.rb
13
13
  lib/persondb/version.rb
@@ -15,7 +15,7 @@ module PersonDb
15
15
 
16
16
  Prop = ConfDb::Model::Prop
17
17
 
18
- class Person < ActiveRecord::Base ; end
18
+ class Person < ActiveRecord::Base ; end
19
19
 
20
20
  end # module Model
21
21
 
@@ -23,6 +23,8 @@ class Person < ActiveRecord::Base
23
23
  new_attributes[ :country_id ] = value_country.id
24
24
  elsif value =~ /^[A-Z]{3}$/ ## assume three-letter code e.g. AUS, MAL, etc.
25
25
  new_attributes[ :code ] = value
26
+
27
+ #### fix: use more generic/better date reader (allow more formats!!!)
26
28
  elsif value =~ /^([0-9]{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s([0-9]{4})$/ ## assume birthday
27
29
  value_date_str = '%02d/%s/%d' % [$1, $2, $3] ## move to matcher!!
28
30
  value_date = Date.strptime( value_date_str, '%d/%b/%Y' ) ## %b - abbreviated month name (e.g. Jan,Feb, etc.)
@@ -43,6 +45,41 @@ class Person < ActiveRecord::Base
43
45
  new_attributes[ :nationality_id ] = new_attributes[ :country_id ]
44
46
  end
45
47
 
48
+
49
+ ####################################################
50
+ # title-ize / normal-ize names (titles/synonyms)
51
+
52
+ ##
53
+ ## make sure title and synonyms do NOT use all UPPERCASE
54
+ ## e.g. convert Neymar DA SILVA SANTOS to Neymar Da Sliva Santos etc.
55
+
56
+ ### fix: add auto camelcase/titlecase
57
+ ## move to textutils
58
+ ## make it an option for name to auto Camelcase/titlecase?
59
+ ## e.g. BONFIM COSTA SANTOS becomes
60
+ ## Bonfim Costa Santos etc.
61
+ ## fix: better move into person parser?
62
+ ## store all alt_names titleized!!!
63
+
64
+ raw_title = new_attributes[ :title ]
65
+ new_title = titleize( raw_title )
66
+ if raw_title != new_title
67
+ logger.debug " change person title/name to <#{new_title}> from >#{raw_title}<"
68
+ new_attributes[ :title ] = new_title
69
+ end
70
+
71
+ raw_synonyms = new_attributes[ :synonyms ]
72
+ if raw_synonyms.present?
73
+ new_synonyms = raw_synonyms.split('|').map { |value| titleize(value) }.join('|')
74
+
75
+ if raw_synonyms != new_synonyms
76
+ logger.debug " change person synonyms/alt_names to <#{new_synonyms}> from >#{raw_synonyms}<"
77
+ new_attributes[ :synonyms ] = new_synonyms
78
+ end
79
+ end
80
+
81
+
82
+
46
83
  rec = Person.find_by_key( new_attributes[ :key ] )
47
84
  if rec.present?
48
85
  logger.debug "update Person #{rec.id}-#{rec.key}:"
@@ -56,6 +93,15 @@ class Person < ActiveRecord::Base
56
93
  rec.update_attributes!( new_attributes )
57
94
  end # create_or_update_from_values
58
95
 
96
+ private
97
+
98
+
99
+ def self.titleize( str ) # note: added as class-level method for self.create etc.
100
+ ## fix: for now works only with ASCII only
101
+ ## words 2 letters and ups
102
+ ## fix also allow words w/ quote e.g. O'Connor etc.
103
+ str.gsub(/\b[A-Z]{2,}\b/) { |match| match.capitalize }
104
+ end
59
105
 
60
106
  end # class Person
61
107
 
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
 
2
2
  module PersonDb
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
 
data/lib/persondb.rb CHANGED
@@ -1,26 +1,17 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  # core and stdlibs
4
+ # todo: check already included in worlddb - thus, remove? why? why not?
4
5
  require 'json'
5
6
  require 'uri'
6
7
  require 'pp'
7
8
 
8
9
 
9
10
  # 3rd party gems / libs
10
- require 'active_record' ## todo: add sqlite3? etc.
11
+ require 'worlddb' # note: let worlddb pull in all 3rd party gems / libs (do NOT duplicate here)
11
12
 
12
- require 'activerecord/utils' # check - if dependency on logutils? or props? etc let others go first
13
-
14
- require 'logutils'
15
- require 'logutils/db' # NB: explict require required for LogDb (NOT automatic)
16
-
17
- require 'textutils'
18
- require 'tagutils'
19
-
20
- require 'props'
21
- require 'props/db' # NB: explict require required for LogDb (NOT automatic); includes ConfDb (ConfDb::Model::Prop, etc.)
22
-
23
- require 'worlddb'
13
+ ## fix: add/move to worlddb
14
+ require 'logutils/db'
24
15
 
25
16
 
26
17
  ### our own code
@@ -30,9 +21,9 @@ require 'persondb/schema'
30
21
 
31
22
  require 'persondb/models/forward'
32
23
 
33
- require 'persondb/models/worlddb/city'
34
- require 'persondb/models/worlddb/region'
35
- require 'persondb/models/worlddb/country'
24
+ require 'persondb/models/world/city'
25
+ require 'persondb/models/world/region'
26
+ require 'persondb/models/world/country'
36
27
 
37
28
  require 'persondb/models/person'
38
29
  require 'persondb/reader'
data/test/test_reader.rb CHANGED
@@ -13,7 +13,7 @@ class TestReader < MiniTest::Unit::TestCase
13
13
 
14
14
  def add_world
15
15
  ## add some counties
16
- br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 0, area: 0 )
16
+ Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 0, area: 0 )
17
17
  end
18
18
 
19
19
  def test_read
@@ -24,6 +24,11 @@ class TestReader < MiniTest::Unit::TestCase
24
24
 
25
25
  assert_equal 23, Person.count
26
26
  assert_equal 23, br.persons.count
27
+
28
+ jefferson = Person.find_by_key!( 'jefferson' )
29
+ assert_equal 'Jefferson De Oliveira Galvao', jefferson.synonyms
30
+ ## todo: add more asserts - use assert_persons ?
31
+
27
32
  end
28
33
 
29
34
  end # class TestReader
metadata CHANGED
@@ -1,141 +1,115 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persondb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Gerald Bauer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
12
+ date: 2014-05-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: props
15
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &75685120 !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ! '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
24
+ version_requirements: *75685120
27
25
  - !ruby/object:Gem::Dependency
28
26
  name: logutils
29
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &75684720 !ruby/object:Gem::Requirement
28
+ none: false
30
29
  requirements:
31
30
  - - ! '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
35
+ version_requirements: *75684720
41
36
  - !ruby/object:Gem::Dependency
42
37
  name: textutils
43
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &75684280 !ruby/object:Gem::Requirement
39
+ none: false
44
40
  requirements:
45
41
  - - ! '>='
46
42
  - !ruby/object:Gem::Version
47
43
  version: '0'
48
44
  type: :runtime
49
45
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
46
+ version_requirements: *75684280
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: worlddb
57
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &75683770 !ruby/object:Gem::Requirement
50
+ none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  type: :runtime
63
56
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
57
+ version_requirements: *75683770
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: tagutils
71
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &75683300 !ruby/object:Gem::Requirement
61
+ none: false
72
62
  requirements:
73
63
  - - ! '>='
74
64
  - !ruby/object:Gem::Version
75
65
  version: '0'
76
66
  type: :runtime
77
67
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ! '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ version_requirements: *75683300
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: activerecord-utils
85
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &75682920 !ruby/object:Gem::Requirement
72
+ none: false
86
73
  requirements:
87
74
  - - ! '>='
88
75
  - !ruby/object:Gem::Version
89
76
  version: '0'
90
77
  type: :runtime
91
78
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
79
+ version_requirements: *75682920
97
80
  - !ruby/object:Gem::Dependency
98
81
  name: activerecord
99
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &75682620 !ruby/object:Gem::Requirement
83
+ none: false
100
84
  requirements:
101
85
  - - ! '>='
102
86
  - !ruby/object:Gem::Version
103
87
  version: '0'
104
88
  type: :runtime
105
89
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
90
+ version_requirements: *75682620
111
91
  - !ruby/object:Gem::Dependency
112
92
  name: rdoc
113
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &75682000 !ruby/object:Gem::Requirement
94
+ none: false
114
95
  requirements:
115
96
  - - ~>
116
97
  - !ruby/object:Gem::Version
117
98
  version: '4.0'
118
99
  type: :development
119
100
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ~>
123
- - !ruby/object:Gem::Version
124
- version: '4.0'
101
+ version_requirements: *75682000
125
102
  - !ruby/object:Gem::Dependency
126
103
  name: hoe
127
- requirement: !ruby/object:Gem::Requirement
104
+ requirement: &75681240 !ruby/object:Gem::Requirement
105
+ none: false
128
106
  requirements:
129
107
  - - ~>
130
108
  - !ruby/object:Gem::Version
131
- version: '3.10'
109
+ version: '3.11'
132
110
  type: :development
133
111
  prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ~>
137
- - !ruby/object:Gem::Version
138
- version: '3.10'
112
+ version_requirements: *75681240
139
113
  description: persondb - person schema n models for easy (re)use
140
114
  email: webslideshow@googlegroups.com
141
115
  executables: []
@@ -152,9 +126,9 @@ files:
152
126
  - lib/persondb.rb
153
127
  - lib/persondb/models/forward.rb
154
128
  - lib/persondb/models/person.rb
155
- - lib/persondb/models/worlddb/city.rb
156
- - lib/persondb/models/worlddb/country.rb
157
- - lib/persondb/models/worlddb/region.rb
129
+ - lib/persondb/models/world/city.rb
130
+ - lib/persondb/models/world/country.rb
131
+ - lib/persondb/models/world/region.rb
158
132
  - lib/persondb/reader.rb
159
133
  - lib/persondb/schema.rb
160
134
  - lib/persondb/version.rb
@@ -166,7 +140,6 @@ files:
166
140
  homepage: https://github.com/geraldb/person.db.ruby
167
141
  licenses:
168
142
  - Public Domain
169
- metadata: {}
170
143
  post_install_message:
171
144
  rdoc_options:
172
145
  - --main
@@ -174,20 +147,22 @@ rdoc_options:
174
147
  require_paths:
175
148
  - lib
176
149
  required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
177
151
  requirements:
178
152
  - - ! '>='
179
153
  - !ruby/object:Gem::Version
180
154
  version: 1.9.2
181
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
182
157
  requirements:
183
158
  - - ! '>='
184
159
  - !ruby/object:Gem::Version
185
160
  version: '0'
186
161
  requirements: []
187
162
  rubyforge_project:
188
- rubygems_version: 2.1.10
163
+ rubygems_version: 1.8.17
189
164
  signing_key:
190
- specification_version: 4
165
+ specification_version: 3
191
166
  summary: persondb - person schema n models for easy (re)use
192
167
  test_files:
193
168
  - test/test_models.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 8ae3400852fe3e86d39cef68b9b9d5dbfb15bc97
4
- data.tar.gz: 1af4911c17764d27463a5bf4124910bab85d123e
5
- SHA512:
6
- metadata.gz: e9a92a35b7aea6f0cfaf16b7783cfed55f8db4a56e82bfde653b4aebe231bbbf7984ced2d24987a52d18c346f54bda509c92ea03ee9dc78436dc7525bca9b0c0
7
- data.tar.gz: 579c4f48464a2c5e44b2e4a7363dd0b13699731ad90c735733d82c9f720cc0b10543d8aef4971573242d3510e124e27e67b3a4cb940f9fdcf9d49124318d381e