Skip to content

Improve project helpers (based off 4-0-dev) #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ BaseRspecPath = Pathname.new(Dir.pwd)
ReposPath = BaseRspecPath.join('repos')
MAX_PROJECT_NAME_LENGTH = Projects.map(&:length).max

def filter_projects_by_string(string, projects=Projects)
selection = string.split(" ")
projects.select { |project| selection.include?(project.downcase) }
end

def select_projects(options={})
projects =
if only_string = ENV['ONLY']
filter_projects_by_string(only_string)
else
options.fetch(:only, Projects).flatten - Array(options[:except])
end

projects -= filter_projects_by_string(ENV['EXCEPT']) if ENV['EXCEPT']

projects
end

def run_command(command, opts={})
projects = if opts[:except]
Projects - [opts[:except]].flatten
elsif opts[:only]
[opts[:only]].flatten
else
Projects
end
projects.each do |dir|
select_projects(opts).each do |dir|
next if [opts[:except]].flatten.compact.include?(dir)
path = ReposPath.join(dir)
FileUtils.cd(path) do
Expand All @@ -43,10 +54,7 @@ def announce(project)
end

def each_project(options = {})
projects = options.fetch(:only, Projects)
projects -= Array(options[:except])

projects.each do |project|
select_projects(options).each do |project|
Dir.chdir("repos/#{project}") do
if options[:silent]
yield project
Expand Down Expand Up @@ -408,10 +416,23 @@ namespace :common_plaintext_files do
file.basename.to_s =~ /ISSUE_TEMPLATE/
end

COMMON_PLAINTEXT_EXCLUSIONS =
{
'rspec' =>
%w[BUILD_DETAIL.md.erb CONTRIBUTING.md.erb DEVELOPMENT.md.erb ISSUE_TEMPLATE.md.erb REPORT_TEMPLATE.md],
'rspec-rails' => %w[ISSUE_TEMPLATE.md.erb REPORT_TEMPLATE.md]
}

def common_plaintext_files_with_comments(project_name)
plaintext_root = BaseRspecPath.join('common_plaintext_files')

excluded_files =
COMMON_PLAINTEXT_EXCLUSIONS.fetch(project_name, []).map do |filename|
File.expand_path(filename, plaintext_root).to_s
end

file_names = Pathname.glob(plaintext_root.join('{.[!.],*}*', '{*,.*}')).select do |f|
f.file?
f.file? && !excluded_files.include?(f.to_s)
end

file_names.map do |file|
Expand Down
2 changes: 1 addition & 1 deletion ci/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
ruby:
- 3.0.0-rc1
- 3.0
- 2.7
- 2.6
- 2.5
Expand Down