datafile 0.2.2 → 0.2.3

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: 42277d01f83ab3de43b42c67bd360d8e33a4ec96
4
- data.tar.gz: 0dbac9ee1f7dd981b82c661846b99fa4870fffb0
3
+ metadata.gz: d39f9bca67fd30470e40bd1b4985594eb2697326
4
+ data.tar.gz: 6e9fd82ae31c9507194dfd61e9d8112f66fdf0ea
5
5
  SHA512:
6
- metadata.gz: dfdf41d1c6110b5581b50e46b215bee08a92f0fefb5fbcdc8c7730f2bfdb00cd0f2c4934083996aed2a60a823a0b545240487e08e4909f6eb3612513fffb06db
7
- data.tar.gz: 8ab664e96b5fa743818a45c80411618dd5dd245cbaad81270a1b27471320b47cd4f0eb3181d33a0f98def76fb2c6ee8a264827b97acbbd4c0af148f44089738d
6
+ metadata.gz: 799c1587b0fea635d95d3cd28c0ed4fe0b6bfbdfbecf7b4805c126daded83e79791bdffc859adccb5c6321ccb4d336999ea915d9f2781ee4bd54cf14ff6fb6a3
7
+ data.tar.gz: ff6a33747c7ee59fd3bc6d41b1aa277b36982f4e14a5df9fa802f86b270d6bd366e914dfa9c36001a982e5e2cbd8d3a329e0ad7a3bc37a1f440ac6e7efdc318c
@@ -24,6 +24,16 @@ class Builder ## "simple" builder (one file, one datafile)
24
24
 
25
25
  attr_reader :datafile
26
26
 
27
+ ## "special" datasets
28
+
29
+ def inline( &block )
30
+ logger.info( "[builder] add inline script-block" )
31
+ @datafile.inlines << Inline.new( block )
32
+ end
33
+
34
+
35
+ ## "classic" standard datasets
36
+
27
37
  def beer( name, opts={} )
28
38
  logger.info( "[builder] add beer-dataset '#{name}'" )
29
39
  @datafile.datasets << BeerDataset.new( name, opts )
@@ -4,7 +4,7 @@ module Datafile
4
4
 
5
5
 
6
6
  ###
7
- ## check/todo: ename to BatchBuilder, MultiBuilder,etc - find better name - why, why not??
7
+ ## check/todo: rename to BatchBuilder, MultiBuilder,etc - find better name - why, why not??
8
8
 
9
9
  class BuilderEx
10
10
 
@@ -20,6 +20,29 @@ class Script
20
20
  end ## class Script
21
21
 
22
22
 
23
+ ### todo/check: use Script for Inline too?? - why, why not???
24
+ ### - use setup/pre/before and post/after or something??
25
+ ## - note: for now always is pre/before
26
+
27
+ class Inline
28
+ include LogUtils::Logging
29
+
30
+ def initialize( proc )
31
+ @proc = proc
32
+ end
33
+
34
+ def call
35
+ logger.info( "[inline] calling script block" )
36
+ @proc.call
37
+ end
38
+
39
+ def dump
40
+ puts " script: #{@proc.inspect}"
41
+ end
42
+ end ## class Inline
43
+
44
+
45
+
23
46
  class Datafile
24
47
 
25
48
  ## convenience method - use like Datafile.load_file()
@@ -45,6 +68,7 @@ class Datafile
45
68
  @opts = opts
46
69
  @datasets = []
47
70
  @scripts = [] ## calculation scripts (calc blocks)
71
+ @inlines = [] ## inline (setup) scripts (run before reading datasets)
48
72
 
49
73
  ## (target)name - return nil if noname (set/defined/assigned)
50
74
  @name = opts[:name] || nil
@@ -61,6 +85,7 @@ class Datafile
61
85
 
62
86
  attr_reader :datasets
63
87
  attr_reader :scripts ## calc(ulation) scripts (calc blocks)
88
+ attr_reader :inlines ## inline script blocks -- use before?? run before datasets
64
89
  attr_reader :name
65
90
  attr_reader :deps ## dep(endencies)
66
91
 
@@ -70,7 +95,7 @@ class Datafile
70
95
  def run
71
96
  logger.info( "[datafile] begin - run" )
72
97
  download # step 1 - download zips for datasets
73
- read # step 2 - read in datasets from zips
98
+ read # step 2 - read in datasets from zips - note: includes running inlines
74
99
  calc # step 3 - run calc(ulations) scripts
75
100
  logger.info( "[datafile] end - run" )
76
101
  end
@@ -4,7 +4,7 @@ module Datafile
4
4
 
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 2
7
- PATCH = 2
7
+ PATCH = 3
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -15,6 +15,11 @@ class FileWorker ## check: rename to FileDatafileWorker?? or FileDatafile -wh
15
15
  end
16
16
 
17
17
  def read
18
+ ## note: also run inlines (setup script) before
19
+ @datafile.inlines.each do |inline|
20
+ inline.call
21
+ end
22
+
18
23
  @datafile.datasets.each do |dataset|
19
24
  dataset.file_worker.read
20
25
  end
@@ -27,6 +32,11 @@ class FileWorker ## check: rename to FileDatafileWorker?? or FileDatafile -wh
27
32
  end
28
33
 
29
34
  def dump
35
+ ## also dump inlines
36
+ @datafile.inlines.each do |inline|
37
+ inline.dump
38
+ end
39
+
30
40
  @datafile.datasets.each do |dataset|
31
41
  dataset.file_worker.dump
32
42
  end
@@ -17,6 +17,11 @@ class ZipWorker ## check: rename to ZipDatafileWorker?? or ZipDatafile -why,
17
17
  end
18
18
 
19
19
  def read
20
+ ## note: also run inlines (setup script) before
21
+ @datafile.inlines.each do |inline|
22
+ inline.call
23
+ end
24
+
20
25
  @datafile.datasets.each do |dataset|
21
26
  dataset.zip_worker.read
22
27
  end
@@ -29,6 +34,10 @@ class ZipWorker ## check: rename to ZipDatafileWorker?? or ZipDatafile -why,
29
34
  end
30
35
 
31
36
  def dump
37
+ ## also dump inlines
38
+ @datafile.inlines.each do |inline|
39
+ inline.dump
40
+ end
32
41
  @datafile.datasets.each do |dataset|
33
42
  dataset.zip_worker.dump
34
43
  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.2.2
4
+ version: 0.2.3
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-14 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils