Class: RubbyReport
- Inherits:
-
Object
- Object
- RubbyReport
- Defined in:
- lib/rubbyReport.rb
Instance Method Summary collapse
- #generate_base_64_from_img_to_src(path) ⇒ Object
-
#initialize ⇒ RubbyReport
constructor
A new instance of RubbyReport.
- #run(description = "", key = "", template = 'basic') ⇒ Object
Constructor Details
#initialize ⇒ RubbyReport
Returns a new instance of RubbyReport.
6 7 8 9 |
# File 'lib/rubbyReport.rb', line 6 def initialize @images_list = Dir.glob("*png") @images_list.reverse! end |
Instance Method Details
#generate_base_64_from_img_to_src(path) ⇒ Object
11 12 13 14 15 |
# File 'lib/rubbyReport.rb', line 11 def generate_base_64_from_img_to_src(path) File.open(path, 'rb') do |img| 'data:image/png;base64,' + Base64.strict_encode64(img.read) end end |
#run(description = "", key = "", template = 'basic') ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubbyReport.rb', line 17 def run(description = "", key = "",template='basic') data = ReportData.new data.images_array = @images_list.map do |img| titulo_formatado = img.split('@')[-2] titulo = titulo_formatado.nil? ? img.split('.')[0] : titulo_formatado [titulo, generate_base_64_from_img_to_src(img)] end data.issue_description = description data.issue_key = key data.time = Time.now filename = key == "" ? "report.html" : "#{key}.html" view = Report.new(template, data) File.write(filename, view.render) puts "generated #{filename} file in current folder." end |