-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
75 lines (61 loc) · 1.63 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "timecop"
require "inq"
RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = "-w -r./spec/capture_warnings.rb"
end
task :default => :spec
task :generate_changelog do
sh "github_changelog_generator"
end
task :future_changelog do
sh "github_changelog_generator --future-release v#{Inq::VERSION}"
end
# Helper functions used later in the Rakefile.
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)
require "./spec/vcr_helper.rb"
freeze_time do
report = nil
options = {
repository: repository,
format: format,
}
cassette = repository.tr("/", "-")
VCR.use_cassette(cassette) do
report = Inq.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
[
"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