datafile 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8782dd8b936ebd15c057be430754b81935000a53
4
- data.tar.gz: 6761a2f36be11909f9caf6ffbbe4645e2e30f440
3
+ metadata.gz: 26b6312f588cc22d664d552ca2f01e6e11482f3d
4
+ data.tar.gz: 3afcbe6af0340685f5358a9f0713a4631a59e5ee
5
5
  SHA512:
6
- metadata.gz: df27e034db8d08fc858bef78b83c6ae42b702879d1bb86edadd3fc514e43db4b0152b29a8fc48a4e8759fa2fb059189f61500f80edc1722cb1ef29ce3fb97c6e
7
- data.tar.gz: 8b59c770f07f82a022c17b9b291ed09321db17a2b0a3f59ecd22683ba16b01adaa406e27d5051c5f7c2e91e0b72da267dc02cb986c3ef5ff12f3d589c2321fe6
6
+ metadata.gz: 78dddc2a46795eb19b25819c9cc95e3d5202b81dcd11851ddbce92ac7efd883815495a6224546baaa53fbefaeb944abbdc686645b16ac3c9464bec7ccb491f5c
7
+ data.tar.gz: 48ae309c57d5a09b77d81d40e9542473427928c26ffabb28b9e4e7f18af941de1196f0f17a43440d9456a155111ddec61c9dfef7ae1854a3e8cb2c25ecbbc30c
@@ -15,6 +15,5 @@ require 'datafile/datafile'
15
15
  require 'datafile/builder'
16
16
 
17
17
 
18
-
19
- puts Datafile.banner # say hello
20
-
18
+ # say hello
19
+ puts Datafile.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
@@ -19,36 +19,120 @@ class Datafile
19
19
  def self.load( code )
20
20
  builder = Builder.new
21
21
  builder.instance_eval( code )
22
- builder.datafile # note: return datafile (of course, NOT the builder)
22
+
23
+ # Note: return datafile (of course, NOT the builder)
24
+ # if you want a builder use Datafile::Builder ;-)
25
+ builder.datafile
23
26
  end
24
27
 
25
28
 
26
- def initialize()
29
+ def initialize
27
30
  @datasets = []
28
31
  end
29
32
 
30
33
 
31
- def run()
34
+ def run
32
35
  logger.info( "[datafile] begin - run" )
33
36
  download() # step 1 - download zips for datasets
34
37
  read() # step 2 - read in datasets from zips
35
38
  logger.info( "[datafile] end - run" )
36
39
  end
37
40
 
38
- def download()
41
+
42
+
43
+ def download
39
44
  logger.info( "[datafile] dowload" )
40
45
  @datasets.each do |dataset|
41
46
  dataset.download()
42
47
  end
43
48
  end
44
49
 
45
- def read()
50
+ def download_world ## only dl world datasets (skip all others)
51
+ logger.info( "[datafile] dowload world datasets" )
52
+ @datasets.each do |dataset|
53
+ if dataset.kind_of? WorldDataset
54
+ dataset.download()
55
+ else
56
+ # skip all others
57
+ end
58
+ end
59
+ end
60
+
61
+ def download_beer ## only dl beer datasets (skip all others)
62
+ logger.info( "[datafile] dowload beer datasets" )
63
+ @datasets.each do |dataset|
64
+ if dataset.kind_of? BeerDataset
65
+ dataset.download()
66
+ else
67
+ # skip all others
68
+ end
69
+ end
70
+ end
71
+
72
+ def download_football ## only dl football datasets (skip all others)
73
+ logger.info( "[datafile] dowload football datasets" )
74
+ @datasets.each do |dataset|
75
+ if dataset.kind_of? FootballDataset
76
+ dataset.download()
77
+ else
78
+ # skip all others
79
+ end
80
+ end
81
+ end
82
+
83
+
84
+
85
+
86
+ def read
46
87
  logger.info( "[datafile] read" )
47
88
  @datasets.each do |dataset|
48
89
  dataset.read()
49
90
  end
50
91
  end
51
92
 
