Class: Laborantin::Analysis
- Inherits:
-
Object
- Object
- Laborantin::Analysis
- Extended by:
- Metaprog::Describable, Metaprog::MultiName
- Defined in:
- lib/laborantin/core/analysis.rb
Overview
An Analysis is a handy way to reload and filter the various scenarii that were run. You can easily filter on them.
Constant Summary collapse
- @@all =
[]
Constants included from Metaprog::MultiName
Metaprog::MultiName::AVAILABLE_NAMES
Class Attribute Summary collapse
-
.analyses ⇒ Object
An array.
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Attributes included from Metaprog::Describable
Attributes included from Metaprog::MultiName
Attributes included from Metaprog::Selector
Class Method Summary collapse
- .all ⇒ Object
-
.analyze(str, params = {}, &blk) ⇒ Object
Adds an analysis to this class.
- .inherited(klass) ⇒ Object
Instance Method Summary collapse
-
#analyze ⇒ Object
TODO : recode this, maybe as nothing to do here.
- #create_output_dir ⇒ Object
- #export_file(mode = 'r', &blk) ⇒ Object
- #export_path ⇒ Object
-
#initialize(command = nil) ⇒ Analysis
constructor
Just loads the environments and scenarii from the resultdir.
- #output(name, mode = 'r') ⇒ Object
- #output_dirname ⇒ Object
- #output_dirpath ⇒ Object
- #output_path(name) ⇒ Object
-
#report(tpl_path = nil) ⇒ Object
TODO: more flexible.
- #runner ⇒ Object
- #table(name, struct) ⇒ Object
Methods included from Metaprog::MultiName
Methods included from Metaprog::Exports
#export, #exports, #load_exports, #plots, #save_exports
Methods included from Metaprog::Dependencies
Methods included from Metaprog::Selector
included, #load_environments, #load_prior_results, #load_scenarii, #select_instance?
Constructor Details
#initialize(command = nil) ⇒ Analysis
Just loads the environments and scenarii from the resultdir.
126 127 128 129 |
# File 'lib/laborantin/core/analysis.rb', line 126 def initialize(command = nil) @command = command load_prior_results end |
Class Attribute Details
.analyses ⇒ Object
An array
44 45 46 |
# File 'lib/laborantin/core/analysis.rb', line 44 def analyses @analyses end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
123 124 125 |
# File 'lib/laborantin/core/analysis.rb', line 123 def command @command end |
Class Method Details
.all ⇒ Object
65 66 67 |
# File 'lib/laborantin/core/analysis.rb', line 65 def all @@all end |
.analyze(str, params = {}, &blk) ⇒ Object
Adds an analysis to this class. str is a description of the added analysis params is a hash of parameters for this analysis, specifically, the :type parameters allows you to differenciate the kind of analysis for repors TODO: more info on that, tells that we can directly use Analysis.plot and Analysis.table methods
52 53 54 |
# File 'lib/laborantin/core/analysis.rb', line 52 def analyze(str, params = {}, &blk) @analyses << {:str => str, :params => params, :blk => blk} end |
.inherited(klass) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/laborantin/core/analysis.rb', line 58 def inherited(klass) @@all << klass klass.select(:environments,[Laborantin::Environment]) klass.select(:scenarii,[Laborantin::Scenario]) klass.analyses = [] end |
Instance Method Details
#analyze ⇒ Object
TODO : recode this, maybe as nothing to do here
71 72 73 74 75 76 77 78 |
# File 'lib/laborantin/core/analysis.rb', line 71 def analyze self.class.analyses.each do |a| puts "(#{a[:str]})" instance_eval &a[:blk] puts "done" end save_exports end |
#create_output_dir ⇒ Object
96 97 98 |
# File 'lib/laborantin/core/analysis.rb', line 96 def create_output_dir FileUtils.mkdir_p(output_dirpath) unless File.directory?(output_dirpath) end |
#export_file(mode = 'r', &blk) ⇒ Object
115 116 117 |
# File 'lib/laborantin/core/analysis.rb', line 115 def export_file(mode='r', &blk) output('exports.yaml', mode, &blk) end |
#export_path ⇒ Object
119 120 121 |
# File 'lib/laborantin/core/analysis.rb', line 119 def export_path output_path('exports.yaml') end |
#output(name, mode = 'r') ⇒ Object
104 105 106 107 108 109 |
# File 'lib/laborantin/core/analysis.rb', line 104 def output(name, mode='r') create_output_dir File.open(output_path(name), mode) do |f| yield f end end |
#output_dirname ⇒ Object
88 89 90 |
# File 'lib/laborantin/core/analysis.rb', line 88 def output_dirname self.class.cli_name end |
#output_dirpath ⇒ Object
92 93 94 |
# File 'lib/laborantin/core/analysis.rb', line 92 def output_dirpath File.join('.', 'reports', output_dirname) end |
#output_path(name) ⇒ Object
100 101 102 |
# File 'lib/laborantin/core/analysis.rb', line 100 def output_path(name) File.join(output_dirpath, name) end |
#report(tpl_path = nil) ⇒ Object
TODO: more flexible
81 82 83 84 85 86 |
# File 'lib/laborantin/core/analysis.rb', line 81 def report(tpl_path=nil) tpl = ERB.new(File.read(tpl_path)) File.open("reports/#{self.class.name}.html", 'w') do |f| f.puts tpl.result(binding) end end |
#runner ⇒ Object
131 132 133 |
# File 'lib/laborantin/core/analysis.rb', line 131 def runner command.runner if command end |