laborantin 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/laborantin.rb +1 -1
- data/lib/laborantin/core/environment.rb +32 -28
- data/lib/laborantin/core/scenario.rb +5 -5
- metadata +6 -4
data/Rakefile
CHANGED
data/lib/laborantin.rb
CHANGED
@@ -28,7 +28,7 @@ require File.join(File.dirname(__FILE__), 'laborantin', 'core', 'environment')
|
|
28
28
|
require File.join(File.dirname(__FILE__), 'laborantin', 'core', 'monkey_patches')
|
29
29
|
|
30
30
|
module Laborantin
|
31
|
-
VERSION = '0.0.
|
31
|
+
VERSION = '0.0.13'
|
32
32
|
AUTHORS = ['Lucas Di Cioccio']
|
33
33
|
WEBSITE = 'http://dicioccio.fr'
|
34
34
|
LICENSE = 'GNU GPL version 3'
|
@@ -26,7 +26,7 @@ require 'logger'
|
|
26
26
|
require 'fileutils'
|
27
27
|
|
28
28
|
module Laborantin
|
29
|
-
|
29
|
+
|
30
30
|
# An Environment represents the surrounding of an experiment. Basically, it
|
31
31
|
# should only contains things that are hard to change during an experiment.
|
32
32
|
# Let's say you have two computers, A and B. A can be a server and B a client
|
@@ -45,16 +45,16 @@ module Laborantin
|
|
45
45
|
def self.scan_resdir(dir)
|
46
46
|
ret = []
|
47
47
|
Dir.entries(dir).each do |f|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
envklass = Laborantin::Environment.all.find{|e| e.name.duck_case == f}
|
49
|
+
if envklass
|
50
|
+
Dir.entries(envklass.envdir).each do |e|
|
51
|
+
if e =~ /\d+-\w+-\d+_\d+-\d+-\d+/
|
52
|
+
env = envklass.new #XXX don't prepare! it hence don't overwrite logs
|
53
|
+
env.rundir = File.join(envklass.envdir, e)
|
54
|
+
ret << env
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
58
|
end
|
59
59
|
ret
|
60
60
|
end
|
@@ -77,46 +77,46 @@ module Laborantin
|
|
77
77
|
|
78
78
|
# Prepares attributes' default values whenever a subclass is created.
|
79
79
|
def inherited(klass)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
klass.verifications = []
|
81
|
+
klass.description = ''
|
82
|
+
klass.hooks = {:setup => [], :teardown => []}
|
83
|
+
@@all << klass
|
84
84
|
end
|
85
85
|
|
86
86
|
# Registers new verifiers.
|
87
87
|
def verify(*args)
|
88
|
-
|
88
|
+
self.verifications = [*args].flatten
|
89
89
|
end
|
90
90
|
|
91
91
|
# Sets the description.
|
92
92
|
def describe(str)
|
93
|
-
|
93
|
+
self.description = str
|
94
94
|
end
|
95
95
|
|
96
96
|
# Registers setup hooks, called before any scenario is instantiated.
|
97
97
|
def setup(*args)
|
98
|
-
|
98
|
+
self.hooks[:setup] = [*args].flatten
|
99
99
|
end
|
100
100
|
|
101
101
|
# Registers teardown hooks, called after every scenarii has been
|
102
102
|
# performed and analyzed.
|
103
103
|
def teardown(*args)
|
104
|
-
|
104
|
+
self.hooks[:teardown] = [*args].flatten
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
def to_s
|
108
|
-
|
108
|
+
"#{self.name}:\n\t#{self.description}"
|
109
109
|
end
|
110
110
|
|
111
111
|
# Returns all the known subklasses of Environment.
|
112
112
|
def all
|
113
|
-
|
113
|
+
@@all
|
114
114
|
end
|
115
115
|
|
116
116
|
# The path where the results for instance of a subklass of Environment
|
117
117
|
# are stored (needs the Laborantin.resultdir).
|
118
118
|
def envdir
|
119
|
-
|
119
|
+
File.join(Laborantin.resultdir, self.name.duck_case)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -142,6 +142,10 @@ module Laborantin
|
|
142
142
|
self.class.verifications.find{|v| not send(v)}.nil?
|
143
143
|
end
|
144
144
|
|
145
|
+
def logfile_path
|
146
|
+
File.join(rundir, 'environment.log')
|
147
|
+
end
|
148
|
+
|
145
149
|
# In the following order:
|
146
150
|
# * Creates the envdir if needed.
|
147
151
|
# * Adds some loggers.
|
@@ -151,7 +155,7 @@ module Laborantin
|
|
151
155
|
#
|
152
156
|
def prepare!
|
153
157
|
FileUtils.mkdir_p(rundir) #TODO: ensure unicity
|
154
|
-
@loggers << Logger.new(
|
158
|
+
@loggers << Logger.new(logfile_path)
|
155
159
|
@loggers << Logger.new(STDOUT)
|
156
160
|
log(self.class.description, :info) unless self.class.description.empty?
|
157
161
|
log "Directories prepared"
|
@@ -174,6 +178,10 @@ module Laborantin
|
|
174
178
|
Laborantin::Scenario.scan_env(self)
|
175
179
|
end
|
176
180
|
|
181
|
+
def date_str
|
182
|
+
date.strftime("%Y-%h-%d_%H-%M-%S")
|
183
|
+
end
|
184
|
+
|
177
185
|
private
|
178
186
|
|
179
187
|
def call_hooks(name)
|
@@ -181,9 +189,5 @@ module Laborantin
|
|
181
189
|
self.class.hooks[name].each{|sym| send sym}
|
182
190
|
end
|
183
191
|
|
184
|
-
def date_str
|
185
|
-
date.strftime("%Y-%h-%d_%H-%M-%S")
|
186
|
-
end
|
187
|
-
|
188
192
|
end # class
|
189
193
|
end # module
|
@@ -58,7 +58,7 @@ module Laborantin
|
|
58
58
|
scs << scenar
|
59
59
|
scenar.rundir = File.join(scklass.scenardir(env), r)
|
60
60
|
tst, params = YAML.load_file(File.join(scenar.rundir, 'config.yaml'))
|
61
|
-
|
61
|
+
scenar.params = params
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -226,6 +226,10 @@ module Laborantin
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
+
def date_str
|
230
|
+
date.strftime("%Y-%h-%d_%H-%M-%S")
|
231
|
+
end
|
232
|
+
|
229
233
|
private
|
230
234
|
|
231
235
|
def call_hooks(name)
|
@@ -233,10 +237,6 @@ module Laborantin
|
|
233
237
|
self.class.hooks[name].each{|sym| send sym}
|
234
238
|
end
|
235
239
|
|
236
|
-
def date_str
|
237
|
-
date.strftime("%Y-%h-%d_%H-%M-%S")
|
238
|
-
end
|
239
|
-
|
240
240
|
def log(*args)
|
241
241
|
environment.log *args
|
242
242
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: laborantin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Di Cioccio Lucas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-17 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -42,6 +42,8 @@ files:
|
|
42
42
|
- lib/laborantin/core/monkey_patches.rb
|
43
43
|
has_rdoc: true
|
44
44
|
homepage: http://rubyforge.org/projects/laborantin
|
45
|
+
licenses: []
|
46
|
+
|
45
47
|
post_install_message:
|
46
48
|
rdoc_options: []
|
47
49
|
|
@@ -62,9 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
64
|
requirements: []
|
63
65
|
|
64
66
|
rubyforge_project: laborantin
|
65
|
-
rubygems_version: 1.3.
|
67
|
+
rubygems_version: 1.3.3
|
66
68
|
signing_key:
|
67
|
-
specification_version:
|
69
|
+
specification_version: 3
|
68
70
|
summary: A measurement batch facilitator
|
69
71
|
test_files: []
|
70
72
|
|