93
+ def read_world
94
+ logger.info( "[datafile] read world datasets" )
95
+ @datasets.each do |dataset|
96
+ if dataset.kind_of? WorldDataset
97
+ dataset.read()
98
+ else
99
+ # skip all others
100
+ end
101
+ end
102
+ end
103
+
104
+ def read_beer
105
+ logger.info( "[datafile] read beer datasets" )
106
+ @datasets.each do |dataset|
107
+ if dataset.kind_of? BeerDataset
108
+ dataset.read()
109
+ else
110
+ # skip all others
111
+ end
112
+ end
113
+ end
114
+
115
+ def read_football
116
+ logger.info( "[datafile] read football datasets" )
117
+ @datasets.each do |dataset|
118
+ if dataset.kind_of? FootballDataset
119
+ dataset.read()
120
+ else
121
+ # skip all others
122
+ end
123
+ end
124
+ end
125
+
126
+
127
+ def dump
128
+ ## for debugging dump datasets (note: will/might also check if zip exits)
129
+ logger.info( "[datafile] dump datasets (for debugging)" )
130
+ @datasets.each do |dataset|
131
+ dataset.dump()
132
+ end
133
+ end
134
+
135
+
52
136
  end # class Datafile
53
137
  end # module Datafile
54
138
 
@@ -10,33 +10,34 @@ class Dataset
10
10
  @opts = opts
11
11
  end
12
12
 
13
- def setup()
13
+
14
+ def setup
14
15
  value = @opts[:setup] || 'all'
15
16
  "setups/#{value}"
16
17
  end
17
18
 
18
- def remote_zip_url() # remote zip url
19
+ def remote_zip_url # remote zip url
19
20
  ### note: use http:// for now - lets us use (personal proxy NOT working w/ https) for now
20
21
  ## "https://github.com/#{@name}/archive/master.zip"
21
22
  "http://github.com/#{@name}/archive/master.zip"
22
23
  end
23
24
 
24
- def local_zip_name()
25
+ def local_zip_name
25
26
  ### note: replace / in name w/ --I--
26
27
  ## e.g. flatten the filename, that is, do NOT include any folders
27
28
  @name.gsub('/', '--I--') # note: will NOT include/return .zip extension
28
29
  end
29
30
 
30
- def local_zip_root()
31
+ def local_zip_root
31
32
  "./tmp"
32
33
  end
33
34
 
34
- def local_zip_path() # local zip path
35
+ def local_zip_path # local zip path
35
36
  "#{local_zip_root}/#{local_zip_name}.zip"
36
37
  end
37
38
 
38
39
 
39
- def download()
40
+ def download
40
41
  logger.info( "download dataset '#{@name}'" )
41
42
  logger.info( " from '#{remote_zip_url}'" )
42
43
  logger.info( " to '#{local_zip_path}'..." )
@@ -44,6 +45,20 @@ class Dataset
44
45
  download_blob( remote_zip_url, local_zip_path )
45
46
  end
46
47
 
48
+
49
+ def dump
50
+ ## for debuggin dump dataset (also check if zip exits)
51
+ puts "dataset '#{@name}' opts=#{@opts.to_json}" ## use opts.inspect instead of to_json - why? why not?
52
+ puts " local '#{local_zip_name}' (#{local_zip_path})"
53
+ if File.exist?( local_zip_path )
54
+ puts " size: #{File.size(local_zip_path)} bytes"
55
+ else
56
+ puts " (file not found)"
57
+ end
58
+ puts " remote '#{remote_zip_url}'"
59
+ end
60
+
61
+
47
62
  private
48
63
  ####
49
64
  # download tasks for zips
@@ -4,7 +4,7 @@ module Datafile
4
4
 
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 1
7
- PATCH = 1
7
+ PATCH = 2
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -32,6 +32,8 @@ EOS
32
32
  ## datafile.run
33
33
  ## datafile.download
34
34
  ## datafile.read
35
+
36
+ datafile.dump
35
37
 
36
38
  assert true # if we get here - test success
37
39
  end
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils