Skip to content

Commit d81d4d6

Browse files
authored
Merge pull request #276 from rspec/project-helpers-4-0
Improve project helpers (based off 4-0-dev)
2 parents 41f2637 + ff60076 commit d81d4d6

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

Rakefile

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,26 @@ BaseRspecPath = Pathname.new(Dir.pwd)
1212
ReposPath = BaseRspecPath.join('repos')
1313
MAX_PROJECT_NAME_LENGTH = Projects.map(&:length).max
1414

15+
def filter_projects_by_string(string, projects=Projects)
16+
selection = string.split(" ")
17+
projects.select { |project| selection.include?(project.downcase) }
18+
end
19+
20+
def select_projects(options={})
21+
projects =
22+
if only_string = ENV['ONLY']
23+
filter_projects_by_string(only_string)
24+
else
25+
options.fetch(:only, Projects).flatten - Array(options[:except])
26+
end
27+
28+
projects -= filter_projects_by_string(ENV['EXCEPT']) if ENV['EXCEPT']
29+
30+
projects
31+
end
32+
1533
def run_command(command, opts={})
16-
projects = if opts[:except]
17-
Projects - [opts[:except]].flatten
18-
elsif opts[:only]
19-
[opts[:only]].flatten
20-
else
21-
Projects
22-
end
23-
projects.each do |dir|
34+
select_projects(opts).each do |dir|
2435
next if [opts[:except]].flatten.compact.include?(dir)
2536
path = ReposPath.join(dir)
2637
FileUtils.cd(path) do
@@ -43,10 +54,7 @@ def announce(project)
4354
end
4455

4556
def each_project(options = {})
46-
projects = options.fetch(:only, Projects)
47-
projects -= Array(options[:except])
48-
49-
projects.each do |project|
57+
select_projects(options).each do |project|
5058
Dir.chdir("repos/#{project}") do
5159
if options[:silent]
5260
yield project
@@ -408,10 +416,23 @@ namespace :common_plaintext_files do
408416
file.basename.to_s =~ /ISSUE_TEMPLATE/
409417
end
410418

419+
COMMON_PLAINTEXT_EXCLUSIONS =
420+
{
421+
'rspec' =>
422+
%w[BUILD_DETAIL.md.erb CONTRIBUTING.md.erb DEVELOPMENT.md.erb ISSUE_TEMPLATE.md.erb REPORT_TEMPLATE.md],
423+
'rspec-rails' => %w[ISSUE_TEMPLATE.md.erb REPORT_TEMPLATE.md]
424+
}
425+
411426
def common_plaintext_files_with_comments(project_name)
412427
plaintext_root = BaseRspecPath.join('common_plaintext_files')
428+
429+
excluded_files =
430+
COMMON_PLAINTEXT_EXCLUSIONS.fetch(project_name, []).map do |filename|
431+
File.expand_path(filename, plaintext_root).to_s
432+
end
433+
413434
file_names = Pathname.glob(plaintext_root.join('{.[!.],*}*', '{*,.*}')).select do |f|
414-
f.file?
435+
f.file? && !excluded_files.include?(f.to_s)
415436
end
416437

417438
file_names.map do |file|

ci/.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
matrix:
2121
ruby:
22-
- 3.0.0-rc1
22+
- 3.0
2323
- 2.7
2424
- 2.6
2525
- 2.5

0 commit comments

Comments
 (0)