Permalink
Browse files

use model ns

  • Loading branch information...
1 parent 2699448 commit cc945738c37c7a99979987c8918529354b2d1eff @geraldb geraldb committed Feb 9, 2014
View
@@ -13,15 +13,11 @@ lib/sportdb.rb
lib/sportdb/cli/main.rb
lib/sportdb/cli/opts.rb
lib/sportdb/console.rb
-lib/sportdb/data/fixtures.rb
lib/sportdb/data/keys.rb
lib/sportdb/data/models.rb
lib/sportdb/deleter.rb
lib/sportdb/lang.rb
lib/sportdb/models/badge.rb
-lib/sportdb/models/city.rb
-lib/sportdb/models/continent.rb
-lib/sportdb/models/country.rb
lib/sportdb/models/event.rb
lib/sportdb/models/event_team.rb
lib/sportdb/models/forward.rb
@@ -31,17 +27,19 @@ lib/sportdb/models/group.rb
lib/sportdb/models/group_team.rb
lib/sportdb/models/league.rb
lib/sportdb/models/person.rb
-lib/sportdb/models/prop.rb
lib/sportdb/models/race.rb
lib/sportdb/models/record.rb
-lib/sportdb/models/region.rb
lib/sportdb/models/roster.rb
lib/sportdb/models/round.rb
lib/sportdb/models/run.rb
lib/sportdb/models/season.rb
lib/sportdb/models/team.rb
lib/sportdb/models/track.rb
lib/sportdb/models/utils.rb
+lib/sportdb/models/world/city.rb
+lib/sportdb/models/world/continent.rb
+lib/sportdb/models/world/country.rb
+lib/sportdb/models/world/region.rb
lib/sportdb/reader.rb
lib/sportdb/schema.rb
lib/sportdb/service.rb
@@ -79,7 +77,6 @@ lib/sportdb/title.rb
lib/sportdb/updater.rb
lib/sportdb/utils.rb
lib/sportdb/version.rb
-tasks/test.rb
test/helper.rb
test/test_changes.rb
test/test_cursor.rb
View
@@ -139,9 +139,9 @@ Just install the gem:
## Free Open Public Domain Datasets
- [`football.db`](https://github.com/openfootball) - free open public domain football (soccer) data for use in any (programming) language
-- [`formula1.db`](https://github.com/geraldb/formula1.db) - free open public domain Formula 1/Formula One data for use in any (programming) language
-- [`ski.db`](https://github.com/geraldb/ski.db) - free open public domain Ski Alpin/Alpine Ski data for use in any (programming) language
-- [`sport.db`](https://github.com/geraldb/sport.db) - free open public domain sports data for use in any (programming) language
+- [`formula1.db`](https://github.com/opensport/formula1.db) - free open public domain Formula 1/Formula One data for use in any (programming) language
+- [`ski.db`](https://github.com/opensport/ski.db) - free open public domain Ski Alpin/Alpine Ski data for use in any (programming) language
+- [`american-football.db`](https://github.com/opensport/american-football.db) - free open public domain American Football data for use in any (programming) language
## License
@@ -202,4 +202,4 @@ def self.all
end # module Fixtures
-end # module SportDb
+end # module SportDb
@@ -161,3 +161,4 @@ def import_fixtures( teams, fixtures )
$ rake -I ../world.db.ruby/lib -I ../sport.db.ruby/lib update
=end
+
View
@@ -31,10 +31,11 @@
require 'sportdb/title' ## fix - move to textutils gem
require 'sportdb/models/forward'
+require 'sportdb/models/world/city'
+require 'sportdb/models/world/country'
+require 'sportdb/models/world/continent'
+require 'sportdb/models/world/region'
require 'sportdb/models/badge'
-require 'sportdb/models/city'
-require 'sportdb/models/country'
-require 'sportdb/models/continent'
require 'sportdb/models/event'
require 'sportdb/models/event_team'
require 'sportdb/models/game'
@@ -43,17 +44,22 @@
require 'sportdb/models/group_team'
require 'sportdb/models/league'
require 'sportdb/models/person'
-require 'sportdb/models/prop'
require 'sportdb/models/race'
require 'sportdb/models/record'
-require 'sportdb/models/region'
require 'sportdb/models/roster'
require 'sportdb/models/round'
require 'sportdb/models/run'
require 'sportdb/models/season'
require 'sportdb/models/team'
require 'sportdb/models/track'
require 'sportdb/models/utils' # e.g. GameCursor
+
+## add backwards compatible namespace (delete later!)
+module SportDb
+ Models = Model
+end
+
+
require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models)
require 'sportdb/utils'
require 'sportdb/reader'
@@ -72,7 +78,6 @@
# todo/fix => remove from here and move into console.rb and tasks.rb
require 'sportdb/data/keys'
-require 'sportdb/data/fixtures'
require 'sportdb/data/models' # add convenience finders for known fixtures
@@ -114,7 +119,7 @@ def self.main
def self.create
CreateDb.new.up
- WorldDb::Models::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
+ WorldDb::Model::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
end
def self.read_setup( setup, include_path )
@@ -1,6 +1,6 @@
# encoding: utf-8
-module SportDb::Models
+module SportDb::Model
## add convenience finders to some model classes
@@ -38,6 +38,6 @@ def self.find_world_quali_america_2014!
end # class Event
-end # module SportDb::Models
+end # module SportDb::Model
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class Badge < ActiveRecord::Base
@@ -9,4 +9,5 @@ class Badge < ActiveRecord::Base
end # class Badge
-end # module SportDb::Models
+end # module SportDb::Model
+
View
@@ -1,14 +0,0 @@
-
-## todo: how to best extends city model?
-
-module WorldDb::Models
- class City
- has_many :teams, :class_name => 'SportDb::Models::Team', :foreign_key => 'city_id'
- end
-end # module WorldDb::Models
-
-
-## moved to models/forward
-# module SportDb::Models
-# City = WorldDb::Models::City
-# end # module SportDb::Models
@@ -1,18 +0,0 @@
-# encoding: utf-8
-
-## todo: how to best extends country model?
-
-module WorldDb::Models
-
- class Country
- has_many :teams, :class_name => 'SportDb::Models::Team', :foreign_key => 'country_id'
- has_many :leagues, :class_name => 'SportDb::Models::League', :foreign_key => 'country_id'
- end # class Country
-
-end # module WorldDb::Models
-
-
-## moved to models/forward
-# module SportDb::Models
-# Country = WorldDb::Models::Country
-# end # module SportDb::Models
@@ -1,6 +1,6 @@
# encoding: utf-8
-module SportDb::Models
+module SportDb::Model
class Event < ActiveRecord::Base
@@ -54,4 +54,4 @@ def known_teams_table
end # class Event
-end # module SportDb::Models
+end # module SportDb::Model
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class EventTeam < ActiveRecord::Base
@@ -9,4 +9,4 @@ class EventTeam < ActiveRecord::Base
end # class EventTeam
-end # module SportDb::Models
+end # module SportDb::Model
@@ -2,15 +2,15 @@
### forward references
## require first to resolve circular references
-module SportDb::Models
+module SportDb::Model
## todo: why? why not use include WorldDb::Models here???
- Continent = WorldDb::Models::Continent
- Country = WorldDb::Models::Country
- Region = WorldDb::Models::Region
- City = WorldDb::Models::City
- Prop = WorldDb::Models::Prop
+ Continent = WorldDb::Model::Continent
+ Country = WorldDb::Model::Country
+ Region = WorldDb::Model::Region
+ City = WorldDb::Model::City
+ Prop = WorldDb::Model::Prop
## nb: for now only team and league use worlddb tables
# e.g. with belongs_to assoc (country,region)
@@ -21,12 +21,12 @@ class League < ActiveRecord::Base ; end
end
-module WorldDb::Models
+module WorldDb::Model
# add alias? why? why not? # is there a better way?
# - just include SportDb::Models - why? why not?
# - just include once in loader??
- Team = SportDb::Models::Team
- League = SportDb::Models::League
+ Team = SportDb::Model::Team
+ League = SportDb::Model::League
end
View
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class Game < ActiveRecord::Base
@@ -86,53 +86,19 @@ def calc_winner
### getter/setters for deprecated attribs (score3,4,5,6) n national
- def score3
- score1et
- end
-
- def score4
- score2et
- end
-
- def score1ot
- score1et
- end
-
- def score2ot
- score2et
- end
-
- def score5
- score1p
- end
-
- def score6
- score2p
- end
+ def score3() score1et end
+ def score4() score2et end
+ def score1ot() score1et end
+ def score2ot() score2et end
+ def score5() score1p end
+ def score6() score2p end
- def score3=(value)
- self.score1et = value
- end
-
- def score4=(value)
- self.score2et = value
- end
-
- def score1ot=(value)
- self.score1et = value
- end
-
- def score2ot=(value)
- self.score2et = value
- end
-
- def score5=(value)
- self.score1p = value
- end
-
- def score6=(value)
- self.score2p = value
- end
+ def score3=(value) self.score1et = value end
+ def score4=(value) self.score2et = value end
+ def score1ot=(value) self.score1et = value end
+ def score2ot=(value) self.score2et = value end
+ def score5=(value) self.score1p = value end
+ def score6=(value) self.score2p = value end
@@ -391,4 +357,4 @@ def check_for_changes( new_attributes )
end # class Game
-end # module SportDb::Models
+end # module SportDb::Model
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class Goal < ActiveRecord::Base
@@ -9,4 +9,4 @@ class Goal < ActiveRecord::Base
end # class Goal
-end # module SportDb::Models
+end # module SportDb::Model
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class Group < ActiveRecord::Base
@@ -19,5 +19,5 @@ def add_teams_from_ary!( team_keys )
end # class Group
-end # module SportDb::Models
+end # module SportDb::Model
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class GroupTeam < ActiveRecord::Base
@@ -9,5 +9,5 @@ class GroupTeam < ActiveRecord::Base
end # class GroupTeam
-end # module SportDb::Models
+end # module SportDb::Model
@@ -1,4 +1,4 @@
-module SportDb::Models
+module SportDb::Model
class League < ActiveRecord::Base
@@ -10,7 +10,7 @@ class League < ActiveRecord::Base
has_many :events
has_many :seasons, :through => :events
- belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
+ belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
def self.create_or_update_from_values( new_attributes, values )
@@ -78,4 +78,4 @@ def self.create_from_ary!( leagues, more_values={} )
end # class League
-end # module SportDb::Models
+end # module SportDb::Model
Oops, something went wrong.

0 comments on commit cc94573

Please sign in to comment.