Sha256: cefd8ec5eb1a72727a657a53a23308eeacf05df4c7839f6678a7e609ebc4e3f4

Contents?: true

Size: 1.45 KB

Versions: 28

Compression:

Stored size: 1.45 KB

Contents

require ::File.expand_path("../lib/cornucopia/util/report_builder", File.dirname(__FILE__))

def generate_report_file(folder_name)
  generated_report = Cornucopia::Util::ReportBuilder.new_report(folder_name, "sample_report")
  rand(5..10).times do
    generated_report.within_section(Faker::Lorem.sentence) do |build_report|
      build_report.within_table do |table|
        build_table(table, 0)

        @last_val = Faker::Lorem.words(rand(1..4)).join("_")
        table.write_stats(@last_val, Faker::Lorem.sentence)
      end
    end
  end

  report_name = generated_report.report_base_page_name
  generated_report.close

  report_name
end

def build_table(table, level)
  rand(5..10).times do
    case rand(10)
      when 9
        if level < 3
          Cornucopia::Util::ReportTable.new(nested_table:       table,
                                            nested_table_label: Faker::Lorem.words(rand(1..4)).join("_")) do |sub_report|
            build_table(sub_report, level + 1)
          end
        else
          table.write_stats(Faker::Lorem.words(rand(1..4)).join("_"), Faker::Lorem.sentence)
        end

      when 2
        table.write_stats(Faker::Lorem.words(rand(1..4)).join("_"), Faker::Lorem.paragraph)

      when 3
        table.write_stats(Faker::Lorem.words(rand(1..4)).join("_"), Faker::Lorem.paragraphs(rand(5..10)).join("\n\n"))

      else
        table.write_stats(Faker::Lorem.words(rand(1..4)).join("_"), Faker::Lorem.sentence)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
cornucopia-0.1.40 spec/sample_report.rb
cornucopia-0.1.39 spec/sample_report.rb
cornucopia-0.1.38 spec/sample_report.rb
cornucopia-0.1.37 spec/sample_report.rb
cornucopia-0.1.36 spec/sample_report.rb
cornucopia-0.1.35 spec/sample_report.rb
cornucopia-0.1.34 spec/sample_report.rb
cornucopia-0.1.33 spec/sample_report.rb
cornucopia-0.1.32 spec/sample_report.rb
cornucopia-0.1.31 spec/sample_report.rb
cornucopia-0.1.30 spec/sample_report.rb
cornucopia-0.1.29 spec/sample_report.rb
cornucopia-0.1.28 spec/sample_report.rb
cornucopia-0.1.26 spec/sample_report.rb
cornucopia-0.1.25 spec/sample_report.rb
cornucopia-0.1.24 spec/sample_report.rb
cornucopia-0.1.23 spec/sample_report.rb
cornucopia-0.1.22 spec/sample_report.rb
cornucopia-0.1.21 spec/sample_report.rb
cornucopia-0.1.20 spec/sample_report.rb