laborantin 0.0.7 → 0.0.8

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.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
 
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.name = 'laborantin'
6
- s.version = '0.0.7'
6
+ s.version = '0.0.8'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.summary = "A measurement batch facilitator"
9
9
 
data/bin/labor CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
- require 'rubygems'
5
- #require 'laborantin'
6
- require '../lib/laborantin'
4
+ #require 'rubygems'
5
+ require 'laborantin'
6
+ #require '../lib/laborantin'
7
7
  require 'fileutils'
8
8
  require 'find'
9
9
  require 'erb'
@@ -253,8 +253,9 @@ Command.new('run', 'actually perform measurements') do |c|
253
253
  sc.analyze!
254
254
  end
255
255
  end
256
- env.log "Scenarii performed", :info
257
256
  env.analyze!
257
+ env.teardown!
258
+ env.log "Scenarii performed", :info
258
259
  end
259
260
  end
260
261
  end
@@ -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.7'
31
+ VERSION = '0.0.8'
32
32
  AUTHORS = ['Lucas Di Cioccio']
33
33
  WEBSITE = 'http://dicioccio.fr'
34
34
  LICENSE = 'GNU GPL version 3'
@@ -30,7 +30,7 @@ module Laborantin
30
30
  @@all = []
31
31
  @@rootdir = '.'
32
32
  class << self
33
- attr_accessor :verifications, :description, :envdir
33
+ attr_accessor :verifications, :description, :envdir, :hooks
34
34
 
35
35
  def rootdir=(dir='.')
36
36
  @@rootdir = dir
@@ -47,6 +47,7 @@ module Laborantin
47
47
  def inherited(klass)
48
48
  klass.verifications = []
49
49
  klass.description = ''
50
+ klass.hooks = {:setup => [], :teardown => []}
50
51
  @@all << klass
51
52
  end
52
53
 
@@ -57,6 +58,14 @@ module Laborantin
57
58
  def describe(str)
58
59
  self.description = str
59
60
  end
61
+
62
+ def setup(*args)
63
+ self.hooks[:setup] = [*args].flatten
64
+ end
65
+
66
+ def teardown(*args)
67
+ self.hooks[:teardown] = [*args].flatten
68
+ end
60
69
 
61
70
  def to_s
62
71
  "#{self.name}:\n\t#{self.description}"
@@ -87,6 +96,11 @@ module Laborantin
87
96
  @loggers << Logger.new(STDOUT)
88
97
  log(self.class.description, :info) unless self.class.description.empty?
89
98
  log "Directories prepared"
99
+ call_hooks :setup
100
+ end
101
+
102
+ def teardown!
103
+ call_hooks :teardown
90
104
  end
91
105
 
92
106
  def analyze!
@@ -99,6 +113,11 @@ module Laborantin
99
113
 
100
114
  private
101
115
 
116
+ def call_hooks(name)
117
+ log "Calling #{name} hooks"
118
+ self.class.hooks[name].each{|sym| send sym}
119
+ end
120
+
102
121
  def date_str
103
122
  date.strftime("%Y-%h-%d_%H-%M-%S")
104
123
  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.7
4
+ version: 0.0.8
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-07-22 00:00:00 +02:00
12
+ date: 2009-07-24 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15