-
Notifications
You must be signed in to change notification settings - Fork 11
/
Rakefile
107 lines (87 loc) · 2.54 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rdoc/task"
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs = %w[lib test]
t.pattern = "test/**/*_test.rb"
t.warning = false
end
desc "integration tests for third party modules"
Rake::TestTask.new(:integration_tests) do |t|
t.libs = %w[lib test]
t.pattern = "integration_tests/**/*_test.rb"
t.warning = false
end
desc "regression tests for particular incidents"
Rake::TestTask.new(:regression_tests) do |t|
t.libs = %w[lib test]
t.pattern = "regression_tests/**/*_test.rb"
t.warning = false
end
RUBY_MAJOR_MINOR = RUBY_VERSION.split(".").first(2).join(".")
begin
require "rubocop/rake_task"
desc "Run rubocop"
RuboCop::RakeTask.new
rescue LoadError
end
namespace :coverage do
desc "Aggregates coverage reports"
task :report do
return unless ENV.key?("CI")
require "simplecov"
SimpleCov.collate Dir["coverage/**/.resultset.json"]
end
end
# Doc
rdoc_opts = ["--line-numbers", "--title", "HTTPX: An HTTP client library for ruby"]
begin
gem "hanna-nouveau"
rdoc_opts.push("-f", "hanna")
rescue Gem::LoadError
end
rdoc_opts.push("--main", "README.md")
RDOC_FILES = %w[README.md lib/**/*.rb] + Dir["doc/*.rdoc"] + Dir["doc/release_notes/*.md"]
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = "rdoc"
rdoc.options += rdoc_opts
rdoc.rdoc_files.add RDOC_FILES
end
desc "Builds jekyll data"
task :prepare_jekyll_data do
require "yaml"
FileUtils.mkdir_p("data")
version_tmpl = <<-VERSION
-
name: "%<name>s"
path: "%<path>s"
VERSION
`git tag -l`.lines(chomp: true)
.map { |v| v[1..-1] }
.sort_by(&Gem::Version.method(:new))
.reverse
.map { |v| { name: v, path: "#{v.tr(".", "_")}_md.html" } }
.map { |v| format(version_tmpl, v) }
.join
.then { |v| "-\n#{v}" }
.then { |output| File.write("data/versions.yml", output) }
end
desc "Builds Homepage"
task :prepare_website => %w[rdoc prepare_jekyll_data] do
require "fileutils"
FileUtils.rm_rf("wiki")
system("git clone https://gitlab.com/os85/httpx.wiki.git wiki")
Dir.glob("wiki/*.md") do |path|
data = File.read(path)
name = File.basename(path, ".md")
title = name == "home" ? "Wiki" : name.split("-").map(&:capitalize).join(" ")
layout = name == "home" ? "page" : "wiki"
header = "---\n" \
"layout: #{layout}\n" \
"title: #{title}\n" \
"project: httpx\n" \
"---\n\n"
File.write(path, header + data)
end
end