Sha256: 60f3239c0fa1708bbebd1e4ddadf9f59815494fb2ba60148f9ae6fbd293c5b75

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'timecop'
#require 'vcr'
require './spec/vcr_helper.rb'
require 'how_is'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec

class HelperFunctions
  def self.freeze_time(&block)
    date = DateTime.parse('2016-11-01').new_offset(0)
    Timecop.freeze(date) do
      yield
    end
  end

  def self.generate_report(repository, format)
    freeze_time do
      report = nil

      options = {
        repository: repository,
        format: format,
      }

      cassette = repository.gsub('/', '-')
      VCR.use_cassette(cassette) do
        report = HowIs.generate_report(**options)
      end

      filename = "#{cassette}-report.#{format}"
      path = File.expand_path("spec/data/#{filename}", __dir__)
      File.open(path, 'w') do |f|
        f.puts report
        # HACK: Trailing newline is missing, otherwise.
        f.puts if format == 'html'
      end
    end
  end
end

namespace :generate_reports do
  desc 'Generate example HTML reports.'
  task :html do
    %w[
      how-is/example-repository
      how-is/example-empty-repository
    ].each do |repo|
      HelperFunctions.generate_report(repo, 'html')
    end
  end

  desc 'Generate example JSON reports.'
  task :json do
    HelperFunctions.generate_report('how-is/example-repository', 'json')
  end

  task :all => [:html, :json]
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
how_is-18.0.3 Rakefile
how_is-18.0.2 Rakefile
how_is-18.0.1 Rakefile
how_is-18.0.0 Rakefile
how_is-17.0.0 Rakefile
how_is-16.0.0 Rakefile
how_is-15.0.0 Rakefile
how_is-14.0.0 Rakefile
how_is-13.0.0 Rakefile
how_is-12.0.0 Rakefile