persondb 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/Manifest.txt CHANGED
@@ -3,4 +3,10 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  lib/persondb.rb
6
+ lib/persondb/models/forward.rb
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
11
+ lib/persondb/schema.rb
6
12
  lib/persondb/version.rb
data/README.md CHANGED
@@ -16,6 +16,18 @@ TBD
16
16
  TBD
17
17
 
18
18
 
19
+ ## Real World Usage
20
+
21
+ [wine.db](https://github.com/openwine) - Used for Winemakers
22
+
23
+ [football.db](https://github.com/openfootball) - Used for Football Players (Goalies, Defenders, Midfielders, etc.)
24
+
25
+ [ski.db](https://github.com/opensport/ski.db) - Use for Alpine Ski Racers
26
+
27
+ [forumula1.db](https://github.com/opensport/formula1.db) - Used for Formula 1 Race Drivers
28
+
29
+
30
+
19
31
  ## License
20
32
 
21
33
  The `persondb` scripts are dedicated to the public domain.
@@ -0,0 +1,36 @@
1
+ ### forward references
2
+ ## require first to resolve circular references
3
+
4
+ module PersonDb
5
+ module Model
6
+
7
+ ## todo: why? why not use include WorldDb::Models here???
8
+
9
+ Continent = WorldDb::Model::Continent
10
+ Country = WorldDb::Model::Country
11
+ Region = WorldDb::Model::Region
12
+ City = WorldDb::Model::City
13
+
14
+ Tag = WorldDb::Model::Tag
15
+ Tagging = WorldDb::Model::Tagging
16
+
17
+ Prop = WorldDb::Model::Prop
18
+
19
+ class Person < ActiveRecord::Base ; end
20
+
21
+ end # module Model
22
+
23
+ ## note: for convenciene (and compatibility) add alias Models for Model namespace
24
+ ## e.g lets you use include PersonDb::Models
25
+ Models = Model
26
+
27
+ end # module WineDb
28
+
29
+
30
+ module WorldDb
31
+ module Model
32
+
33
+ Person = PersonDb::Model::Person
34
+
35
+ end
36
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+
3
+ module PersonDb
4
+ module Model
5
+
6
+ class Person < ActiveRecord::Base
7
+
8
+ self.table_name = 'persons'
9
+ ## to be done
10
+
11
+ end # class Person
12
+
13
+ end # module Model
14
+ end # module PersonDb
@@ -0,0 +1,10 @@
1
+ module WorldDb
2
+ module Model
3
+
4
+ class City
5
+ has_many :persons, class_name: 'PersonDb::Model::Person', foreign_key: 'city_id'
6
+ end # class City
7
+
8
+ end # module Model
9
+ end # module WorldDb
10
+
@@ -0,0 +1,10 @@
1
+ module WorldDb
2
+ module Model
3
+
4
+ class Country
5
+ has_many :persons, class_name: 'PersonDb::Model::Person', foreign_key: 'country_id'
6
+ end # class Country
7
+
8
+ end # module Model
9
+ end # module WorldDb
10
+
@@ -0,0 +1,10 @@
1
+ module WorldDb
2
+ module Model
3
+
4
+ class Region
5
+ has_many :persons, class_name: 'PersonDb::Model::Person', foreign_key: 'region_id'
6
+ end # class Region
7
+
8
+ end # module Model
9
+ end # module WorldDb
10
+
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+
3
+ module PersonDb
4
+
5
+ class CreateDb < ActiveRecord::Migration
6
+
7
+ def up
8
+
9
+ ###########
10
+ # use people ? instead of persons (person/persons makes it easier?)
11
+
12
+ create_table :persons do |t|
13
+ t.string :key, null: false # import/export key
14
+ t.string :name, null: false
15
+ t.string :synonyms # comma separated list of synonyms
16
+
17
+ ## todo: add gender flag (male/female -man/lady how?)
18
+ t.date :born_at # optional date of birth (birthday)
19
+ ## todo: add country of birth might not be the same as nationality
20
+
21
+ t.references :city
22
+ t.references :region
23
+ t.references :country ## , null: false
24
+
25
+ t.references :nationality ## , null: false # by default assume same as country of birth (see above)
26
+
27
+ t.timestamps
28
+ end
29
+
30
+ end # method up
31
+
32
+ def down
33
+ raise ActiveRecord::IrreversibleMigration
34
+ end
35
+
36
+
37
+ end # class CreateDb
38
+
39
+ end # module PersonDb
@@ -1,4 +1,5 @@
1
1
 
2
2
  module PersonDb
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
5
+
data/lib/persondb.rb CHANGED
@@ -1,6 +1,26 @@
1
1
 
2
+ # 3rd party gems / libs
3
+
4
+ require 'active_record' ## todo: add sqlite3? etc.
5
+
6
+ require 'logutils'
7
+ require 'textutils'
8
+ require 'worlddb'
9
+
10
+
11
+ ### our own code
2
12
 
3
13
  require 'persondb/version' # let it always go first
14
+ require 'persondb/schema'
15
+
16
+ require 'persondb/models/forward'
17
+
18
+ require 'persondb/models/worlddb/city'
19
+ require 'persondb/models/worlddb/region'
20
+ require 'persondb/models/worlddb/country'
21
+
22
+ require 'persondb/models/person'
23
+
4
24
 
5
25
 
6
26
  module PersonDb
@@ -13,6 +33,24 @@ module PersonDb
13
33
  "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
14
34
  end
15
35
 
36
+
37
+ def self.create
38
+ CreateDb.new.up
39
+
40
+ Model::Prop.create!( key: 'db.schema.person.version', value: VERSION )
41
+ end
42
+
43
+ def self.delete!
44
+ ## fix/todo: move into deleter class (see worlddb,sportdb etc.)
45
+ Model::Person.delete_all
46
+ end
47
+
48
+ def self.tables
49
+ ## fix/todo: move into stats class (see worlddb,sportdb etc.)
50
+ puts " #{Model::Person.count} persons"
51
+ end
52
+
53
+
16
54
  end # module PersonDb
17
55
 
18
56
 
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ require 'helper'
5
+
6
+
7
+ class TestModels < MiniTest::Unit::TestCase
8
+
9
+ def setup # runs before every test
10
+ PersonDb.delete! # always clean-out tables
11
+ end
12
+
13
+ def test_worlddb_assocs
14
+ assert_equal 0, AT.persons.count
15
+ assert_equal 0, N.persons.count
16
+ assert_equal 0, FEUERSBRUNN.persons.count
17
+ end
18
+
19
+ def test_count
20
+ assert_equal 0, Person.count
21
+
22
+ PersonDb.tables # print stats
23
+ end
24
+
25
+ end # class TestModels
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persondb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2014-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logutils
16
- requirement: &77830470 !ruby/object:Gem::Requirement
16
+ requirement: &73136460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *77830470
24
+ version_requirements: *73136460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &77830090 !ruby/object:Gem::Requirement
27
+ requirement: &73136130 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.10'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *77830090
35
+ version_requirements: *73136130
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hoe
38
- requirement: &77829640 !ruby/object:Gem::Requirement
38
+ requirement: &73135730 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *77829640
46
+ version_requirements: *73135730
47
47
  description: persondb - person schema n models for easy (re)use
48
48
  email: webslideshow@googlegroups.com
49
49
  executables: []
@@ -56,7 +56,15 @@ files:
56
56
  - README.md
57
57
  - Rakefile
58
58
  - lib/persondb.rb
59
+ - lib/persondb/models/forward.rb
60
+ - lib/persondb/models/person.rb
61
+ - lib/persondb/models/worlddb/city.rb
62
+ - lib/persondb/models/worlddb/country.rb
63
+ - lib/persondb/models/worlddb/region.rb
64
+ - lib/persondb/schema.rb
59
65
  - lib/persondb/version.rb
66
+ - test/test_models.rb
67
+ - .gemtest
60
68
  homepage: https://github.com/geraldb/person.db.ruby
61
69
  licenses:
62
70
  - Public Domain
@@ -84,4 +92,5 @@ rubygems_version: 1.8.17
84
92
  signing_key:
85
93
  specification_version: 3
86
94
  summary: persondb - person schema n models for easy (re)use
87
- test_files: []
95
+ test_files:
96
+ - test/test_models.rb