Hello all rubyist,
I fall in love of ruby some years ago when I reach to re-write in a couple of days with ruby only a scripts I spent some weeks to write with classical unix tools (awk, sed, grep, ...) and the new stuff was running far more quickly.
To learn more ruby, I tried also to write a script to build the linux toolchain (i.e. binutils, glibc, gcc).
As far as for those tools the build sequence is the same (cleanup a previous build, configure, make, install), it was easy to design a class which I named TCModule to run each of those steps for each module (binutils, glibc, gcc).
When something went wrong some where, I like to log outputs produced by each method in a file.
Idealy, this file should have a name with the module name (e.g. binutils) and the on going step, typically the method name.
Till now, to create this log file name, I didn't find better way to create variabales to own to those values like:
[snip]
# Class of ToolChain Module: binutils|gcc|glibc
class TCModule
# make accessible object variables
attr_accessor :ModuleName, :Target, :Host, :Config, :Prefix, :XcPath, \
:Install, :Env, :Extra
attr :CurrentMethod
# methode called by new to initialise object variables
def initialize(_ModuleName, _Target, _Host, _SpecConfig, _Prefix, _XcPath, \
_Install, _Env, _Extra)
@ModuleName = _ModuleName # name of module to build
[snip]
@CurrentMethod = nil # On going action name
@LogPrefx = "#{$LogDir}/#{@ModuleName}#{@Extra}-#{LaunchDate}"
end # initialize
[snip]
# configure
def _Configure
@CurrentMethod = "_Configure"
[snip]
end # _Configure
# install
def _Install
@CurrentMethod = "_Install"
return make("#{@CurrentMethod}", "install")
end # _Install
end # class TCModule
[snip]
which is initialized like:
_Binutils = TCModule.new(:_Binutils.id2name, # ModuleName: name of module to build
Target, # Target: target we're building for
LocalMach, # Host: compiler to use
$BinUtilsConfigP1, # Prefix: where to install
$TempXC, # SpecConfig: Extra config parameters
$TempXC, # XcPath: xcompiler Path
"", # Install:
"", # Env: Extra env parameters
"") # Extra: Xtra release info (pass1, 2)
But to make maintenance easiest, isn't it possible in the methods to grab the name of the object (instance) (my ModuleName) for which it's on going to run?
Tx in advance for ideas,
r.