Class: Laborantin::Runner
Instance Attribute Summary collapse
-
#config ⇒ Object
The configuration of the Runner, a hash serialized in the laborantin.yaml file.
-
#root_dir ⇒ Object
The root_dir is the internal name for the working directory of a Laborantin’s project.
Instance Method Summary
collapse
#load_config!, #save_config
Constructor Details
#initialize ⇒ Runner
Initializes the root_dir with the current working directory of the shell (i.e. ‘.’).
59
60
61
|
# File 'lib/laborantin/runner.rb', line 59
def initialize
@root_dir = File.expand_path('.')
end
|
Instance Attribute Details
#config ⇒ Object
The configuration of the Runner, a hash serialized in the laborantin.yaml file.
51
52
53
|
# File 'lib/laborantin/runner.rb', line 51
def config
@config
end
|
#root_dir ⇒ Object
The root_dir is the internal name for the working directory of a Laborantin’s project.
55
56
57
|
# File 'lib/laborantin/runner.rb', line 55
def root_dir
@root_dir
end
|
Instance Method Details
#config_path ⇒ Object
83
84
85
|
# File 'lib/laborantin/runner.rb', line 83
def config_path
file(dir(:config), 'laborantin.yaml')
end
|
#dir(*sym) ⇒ Object
Provides a shortcut for building the correct directory path inside the root_dir. Returns a string. Does not check if the directory exists or is readable or anything. e.g. dir(:results) or dir(‘results’) to build the path to the result dir.
67
68
69
|
# File 'lib/laborantin/runner.rb', line 67
def dir(*sym)
File.join(root_dir, sym.map{|s| s.to_s})
end
|
127
128
129
|
# File 'lib/laborantin/runner.rb', line 127
def
File.join('laborantin', 'extra')
end
|
#file(dir, sym) ⇒ Object
79
80
81
|
# File 'lib/laborantin/runner.rb', line 79
def file(dir, sym)
File.join(dir, sym)
end
|
#load_analyses ⇒ Object
123
124
125
|
# File 'lib/laborantin/runner.rb', line 123
def load_analyses
load_local_dir(:analyses)
end
|
#load_commands ⇒ Object
111
112
113
|
# File 'lib/laborantin/runner.rb', line 111
def load_commands
load_local_dir(:commands)
end
|
#load_dir(path) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/laborantin/runner.rb', line 87
def load_dir(path)
if File.directory?(path)
Object::Find.find(path) do |file|
if File.extname(file) == '.rb'
require file
end
end
end
end
|
#load_environments ⇒ Object
115
116
117
|
# File 'lib/laborantin/runner.rb', line 115
def load_environments
load_local_dir(:environments)
end
|
131
132
133
|
# File 'lib/laborantin/runner.rb', line 131
def (what, name)
require File.join(, what.to_s, name.to_s)
end
|
#load_extra_commands ⇒ Object
135
136
137
138
139
140
141
|
# File 'lib/laborantin/runner.rb', line 135
def load_extra_commands
if config and config[:extra].is_a? Hash
config[:extra].each_pair do |name, val|
(:commands, name) if val
end
end
end
|
#load_local_dir(dirname) ⇒ Object
Load the ruby files from the dirname directory of a Laborantin project. Current implementation require all .rb files found in the commands directory.
106
107
108
109
|
# File 'lib/laborantin/runner.rb', line 106
def load_local_dir(dirname)
d = dir(dirname)
load_dir(d)
end
|
#load_scenarii ⇒ Object
119
120
121
|
# File 'lib/laborantin/runner.rb', line 119
def load_scenarii
load_local_dir(:scenarii)
end
|
#load_user_commands ⇒ Object
99
100
101
102
|
# File 'lib/laborantin/runner.rb', line 99
def load_user_commands
dir = File.join(user_laborantin_dir, 'commands')
load_dir(dir)
end
|
#prepare ⇒ Object
Prepare a Runner by loading the configuration and the extra commands.
144
145
146
147
148
149
150
151
152
|
# File 'lib/laborantin/runner.rb', line 144
def prepare
load_config!
load_user_commands
load_commands
load_environments
load_scenarii
load_analyses
load_extra_commands
end
|
#resultdir ⇒ Object
71
72
73
|
# File 'lib/laborantin/runner.rb', line 71
def resultdir
dir(:results)
end
|
#user_laborantin_dir ⇒ Object
75
76
77
|
# File 'lib/laborantin/runner.rb', line 75
def user_laborantin_dir
File.join(File.expand_path('~'), '.laborantin')
end
|