-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
44 lines (37 loc) · 1.18 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
require "active_support"
require "yaml"
namespace :build do
task default: :all
task all: [:rubocop]
task :rubocop do
ribose_guide = "src/rubocop/rubocop.ribose.yml"
thoughtbot_guide = "src/rubocop/rubocop.tb.yml"
output_guide = "ci/rubocop.yml"
merge_yaml(thoughtbot_guide, ribose_guide, to: output_guide)
end
def merge_yaml(*src, to:)
aggregation = src.reduce({}) do |acc, file|
full_path = path_in_project(file)
y = YAML.safe_load(File.read(full_path))
acc.deep_merge(y)
end
target_full_path = path_in_project(to)
FileUtils.mkdir_p(File.dirname(target_full_path))
File.write(to, [yaml_header, YAML.dump(aggregation)].join("\n"))
aggregation
end
def path_in_project(path)
File.expand_path(path, __dir__)
end
def yaml_header
(<<~YAML).chomp
############################################
# This file is auto-generated. #
# DO NOT EDIT DIRECTLY #
# OR YOUR CHANGES MAY BE OVERWRITTEN #
# Edit source files instead. #
# See README for details. #
############################################
YAML
end
end