persondb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -10,3 +10,5 @@ lib/persondb/models/worlddb/country.rb
10
10
  lib/persondb/models/worlddb/region.rb
11
11
  lib/persondb/schema.rb
12
12
  lib/persondb/version.rb
13
+ test/helper.rb
14
+ test/test_models.rb
data/Rakefile CHANGED
@@ -18,7 +18,14 @@ Hoe.spec 'persondb' do
18
18
  self.history_file = 'HISTORY.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['logutils', '>= 0.5']
21
+ ['props' ],
22
+ ['logutils'],
23
+ ['textutils'],
24
+ ['worlddb'],
25
+ ['tagutils'], # tags n tagging tables
26
+ ['activerecord-utils'], # extras e.g. rnd, find_by! for 3.x etc.
27
+ ## 3rd party
28
+ ['activerecord'] # NB: will include activesupport,etc.
22
29
  ]
23
30
 
24
31
  self.licenses = ['Public Domain']
data/lib/persondb.rb CHANGED
@@ -3,8 +3,13 @@
3
3
 
4
4
  require 'active_record' ## todo: add sqlite3? etc.
5
5
 
6
+ require 'activerecord/utils' # check - if dependency on logutils? or props? etc let others go first
7
+
6
8
  require 'logutils'
7
9
  require 'textutils'
10
+ require 'tagutils'
11
+ require 'props'
12
+ require 'props/db' # includes ConfDb (ConfDb::Model::Prop, etc.)
8
13
  require 'worlddb'
9
14
 
10
15
 
@@ -4,17 +4,16 @@
4
4
  module PersonDb
5
5
  module Model
6
6
 
7
- ## todo: why? why not use include WorldDb::Models here???
7
+ ## todo: why? why not use include WorldDb::Models here???
8
+ Continent = WorldDb::Model::Continent
9
+ Country = WorldDb::Model::Country
10
+ Region = WorldDb::Model::Region
11
+ City = WorldDb::Model::City
8
12
 
9
- Continent = WorldDb::Model::Continent
10
- Country = WorldDb::Model::Country
11
- Region = WorldDb::Model::Region
12
- City = WorldDb::Model::City
13
+ Tagging = TagDb::Model::Tagging
14
+ Tag = TagDb::Model::Tag
13
15
 
14
- Tag = WorldDb::Model::Tag
15
- Tagging = WorldDb::Model::Tagging
16
-
17
- Prop = WorldDb::Model::Prop
16
+ Prop = ConfDb::Model::Prop
18
17
 
19
18
  class Person < ActiveRecord::Base ; end
20
19
 
@@ -24,13 +23,11 @@ module PersonDb
24
23
  ## e.g lets you use include PersonDb::Models
25
24
  Models = Model
26
25
 
27
- end # module WineDb
26
+ end # module PersonDb
28
27
 
29
28
 
30
29
  module WorldDb
31
30
  module Model
32
-
33
- Person = PersonDb::Model::Person
34
-
31
+ Person = PersonDb::Model::Person
35
32
  end
36
33
  end
@@ -2,9 +2,10 @@
2
2
 
3
3
  module PersonDb
4
4
 
5
- class CreateDb < ActiveRecord::Migration
5
+ class CreateDb
6
6
 
7
7
  def up
8
+ ActiveRecord::Schema.define do
8
9
 
9
10
  ###########
10
11
  # use people ? instead of persons (person/persons makes it easier?)
@@ -13,6 +14,10 @@ create_table :persons do |t|
13
14
  t.string :key, null: false # import/export key
14
15
  t.string :name, null: false
15
16
  t.string :synonyms # comma separated list of synonyms
17
+ ### fix: change to alt_names
18
+
19
+ t.string :code # three letter code (short title) e.g used for formula1 driver etc.
20
+
16
21
 
17
22
  ## todo: add gender flag (male/female -man/lady how?)
18
23
  t.date :born_at # optional date of birth (birthday)
@@ -23,17 +28,39 @@ create_table :persons do |t|
23
28
  t.references :country ## , null: false
24
29
 
25
30
  t.references :nationality ## , null: false # by default assume same as country of birth (see above)
31
+ ## fix: add nationality2 n nationality3 too
26
32
 
27
33
  t.timestamps
28
34
  end
29
35
 
30
- end # method up
31
-
32
- def down
33
- raise ActiveRecord::IrreversibleMigration
34
- end
35
36
 
37
+ end # Schema.define
38
+ end # method up
36
39
 
37
40
  end # class CreateDb
38
41
 
39
42
  end # module PersonDb
43
+
44
+
45
+
46
+ =begin
47
+ # old (original) sportdb persons table
48
+ create_table :persons do |t| # use people ? instead of persons (person/persons makes it easier?)
49
+ t.string :key, null: false # import/export key
50
+ t.string :name, null: false
51
+ t.string :synonyms # comma separated list of synonyms
52
+ t.string :code # three letter code (short title)
53
+
54
+ ## todo: add gender flag (male/female -man/lady how?)
55
+ t.date :born_at # optional date of birth (birthday)
56
+ ## todo: add country of birth might not be the same as nationality
57
+
58
+ t.references :city
59
+ t.references :region
60
+ t.references :country, null: false
61
+
62
+ t.references :nationality, null: false # by default assume same as country of birth (see above)
63
+
64
+ t.timestamps
65
+ end
66
+ =end
@@ -1,5 +1,5 @@
1
1
 
2
2
  module PersonDb
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
 
