persondb-models 0.4.2 → 0.5.0
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/Manifest.txt +1 -1
- data/lib/persondb/models.rb +2 -2
- data/lib/persondb/models/forward.rb +1 -1
- data/lib/persondb/models/world/{region.rb → state.rb} +3 -3
- data/lib/persondb/reader.rb +1 -1
- data/lib/persondb/schema.rb +1 -1
- data/lib/persondb/version.rb +2 -2
- data/test/helper.rb +1 -1
- data/test/test_models.rb +5 -5
- data/test/test_reader.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3ea4bb59d89558848fb8796b32e712210b1cfa4
|
4
|
+
data.tar.gz: 7392c52df086e03deba2d078f82f4caecff5c5f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28682887dfe9f105434045157d6e715c4165e326875410db512a379eb96c1f03f957e2f723cb2c8c384397f7da3b6dec7381d401ede19b8d917d144f7c37bc6f
|
7
|
+
data.tar.gz: 0d9402cc73e0cec129daaf947b1d133b66cf496227287c50427cb566afa03fa37d4885a1a67c4ed43be29b7a2c8229a16b3bdfe98e20c98cc8921907891b315b
|
data/Manifest.txt
CHANGED
@@ -7,7 +7,7 @@ lib/persondb/models/forward.rb
|
|
7
7
|
lib/persondb/models/person.rb
|
8
8
|
lib/persondb/models/world/city.rb
|
9
9
|
lib/persondb/models/world/country.rb
|
10
|
-
lib/persondb/models/world/
|
10
|
+
lib/persondb/models/world/state.rb
|
11
11
|
lib/persondb/reader.rb
|
12
12
|
lib/persondb/schema.rb
|
13
13
|
lib/persondb/version.rb
|
data/lib/persondb/models.rb
CHANGED
@@ -14,7 +14,7 @@ require 'persondb/schema'
|
|
14
14
|
require 'persondb/models/forward'
|
15
15
|
|
16
16
|
require 'persondb/models/world/city'
|
17
|
-
require 'persondb/models/world/
|
17
|
+
require 'persondb/models/world/state'
|
18
18
|
require 'persondb/models/world/country'
|
19
19
|
|
20
20
|
require 'persondb/models/person'
|
@@ -68,4 +68,4 @@ module PersonDb
|
|
68
68
|
end # module PersonDb
|
69
69
|
|
70
70
|
# say hello
|
71
|
-
puts PersonDb.banner if
|
71
|
+
puts PersonDb.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
|
@@ -7,7 +7,7 @@ module PersonDb
|
|
7
7
|
## todo: why? why not use include WorldDb::Models here???
|
8
8
|
Continent = WorldDb::Model::Continent
|
9
9
|
Country = WorldDb::Model::Country
|
10
|
-
|
10
|
+
State = WorldDb::Model::State
|
11
11
|
City = WorldDb::Model::City
|
12
12
|
|
13
13
|
Tagging = TagDb::Model::Tagging
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module WorldDb
|
2
2
|
module Model
|
3
3
|
|
4
|
-
class
|
5
|
-
has_many :persons, class_name: 'PersonDb::Model::Person', foreign_key: '
|
6
|
-
end # class
|
4
|
+
class State
|
5
|
+
has_many :persons, class_name: 'PersonDb::Model::Person', foreign_key: 'state_id'
|
6
|
+
end # class State
|
7
7
|
|
8
8
|
end # module Model
|
9
9
|
end # module WorldDb
|
data/lib/persondb/reader.rb
CHANGED
data/lib/persondb/schema.rb
CHANGED
@@ -24,7 +24,7 @@ create_table :persons do |t|
|
|
24
24
|
## todo: add country of birth might not be the same as nationality
|
25
25
|
|
26
26
|
t.references :city
|
27
|
-
t.references :
|
27
|
+
t.references :state
|
28
28
|
t.references :country ## , null: false
|
29
29
|
|
30
30
|
t.references :nationality ## , null: false # by default assume same as country of birth (see above)
|
data/lib/persondb/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -13,7 +13,7 @@ require 'persondb/models'
|
|
13
13
|
################
|
14
14
|
# shortcuts
|
15
15
|
Country = WorldDb::Model::Country
|
16
|
-
|
16
|
+
State = WorldDb::Model::State
|
17
17
|
City = WorldDb::Model::City
|
18
18
|
|
19
19
|
## todo: get all models aliases (e.g. from console script)
|
data/test/test_models.rb
CHANGED
@@ -15,15 +15,15 @@ class TestModels < MiniTest::Test
|
|
15
15
|
def add_world
|
16
16
|
## add some counties
|
17
17
|
at = Country.create!( key: 'at', title: 'Austria', code: 'AUT', pop: 0, area: 0 )
|
18
|
-
n =
|
19
|
-
feuersbrunn = City.create!( key: 'feuersbrunn', title: 'Feuersbrunn', country_id: at.id,
|
18
|
+
n = State.create!( key: 'n', title: 'Niederösterreich', country_id: at.id )
|
19
|
+
feuersbrunn = City.create!( key: 'feuersbrunn', title: 'Feuersbrunn', country_id: at.id, state_id: n.id )
|
20
20
|
end
|
21
21
|
|
22
22
|
|
23
23
|
def test_worlddb_assocs
|
24
|
-
at = Country.
|
25
|
-
n =
|
26
|
-
feuersbrunn = City.
|
24
|
+
at = Country.find_by!( key: 'at' )
|
25
|
+
n = State.find_by!( key: 'n' )
|
26
|
+
feuersbrunn = City.find_by!( key: 'feuersbrunn' )
|
27
27
|
|
28
28
|
assert_equal 0, at.persons.count
|
29
29
|
assert_equal 0, n.persons.count
|
data/test/test_reader.rb
CHANGED
@@ -17,11 +17,11 @@ class TestReader < MiniTest::Test
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_read
|
20
|
-
br = Country.
|
20
|
+
br = Country.find_by!( key: 'br' )
|
21
21
|
|
22
22
|
path = "#{PersonDb.test_data_path}/players/south-america/br-brazil/players.txt"
|
23
23
|
reader = PersonReader.from_file( path, country_id: br.id )
|
24
|
-
reader.read
|
24
|
+
reader.read
|
25
25
|
|
26
26
|
assert_equal 23, Person.count
|
27
27
|
assert_equal 23, br.persons.count
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: persondb-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: worlddb-models
|
@@ -71,7 +71,7 @@ files:
|
|
71
71
|
- lib/persondb/models/person.rb
|
72
72
|
- lib/persondb/models/world/city.rb
|
73
73
|
- lib/persondb/models/world/country.rb
|
74
|
-
- lib/persondb/models/world/
|
74
|
+
- lib/persondb/models/world/state.rb
|
75
75
|
- lib/persondb/reader.rb
|
76
76
|
- lib/persondb/schema.rb
|
77
77
|
- lib/persondb/version.rb
|