Class: Reviser::Components::Generator
- Inherits:
-
Reviser::Component
- Object
- Reviser::Component
- Reviser::Components::Generator
- Includes:
- Generators
- Defined in:
- lib/reviser/components/generator.rb
Overview
Generator is used to create a file result after the analysis. Currently, Generator supports HTML, XLS and CSV format.
Class Method Summary collapse
-
.titleize(str) ⇒ String
Quite handy.
Instance Method Summary collapse
-
#criterias ⇒ Array
Gets all criterias of marking used to display informations in documents.
-
#initialize(data) ⇒ Generator
constructor
A new instance of Generator.
-
#run ⇒ Object
Runs the generation of results file in all asked formats by user.
Methods included from Generators
Methods inherited from Reviser::Component
Constructor Details
#initialize(data) ⇒ Generator
Returns a new instance of Generator.
39 40 41 |
# File 'lib/reviser/components/generator.rb', line 39 def initialize(data) super data end |
Class Method Details
.titleize(str) ⇒ String
Quite handy
72 73 74 |
# File 'lib/reviser/components/generator.rb', line 72 def self.titleize(str) str.split(/_/).join(' ').capitalize end |
Instance Method Details
#criterias ⇒ Array
Gets all criterias of marking used to display informations in documents.
65 66 67 |
# File 'lib/reviser/components/generator.rb', line 65 def criterias @data.values.first.keys.unshift.map! { |cri| Generator.titleize(cri.to_s) } end |
#run ⇒ Object
Runs the generation of results file in all asked formats by user.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/reviser/components/generator.rb', line 44 def run #begin Cfg[:out_format].each do |format| # Deep copy !!! arg = Marshal.load(Marshal.dump(@data)) arg.each do |project, results| results.each do |criterion, value| arg[project][criterion] = value.send(format.to_sym).to_s.encode! 'utf-8', :invalid => :replace end end send format.to_sym, arg end #rescue Object => e # @logger.h1 Logger::FATAL, "Wrong format : #{e.to_s}" #end end |