data/test/helper.rb ADDED
@@ -0,0 +1,77 @@
1
+ # encoding: UTF-8
2
+
3
+ ## $:.unshift(File.dirname(__FILE__))
4
+
5
+ ## minitest setup
6
+
7
+ # require 'minitest/unit'
8
+ require 'minitest/autorun'
9
+
10
+ # include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
11
+
12
+
13
+ # ruby stdlibs
14
+
15
+ require 'json'
16
+ require 'uri'
17
+ require 'pp'
18
+
19
+ # our own code
20
+
21
+ require 'persondb'
22
+ require 'logutils/db' # NB: explict require required for LogDb (not automatic)
23
+
24
+ Country = WorldDb::Model::Country
25
+ Region = WorldDb::Model::Region
26
+ City = WorldDb::Model::City
27
+
28
+ ## todo: get all models aliases (e.g. from console script)
29
+
30
+ Person = PersonDb::Model::Person
31
+
32
+
33
+
34
+
35
+ def setup_in_memory_db
36
+ # Database Setup & Config
37
+
38
+ db_config = {
39
+ adapter: 'sqlite3',
40
+ database: ':memory:'
41
+ }
42
+
43
+ pp db_config
44
+
45
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
46
+ ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
47
+
48
+ ## NB: every connect will create a new empty in memory db
49
+ ActiveRecord::Base.establish_connection( db_config )
50
+
51
+
52
+ ## build schema
53
+
54
+ LogDb.create
55
+ ConfDb.create
56
+ TagDb.create
57
+ WorldDb.create
58
+ PersonDb.create
59
+ end
60
+
61
+
62
+ def fillup_in_memory_db
63
+ ## add some counties
64
+
65
+ at = Country.create!( key: 'at', title: 'Austria', code: 'AUT', pop: 0, area: 0 )
66
+ n = Region.create!( key: 'n', title: 'Niederösterreich', country_id: at.id )
67
+ feuersbrunn = City.create!( key: 'feuersbrunn', title: 'Feuersbrunn', country_id: at.id, region_id: n.id )
68
+
69
+ end
70
+
71
+ setup_in_memory_db()
72
+ fillup_in_memory_db()
73
+
74
+ AT = Country.find_by_key!( 'at' )
75
+ N = Region.find_by_key!( 'n' )
76
+ FEUERSBRUNN = City.find_by_key!( 'feuersbrunn' )
77
+
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.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,47 +9,115 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-05 00:00:00.000000000 Z
12
+ date: 2014-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: props
16
+ requirement: &83236560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *83236560
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: logutils
16
- requirement: &73136460 !ruby/object:Gem::Requirement
27
+ requirement: &83236220 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *83236220
36
+ - !ruby/object:Gem::Dependency
37
+ name: textutils
38
+ requirement: &83235830 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *83235830
47
+ - !ruby/object:Gem::Dependency
48
+ name: worlddb
49
+ requirement: &83235410 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *83235410
58
+ - !ruby/object:Gem::Dependency
59
+ name: tagutils
60
+ requirement: &83234330 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *83234330
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord-utils
71
+ requirement: &83249150 !ruby/object:Gem::Requirement
17
72
  none: false
18
73
  requirements:
19
74
  - - ! '>='
20
75
  - !ruby/object:Gem::Version
21
- version: '0.5'
76
+ version: '0'
22
77
  type: :runtime
23
78
  prerelease: false
24
- version_requirements: *73136460
79
+ version_requirements: *83249150
80
+ - !ruby/object:Gem::Dependency
81
+ name: activerecord
82
+ requirement: &83248700 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *83248700
25
91
  - !ruby/object:Gem::Dependency
26
92
  name: rdoc
27
- requirement: &73136130 !ruby/object:Gem::Requirement
93
+ requirement: &83248000 !ruby/object:Gem::Requirement
28
94
  none: false
29
95
  requirements:
30
96
  - - ~>
31
97
  - !ruby/object:Gem::Version
32
- version: '3.10'
98
+ version: '4.0'
33
99
  type: :development
34
100
  prerelease: false
35
- version_requirements: *73136130
101
+ version_requirements: *83248000
36
102
  - !ruby/object:Gem::Dependency
37
103
  name: hoe
38
- requirement: &73135730 !ruby/object:Gem::Requirement
104
+ requirement: &83247450 !ruby/object:Gem::Requirement
39
105
  none: false
40
106
  requirements:
41
107
  - - ~>
42
108
  - !ruby/object:Gem::Version
43
- version: '3.3'
109
+ version: '3.11'
44
110
  type: :development
45
111
  prerelease: false
46
- version_requirements: *73135730
112
+ version_requirements: *83247450
47
113
  description: persondb - person schema n models for easy (re)use
48
114
  email: webslideshow@googlegroups.com
49
115
  executables: []
50
116
  extensions: []
51
117
  extra_rdoc_files:
118
+ - HISTORY.md
52
119
  - Manifest.txt
120
+ - README.md
53
121
  files:
54
122
  - HISTORY.md
55
123
  - Manifest.txt
@@ -63,6 +131,7 @@ files:
63
131
  - lib/persondb/models/worlddb/region.rb
64
132
  - lib/persondb/schema.rb
65
133
  - lib/persondb/version.rb
134
+ - test/helper.rb
66
135
  - test/test_models.rb
67
136
  - .gemtest
68
137
  homepage: https://github.com/geraldb/person.db.ruby
@@ -87,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
156
  - !ruby/object:Gem::Version
88
157
  version: '0'
89
158
  requirements: []
90
- rubyforge_project: persondb
159
+ rubyforge_project:
91
160
  rubygems_version: 1.8.17
92
161
  signing_key:
93
162
  specification_version: 3