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
73 74 75 |
# File 'lib/reviser/components/generator.rb', line 73 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.
66 67 68 |
# File 'lib/reviser/components/generator.rb', line 66 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 61 |
# File 'lib/reviser/components/generator.rb', line 44 def run i = 0 Cfg[:out_format].each do |format| # Deep copy !!! arg = Marshal.load(Marshal.dump(@data)) puts "----[#{i+1}/#{Cfg[:out_format].size}] #{format.upcase}" 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 i += 1 end end |