datafile 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +2 -0
- data/data/football.txt +45 -0
- data/lib/datafile.rb +8 -0
- data/lib/datafile/datasets/dataset.rb +49 -1
- data/lib/datafile/version.rb +1 -1
- data/test/datafile2/at.rb +2 -2
- data/test/test_builder.rb +3 -3
- data/test/test_football_dataset.rb +27 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8afa4e20859ba348f32a1d45f7d385623146099d
|
4
|
+
data.tar.gz: 276cbc2838cd98a227af23ae3bced081b584ed05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c59a27aa7fc14e30cc48cc0a16252eac83d08ccbea25e2008aa4f8bcf9c06fcff3a918ca3f831334532e55cda699466acb8e3d513ef5d41b2a973d9d001f2cb
|
7
|
+
data.tar.gz: a7ab8bf94cc1e1feb28ecdb3d2bb9e6a9de90c948a092501650726f18b08e8eaa1874e920fc966a6ea298c9b2bb4470110400f4b22e7f521f2d713497041e42b
|
data/Manifest.txt
CHANGED
@@ -2,6 +2,7 @@ HISTORY.md
|
|
2
2
|
Manifest.txt
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
|
+
data/football.txt
|
5
6
|
lib/datafile.rb
|
6
7
|
lib/datafile/builder.rb
|
7
8
|
lib/datafile/builder2.rb
|
@@ -26,3 +27,4 @@ test/test_builder.rb
|
|
26
27
|
test/test_builder2.rb
|
27
28
|
test/test_file_dataset_registry.rb
|
28
29
|
test/test_file_worker.rb
|
30
|
+
test/test_football_dataset.rb
|
data/data/football.txt
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
##########################################################
|
2
|
+
# known football.db (openfootball) datasets (repos)
|
3
|
+
|
4
|
+
#####################
|
5
|
+
# -- Basics
|
6
|
+
|
7
|
+
openfootball/stadiums
|
8
|
+
openfootball/players
|
9
|
+
openfootball/assocs
|
10
|
+
|
11
|
+
##########################
|
12
|
+
# -- National Teams
|
13
|
+
|
14
|
+
openfootball/national-teams
|
15
|
+
|
16
|
+
openfootball/world-cup
|
17
|
+
openfootball/euro-cup
|
18
|
+
openfootball/africa-cup
|
19
|
+
openfootball/north-america-gold-cup
|
20
|
+
openfootball/copa-america
|
21
|
+
openfootball/confed-cup
|
22
|
+
|
23
|
+
#########################
|
24
|
+
# -- Clubs
|
25
|
+
|
26
|
+
openfootball/clubs
|
27
|
+
|
28
|
+
openfootball/eng-england
|
29
|
+
openfootball/at-austria
|
30
|
+
openfootball/de-deutschland
|
31
|
+
openfootball/es-espana
|
32
|
+
openfootball/it-italy
|
33
|
+
openfootball/fr-france
|
34
|
+
openfootball/ch-confoederatio-helvetica
|
35
|
+
openfootball/europe-champions-league
|
36
|
+
|
37
|
+
openfootball/major-league-soccer
|
38
|
+
openfootball/mx-mexico
|
39
|
+
openfootball/north-america-champions-league
|
40
|
+
|
41
|
+
openfootball/br-brazil
|
42
|
+
openfootball/copa-sudamericana
|
43
|
+
openfootball/copa-libertadores
|
44
|
+
|
45
|
+
openfootball/club-world-cup
|
data/lib/datafile.rb
CHANGED
@@ -26,6 +26,14 @@ require 'datafile/builder'
|
|
26
26
|
require 'datafile/builder2'
|
27
27
|
|
28
28
|
|
29
|
+
module Datafile
|
30
|
+
def self.data_path
|
31
|
+
"#{root}/data"
|
32
|
+
end
|
33
|
+
end # module Datafile
|
34
|
+
|
35
|
+
|
36
|
+
|
29
37
|
# say hello
|
30
38
|
puts Datafile.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
|
31
39
|
|
@@ -1,5 +1,22 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
|
4
|
+
############
|
5
|
+
# fix: move global method to ??
|
6
|
+
|
7
|
+
def read_known_datasets( path )
|
8
|
+
ary = []
|
9
|
+
lines = File.read( path ) ### fix: use File.read_utf8 ??
|
10
|
+
lines.each_line do |line|
|
11
|
+
## skip blank and comments lines
|
12
|
+
next if /^\s*#/ =~ line || /^\s*$/ =~ line
|
13
|
+
|
14
|
+
ary << line.strip
|
15
|
+
end
|
16
|
+
ary
|
17
|
+
end
|
18
|
+
|
19
|
+
|
3
20
|
module Datafile
|
4
21
|
|
5
22
|
class Dataset
|
@@ -29,15 +46,46 @@ class WorldDataset < Dataset
|
|
29
46
|
def file_worker() WorldFileDataset.new( self ); end
|
30
47
|
end # class WorldDataset
|
31
48
|
|
49
|
+
|
50
|
+
|
32
51
|
class FootballDataset < Dataset
|
33
|
-
|
52
|
+
|
53
|
+
@@known_football_datasets = nil
|
54
|
+
|
55
|
+
def self.known_datasets
|
56
|
+
## return array of known datasets
|
57
|
+
### todo/fix - use \\= idiom - why, why not??
|
58
|
+
if @@known_football_datasets.nil?
|
59
|
+
@@known_football_datasets = read_known_datasets( "#{::Datafile.data_path}/football.txt" )
|
60
|
+
end
|
61
|
+
@@known_football_datasets
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def initialize( name_easy, opts={} )
|
66
|
+
|
67
|
+
## check if name include slash (e.g. /)
|
68
|
+
## - if not auto-add openfootball/ (default)
|
69
|
+
if name_easy.index( '/' ).nil?
|
70
|
+
name = "openfootball/#{name_easy}"
|
71
|
+
else
|
72
|
+
name = name_easy ## just pass through for now
|
73
|
+
end
|
74
|
+
|
34
75
|
super( name, opts )
|
76
|
+
|
77
|
+
### check for known datasets; warn: if not known (might be a typo)
|
78
|
+
unless FootballDataset.known_datasets.include?( name )
|
79
|
+
## todo: use logger - why, why not??
|
80
|
+
puts "*** warn: unknown football dataset '#{name}', typo ???"
|
81
|
+
end
|
35
82
|
end
|
36
83
|
|
37
84
|
def zip_worker() FootballZipDataset.new( self ); end
|
38
85
|
def file_worker() FootballFileDataset.new( self ); end
|
39
86
|
end # class FootballDataset
|
40
87
|
|
88
|
+
|
41
89
|
class BeerDataset < Dataset
|
42
90
|
def initialize( name, opts={} )
|
43
91
|
super( name, opts )
|
data/lib/datafile/version.rb
CHANGED
data/test/datafile2/at.rb
CHANGED
@@ -3,12 +3,12 @@ puts "[eval] self in top = #{self.class.name}"
|
|
3
3
|
|
4
4
|
task :at => :importbuiltin do
|
5
5
|
puts "[eval] self in data (enter) = #{self.class.name}"
|
6
|
-
football '
|
6
|
+
football 'at-austria'
|
7
7
|
puts "[eval] self in data (leave) = #{self.class.name}"
|
8
8
|
end
|
9
9
|
|
10
10
|
task :at_2014_15 => :importbuiltin do
|
11
|
-
football '
|
11
|
+
football 'at-austria', setup: '2014-15'
|
12
12
|
end
|
13
13
|
|
14
14
|
|
data/test/test_builder.rb
CHANGED
@@ -15,12 +15,12 @@ class TestBuilder < MiniTest::Test
|
|
15
15
|
|
16
16
|
world 'openmundi/world.db', setup: 'countries'
|
17
17
|
|
18
|
-
football '
|
18
|
+
football 'national-teams' ## NOTE: default is setup: 'all'
|
19
19
|
|
20
20
|
### todo/fix: download archive only once(!!) even if included more than once
|
21
|
-
## football '
|
21
|
+
## football 'world-cup', setup: '2014_quali'
|
22
22
|
|
23
|
-
football '
|
23
|
+
football 'world-cup', setup: '2014'
|
24
24
|
|
25
25
|
## more comments
|
26
26
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_football_dataset.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestFootballDataset < MiniTest::Test
|
11
|
+
|
12
|
+
def test_names
|
13
|
+
pp Datafile::FootballDataset.known_datasets
|
14
|
+
|
15
|
+
at = Datafile::FootballDataset.new( 'at-austria' )
|
16
|
+
at2 = Datafile::FootballDataset.new( 'openfootball/at-austria' )
|
17
|
+
xxx = Datafile::FootballDataset.new( 'xxx' )
|
18
|
+
xxx2 = Datafile::FootballDataset.new( 'openfootball/xxx' )
|
19
|
+
|
20
|
+
assert_equal 'openfootball/at-austria', at.name
|
21
|
+
assert_equal 'openfootball/at-austria', at2.name
|
22
|
+
|
23
|
+
assert_equal 'openfootball/xxx', xxx.name
|
24
|
+
assert_equal 'openfootball/xxx', xxx2.name
|
25
|
+
end
|
26
|
+
|
27
|
+
end # class TestFootballDataset
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datafile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- Manifest.txt
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
+
- data/football.txt
|
97
98
|
- lib/datafile.rb
|
98
99
|
- lib/datafile/builder.rb
|
99
100
|
- lib/datafile/builder2.rb
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- test/test_builder2.rb
|
119
120
|
- test/test_file_dataset_registry.rb
|
120
121
|
- test/test_file_worker.rb
|
122
|
+
- test/test_football_dataset.rb
|
121
123
|
homepage: https://github.com/rubylibs/datafile
|
122
124
|
licenses:
|
123
125
|
- Public Domain
|
@@ -148,4 +150,5 @@ test_files:
|
|
148
150
|
- test/test_builder2.rb
|
149
151
|
- test/test_builder.rb
|
150
152
|
- test/test_file_dataset_registry.rb
|
153
|
+
- test/test_football_dataset.rb
|
151
154
|
- test/test_file_worker.rb
|