sportdb-market 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -2,20 +2,6 @@ History.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- data/at/2012_13/bl.rb
6
- data/at/2012_13/bl_betathome.txt
7
- data/at/2012_13/bl_tipp3.txt
8
- data/at/2012_13/cup.rb
9
- data/at/2012_13/cup_betathome.txt
10
- data/at/2012_13/cup_tipp3.txt
11
- data/cl/2012_13/cl.rb
12
- data/cl/2012_13/cl_betathome.txt
13
- data/cl/2012_13/cl_tipp3.txt
14
- data/euro/2012.rb
15
- data/euro/2012_tipico.txt
16
- data/euro/2012_tipp3.txt
17
- data/services.rb
18
- data/world/quali_tipp3.txt
19
5
  lib/sportdb/market.rb
20
6
  lib/sportdb/market/loader.rb
21
7
  lib/sportdb/market/models/event_quote.rb
data/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  sportdb plugin for market quotes (odds, etc)
4
4
 
5
- * [geraldb.github.com/sport.db](http://geraldb.github.com/sport.db)
5
+ * home :: [github.com/openbookie/sport.db-market](https://github.com/openbookie/sport.db-market)
6
+ * bugs :: [github.com/openbookie/sport.db-market/issues](https://github.com/openbookie/sport.db-market/issues)
7
+ * gem :: [rubygems.org/gems/sportdb-market](https://rubygems.org/gems/sportdb-market)
8
+ * rdoc :: [rubydoc.info/gems/sportdb-market](http://rubydoc.info/gems/sportdb-market)
9
+ * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
6
10
 
7
11
 
8
12
  ## Usage
data/Rakefile CHANGED
@@ -2,22 +2,16 @@ require 'pp'
2
2
  require 'hoe'
3
3
  require './lib/sportdb/market/version.rb'
4
4
 
5
- ## NB: plugin (hoe-manifest) not required; just used for future testing/development
6
- Hoe::plugin :manifest # more options for manifests (in the future; not yet)
7
5
 
8
- ###########
9
- #### NB: if you try this script at home
10
- # you need to create a (symbolic) link to the sport.db-market fixtures
11
- # e.g. use ln -s ../sport.db-market data or similar
12
6
 
13
7
  Hoe.spec 'sportdb-market' do
14
8
 
15
- self.version = SportDB::Market::VERSION
9
+ self.version = SportDb::Market::VERSION
16
10
 
17
11
  self.summary = 'sportdb plugin for market quotes (odds, etc)'
18
12
  self.description = summary
19
13
 
20
- self.urls = ['https://github.com/geraldb/sport.db.ruby-market']
14
+ self.urls = ['https://github.com/openbookie/sport.db-market']
21
15
 
22
16
  self.author = 'Gerald Bauer'
23
17
  self.email = 'opensport@googlegroups.com'
@@ -14,7 +14,7 @@ require 'sportdb/market/loader'
14
14
  require 'sportdb/market/reader'
15
15
 
16
16
 
17
- module SportDB::Market
17
+ module SportDb::Market
18
18
 
19
19
  def self.banner
20
20
  "sportdb-market #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
@@ -31,9 +31,9 @@ module SportDB::Market
31
31
  end
32
32
 
33
33
  def self.create
34
- CreateDB.up
34
+ CreateDb.up
35
35
  end
36
-
36
+
37
37
  def self.fixtures_rb # all builtin ruby fixtures; helper for covenience
38
38
  ['services',
39
39
  'at/2012_13/bl',
@@ -43,8 +43,8 @@ module SportDB::Market
43
43
  ]
44
44
  end
45
45
 
46
- def self.load_all
47
- load( fixtures_rb )
46
+ def self.load_all( include_path )
47
+ load( fixtures_rb, include_path )
48
48
  end
49
49
 
50
50
  def self.fixtures_txt
@@ -56,31 +56,31 @@ module SportDB::Market
56
56
  ['tipp3', 'cl.2012/13', 'cl/2012_13/cl_tipp3'],
57
57
  ## ['tipico', 'euro.2012', 'euro/2012_tipico'],
58
58
  ## ['tipp3', 'euro.2012', 'euro/2012_tipp3' ],
59
- ['tipp3', 'world.quali.euro.2012/13', 'world/quali_tipp3']]
59
+ ['tipp3', 'world.quali.europe.2014', 'world/quali_tipp3']]
60
60
  end
61
61
 
62
- def self.read_all
63
- read( fixtures_txt )
62
+ def self.read_all( include_path )
63
+ read( fixtures_txt, include_path )
64
64
  end
65
65
 
66
66
 
67
67
  # load built-in (that is, bundled within the gem) named seeds
68
68
  # - pass in an array of seed names e.g. [ 'cl/teams', 'cl/2012_13/cl' ] etc.
69
69
 
70
- def self.load( ary )
71
- loader = Loader.new
70
+ def self.load( ary, include_path )
71
+ loader = Loader.new( include_path )
72
72
  ary.each do |name|
73
- loader.load_builtin( name )
73
+ loader.load( name )
74
74
  end
75
75
  end
76
76
 
77
77
  # load built-in (that is, bundled within the gem) named plain text seeds
78
78
  # - pass in an array of pairs of event/seed names e.g. [['at.2012/13', 'at/2012_13/bl'], ['cl.2012/13', 'cl/2012_13/cl']] etc.
79
79
 
80
- def self.read( ary )
81
- reader = Reader.new
80
+ def self.read( ary, include_path )
81
+ reader = Reader.new( include_path )
82
82
  ary.each do |rec|
83
- reader.load_builtin( rec[0], rec[1], rec[2] ) # service_key, event_key, name
83
+ reader.load( rec[0], rec[1], rec[2] ) # service_key, event_key, name
84
84
  end
85
85
  end
86
86
 
@@ -89,7 +89,7 @@ module SportDB::Market
89
89
 
90
90
  ## make models available in sportdb module by default with namespace
91
91
  # e.g. lets you use Team instead of Models::Team
92
- include SportDB::Models
92
+ include SportDb::Models
93
93
 
94
94
  def run( args=[] )
95
95
  # for now delete all tables
@@ -108,8 +108,8 @@ module SportDB::Market
108
108
  Deleter.new.run
109
109
  end # method delete!
110
110
 
111
- end # module SportDB::Market
111
+ end # module SportDb::Market
112
112
 
113
113
 
114
114
  ## say hello
115
- puts SportDB::Market.banner
115
+ puts SportDb::Market.banner
@@ -1,35 +1,32 @@
1
- module SportDB::Market
1
+
2
+ module SportDb::Market
2
3
 
3
4
  class Loader
4
5
 
6
+ include LogUtils::Logging
7
+
5
8
  ## make models available in sportdb module by default with namespace
6
9
  # e.g. lets you use Team instead of Models::Team
7
- include SportDB::Models
10
+ include SportDb::Models
8
11
 
9
-
10
- def initialize( logger=nil )
11
- if logger.nil?
12
- @logger = Logger.new(STDOUT)
13
- @logger.level = Logger::INFO
14
- else
15
- @logger = logger
16
- end
12
+ attr_reader :include_path
13
+
14
+ def initialize( include_path )
15
+ @include_path
17
16
  end
18
17
 
19
- attr_reader :logger
20
-
21
- def load_builtin( name ) # load from gem (built-in)
22
- path = "#{SportDB::Market.data_path}/#{name}.rb"
23
-
18
+ def load( name ) # load from gem (built-in)
19
+ path = "#{@include_path}/#{name}.rb"
20
+
24
21
  puts "*** loading data '#{name}' (#{path})..."
25
22
 
26
23
  code = File.read_utf8( path )
27
-
24
+
28
25
  load_worker( code )
29
26
 
30
27
  ## for builtin fixtures use VERSION of gem
31
28
 
32
- Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.market.rb.#{SportDB::Market::VERSION}" )
29
+ ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.market.rb.#{SportDB::Market::VERSION}" )
33
30
  end
34
31
 
35
32
 
@@ -37,21 +34,23 @@ private
37
34
 
38
35
  ##
39
36
  # fix/todo: share helper w/ other readers
40
-
37
+ ##
38
+ ## todo/check/fix: check w/ version in textutils - remove here
39
+
41
40
  # helper
42
41
  # change at/2012_13/bl to at.2012/13.bl
43
42
  # or quali_2012_13_europe_c to quali.2012/13.europe.c
44
-
45
- def fixture_name_to_prop_key( name )
46
- prop_key = name.gsub( '/', '.' )
47
- prop_key = prop_key.gsub( /(\d{4})_(\d{2})/, '\1/\2' ) # 2012_13 => 2012/13
48
- prop_key = prop_key.gsub( '_', '.' )
49
- prop_key
50
- end
43
+ #
44
+ # def fixture_name_to_prop_key( name )
45
+ # prop_key = name.gsub( '/', '.' )
46
+ # prop_key = prop_key.gsub( /(\d{4})_(\d{2})/, '\1/\2' ) # 2012_13 => 2012/13
47
+ # prop_key = prop_key.gsub( '_', '.' )
48
+ # prop_key
49
+ # end
51
50
 
52
51
  def load_worker( code )
53
52
  self.class_eval( code )
54
53
  end
55
-
54
+
56
55
  end # class Loader
57
- end # module SportDB::Market
56
+ end # module SportDb::Market
@@ -1,7 +1,7 @@
1
1
 
2
- ## NB: just use namespace SportDB::Models (not SportDB::Models::Market)
2
+ # NB: just use namespace SportDb::Models (not SportDb::Models::Market)
3
3
 
4
- module SportDB::Models
4
+ module SportDb::Models
5
5
 
6
6
  class EventQuote < ActiveRecord::Base
7
7
 
@@ -24,4 +24,4 @@ class EventQuote < ActiveRecord::Base
24
24
 
25
25
  end # class EventQuote
26
26
 
27
- end # module SportDB::Models
27
+ end # module SportDb::Models
@@ -1,10 +1,10 @@
1
1
 
2
- ## NB: just use namespace SportDB::Models (not SportDB::Models::Market)
2
+ # NB: just use namespace SportDb::Models (not SportDb::Models::Market)
3
3
 
4
- module SportDB::Models
4
+ module SportDb::Models
5
5
 
6
6
  ################################
7
- ## extend Game w/ quotes etc.
7
+ # extend Game w/ quotes etc.
8
8
 
9
9
  class Game
10
10
 
@@ -12,4 +12,4 @@ class Game
12
12
 
13
13
  end # class Game
14
14
 
15
- end # module SportDB::Models
15
+ end # module SportDb::Models
@@ -1,7 +1,7 @@
1
1
 
2
- ## NB: just use namespace SportDB::Models (not SportDB::Models::Market)
2
+ # NB: just use namespace SportDb::Models (not SportDb::Models::Market)
3
3
 
4
- module SportDB::Models
4
+ module SportDb::Models
5
5
 
6
6
  class GroupQuote < ActiveRecord::Base
7
7
 
@@ -23,4 +23,4 @@ class GroupQuote < ActiveRecord::Base
23
23
 
24
24
  end # class GroupQuote
25
25
 
26
- end # module SportDB::Models
26
+ end # module SportDb::Models
@@ -1,6 +1,7 @@
1
- ## NB: just use namespace SportDB::Models (not SportDB::Models::Market)
2
1
 
3
- module SportDB::Models
2
+ ## NB: just use namespace SportDb::Models (not SportDb::Models::Market)
3
+
4
+ module SportDb::Models
4
5
 
5
6
  class Quote < ActiveRecord::Base
6
7
 
@@ -29,7 +30,7 @@ class Quote < ActiveRecord::Base
29
30
  end # each games
30
31
  end
31
32
 
32
-
33
+
33
34
  end # class Quote
34
35
 
35
- end # module SportDB::Models
36
+ end # module SportDb::Models
@@ -1,7 +1,7 @@
1
1
 
2
- ## NB: just use namespace SportDB::Models (not SportDB::Models::Market)
2
+ # NB: just use namespace SportDb::Models (not SportDb::Models::Market)
3
3
 
4
- module SportDB::Models
4
+ module SportDb::Models
5
5
 
6
6
  class Service < ActiveRecord::Base
7
7
 
@@ -10,4 +10,4 @@ class Service < ActiveRecord::Base
10
10
 
11
11
  end # class Service
12
12
 
13
- end # module SportDB::Models
13
+ end # module SportDb::Models
@@ -1,44 +1,32 @@
1
1
 
2
- module SportDB::Market
2
+ module SportDb::Market
3
3
 
4
4
  ### load quotes from plain text files
5
5
 
6
6
  class Reader
7
7
 
8
+ include LogUtils::Logging
9
+
8
10
  ## make models available in sportdb module by default with namespace
9
11
  # e.g. lets you use Team instead of Models::Team
10
- include SportDB::Models
11
-
12
+ include SportDb::Models
13
+
14
+ attr_reader :include_path
12
15
 
13
- def initialize
14
- @logger = Logger.new(STDOUT)
15
- @logger.level = Logger::INFO
16
+ def initialize( include_path )
17
+ @include_path
16
18
  end
17
19
 
18
- attr_reader :logger
19
-
20
- def load_with_include_path( service_key, event_key, name, include_path ) # load from file system
21
- path = "#{include_path}/#{name}.txt"
20
+ def load( service_key, event_key, name )
21
+ path = "#{@include_path}/#{name}.txt"
22
22
 
23
23
  puts "*** parsing data '#{name}' (#{path})..."
24
24
 
25
- reader = LineReader.new( logger, path )
26
-
27
- load_worker( service_key, event_key, reader )
28
-
29
- Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
30
- end
31
-
32
- def load_builtin( service_key, event_key, name ) # load from gem (built-in)
33
- path = "#{SportDB::Market.data_path}/#{name}.txt"
25
+ reader = LineReader.new( path )
34
26
 
35
- puts "*** parsing data '#{name}' (#{path})..."
36
-
37
- reader = LineReader.new( logger, path )
38
-
39
27
  load_worker( service_key, event_key, reader )
40
28
 
41
- Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.market.txt.#{SportDB::Market::VERSION}" )
29
+ ## Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
42
30
  end
43
31
 
44
32
  private
@@ -62,7 +50,7 @@ private
62
50
  end # method load
63
51
 
64
52
 
65
- include SportDB::FixtureHelpers
53
+ include SportDb::FixtureHelpers
66
54
 
67
55
 
68
56
  def find_quotes!( line )
@@ -173,4 +161,4 @@ private
173
161
 
174
162
  end # class Reader
175
163
 
176
- end # module SportDB::Market
164
+ end # module SportDb::Market
@@ -1,12 +1,12 @@
1
1
 
2
- module SportDB::Market
2
+ module SportDb::Market
3
3
 
4
4
 
5
- class CreateDB
5
+ class CreateDb
6
6
 
7
7
  ## make models available in sportdb module by default with namespace
8
8
  # e.g. lets you use Team instead of Models::Team
9
- include SportDB::Models
9
+ include SportDb::Models
10
10
 
11
11
 
12
12
  def self.up
@@ -49,11 +49,11 @@ end
49
49
 
50
50
  end # block Schema.define
51
51
 
52
- Prop.create!( key: 'db.schema.sport.market.version', value: SportDB::Market::VERSION )
52
+ Prop.create!( key: 'db.schema.sport.market.version', value: SportDb::Market::VERSION )
53
53
 
54
54
  end # method self.up
55
55
 
56
- end # class CreateDB
56
+ end # class CreateDb
57
57
 
58
58
 
59
- end # module SportDB::Market
59
+ end # module SportDb::Market
@@ -1,6 +1,6 @@
1
1
 
2
- module SportDB ; end # forward reference (for hoe require)
2
+ module SportDb ; end # forward reference (for hoe require)
3
3
 
4
- module SportDB::Market
5
- VERSION = '0.3.0'
4
+ module SportDb::Market
5
+ VERSION = '0.4.0'
6
6
  end
metadata CHANGED
@@ -1,79 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sportdb-market
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gerald Bauer
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-12-04 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-09-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rdoc
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &71884950 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 19
29
- segments:
30
- - 3
31
- - 10
32
- version: "3.10"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.10'
33
22
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *71884950
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ requirement: &71884600 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
29
+ requirements:
41
30
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 1
44
- segments:
45
- - 3
46
- - 3
47
- version: "3.3"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.3'
48
33
  type: :development
49
- version_requirements: *id002
34
+ prerelease: false
35
+ version_requirements: *71884600
50
36
  description: sportdb plugin for market quotes (odds, etc)
51
37
  email: opensport@googlegroups.com
52
38
  executables: []
53
-
54
39
  extensions: []
55
-
56
- extra_rdoc_files:
40
+ extra_rdoc_files:
57
41
  - Manifest.txt
58
- files:
42
+ files:
59
43
  - History.md
60
44
  - Manifest.txt
61
45
  - README.md
62
46
  - Rakefile
63
- - data/at/2012_13/bl.rb
64
- - data/at/2012_13/bl_betathome.txt
65
- - data/at/2012_13/bl_tipp3.txt
66
- - data/at/2012_13/cup.rb
67
- - data/at/2012_13/cup_betathome.txt
68
- - data/at/2012_13/cup_tipp3.txt
69
- - data/cl/2012_13/cl.rb
70
- - data/cl/2012_13/cl_betathome.txt
71
- - data/cl/2012_13/cl_tipp3.txt
72
- - data/euro/2012.rb
73
- - data/euro/2012_tipico.txt
74
- - data/euro/2012_tipp3.txt
75
- - data/services.rb
76
- - data/world/quali_tipp3.txt
77
47
  - lib/sportdb/market.rb
78
48
  - lib/sportdb/market/loader.rb
79
49
  - lib/sportdb/market/models/event_quote.rb
@@ -85,41 +55,31 @@ files:
85
55
  - lib/sportdb/market/schema.rb
86
56
  - lib/sportdb/market/version.rb
87
57
  - lib/sportdb_plugin.rb
88
- homepage: https://github.com/geraldb/sport.db.ruby-market
89
- licenses:
58
+ homepage: https://github.com/openbookie/sport.db-market
59
+ licenses:
90
60
  - Public Domain
91
61
  post_install_message:
92
- rdoc_options:
62
+ rdoc_options:
93
63
  - --main
94
64
  - README.md
95
- require_paths:
65
+ require_paths:
96
66
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
67
+ required_ruby_version: !ruby/object:Gem::Requirement
98
68
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 55
103
- segments:
104
- - 1
105
- - 9
106
- - 2
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
107
72
  version: 1.9.2
108
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
74
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
117
79
  requirements: []
118
-
119
80
  rubyforge_project: sportdb-market
120
- rubygems_version: 1.8.24
81
+ rubygems_version: 1.8.17
121
82
  signing_key:
122
83
  specification_version: 3
123
84
  summary: sportdb plugin for market quotes (odds, etc)
124
85
  test_files: []
125
-