Module: Wprof::Reporters::FileReport
- Included in:
- WprofReporter
- Defined in:
- lib/wprof/reporters/file_report.rb
Instance Method Summary collapse
- #generate_file_report ⇒ Object
- #make_files(path) ⇒ Object
- #write_mix_file(path) ⇒ Object
- #write_split_file(path) ⇒ Object
Instance Method Details
#generate_file_report ⇒ Object
4 5 6 7 8 9 |
# File 'lib/wprof/reporters/file_report.rb', line 4 def generate_file_report require 'csv' csv_type = WProf::Config.get_value(:csv_type) path = WProf::Config.get_value(:file_path) send("write_#{csv_type.downcase}_file", path) end |
#make_files(path) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wprof/reporters/file_report.rb', line 37 def make_files(path) unless File.exist?("#{path}/wprofservice.csv") params = %w[transaction_id total_time start_dt end_dt code service_hostname request_uri] CSV.open("#{path}/wprofservice.csv", 'wb') do |csv| csv << params end end unless File.exist?("#{path}/wprofcontroller.csv") params = %w[transaction_id total_time start_dt end_dt code controller url db_runtime] CSV.open("#{path}/wprofcontroller.csv", 'wb') do |csv| csv << params end end unless File.exist?("#{path}/wprofmethods.csv") # rubocop:disable Style/GuardClause params = %w[transaction_id total_time start_dt end_dt method] CSV.open("#{path}/wprofmethods.csv", 'wb') do |csv| csv << params end end end |
#write_mix_file(path) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/wprof/reporters/file_report.rb', line 11 def write_mix_file(path) CSV.open("#{path}/wprof.csv", 'ab') do |csv| @data.to_a.each do |elem| csv << elem end end end |
#write_split_file(path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wprof/reporters/file_report.rb', line 19 def write_split_file(path) make_files(path) case @rec_type when :service CSV.open("#{path}/wprofservice.csv", 'ab') do |csv| csv << @data.values end when :standard CSV.open("#{path}/wprofcontroller.csv", 'ab') do |csv| csv << @data.values end when :custom CSV.open("#{path}/wprofmethods.csv", 'ab') do |csv| csv << @data.values end end end |