Skip to content

Add sponsor file #223

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 2 commits into from
Dec 6, 2019
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
48 changes: 28 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ namespace :travis do
end
end

namespace :common_markdown_files do
def update_common_markdown_files_in_repos
update_files_in_repos('common markdown files', ' [ci skip]') do |name|
common_markdown_files_with_comments(name).each do |file|
namespace :common_plaintext_files do
def update_common_plaintext_files_in_repos
update_files_in_repos('common plaintext files', ' [ci skip]') do |name|
common_plaintext_files_with_comments(name).each do |file|
full_file_name = ReposPath.join(name, file.file_name)
full_file_name.write(file.contents)
full_file_name.chmod(file.mode) # ensure executables are set
Expand All @@ -310,32 +310,39 @@ namespace :common_markdown_files do
file.basename.to_s =~ /ISSUE_TEMPLATE/
end

def common_markdown_files_with_comments(project_name)
markdown_root = BaseRspecPath.join('common_markdown_files')
file_names = Pathname.glob(markdown_root.join('**', '{*,.*}')).select do |f|
def common_plaintext_files_with_comments(project_name)
plaintext_root = BaseRspecPath.join('common_plaintext_files')
file_names = Pathname.glob(plaintext_root.join('{.[!.],*}*', '{*,.*}')).select do |f|
f.file?
end

file_names.map do |file|
comments_added = false
content = markdown_file_content(file, project_name)
content = plaintext_file_content(file, project_name)

lines = content.each_line.each_with_object([]) do |line, all|
if !github_template_file?(file) && !comments_added && !line.start_with?('#!')
all.concat([
"<!---\n",
"This file was generated on #{Time.now.iso8601} from the rspec-dev repo.\n",
"DO NOT modify it by hand as your changes will get lost the next time it is generated.\n",
"-->\n\n",
])
if file.extname == ".yml"
all.concat([
"# This file was generated on #{Time.now.iso8601} from the rspec-dev repo.\n",
"# DO NOT modify it by hand as your changes will get lost the next time it is generated.\n"
])
else
all.concat([
"<!---\n",
"This file was generated on #{Time.now.iso8601} from the rspec-dev repo.\n",
"DO NOT modify it by hand as your changes will get lost the next time it is generated.\n",
"-->\n\n",
])
end
comments_added = true
end

all << line
end

ReadFile.new(
file.relative_path_from(markdown_root).sub(/\.erb$/, ''),
file.relative_path_from(plaintext_root).sub(/\.erb$/, ''),
lines.join,
file.stat.mode
)
Expand All @@ -349,20 +356,20 @@ namespace :common_markdown_files do
end
end

def markdown_file_content(file, project_name)
def plaintext_file_content(file, project_name)
raw_contents = file.read
return raw_contents unless file.extname == ".erb"
ERBRenderer.new(project_name, raw_contents).render
end

desc "Update common markdown files"
desc "Update common plaintext files"
task :update_files do
update_common_markdown_files_in_repos
update_common_plaintext_files_in_repos
end

desc "Updates the common markdown files files and creates a PR"
desc "Updates the common plaintext files files and creates a PR"
task :create_pr_with_updates do
force_update update_common_markdown_files_in_repos
force_update update_common_plaintext_files_in_repos
end
end

Expand All @@ -380,6 +387,7 @@ end

desc "generate release notes from changelogs"
task :release_notes, :target do |_, args|

target = args[:target] || 'blog'
['rspec-core', 'rspec-expectations', 'rspec-mocks', 'rspec-rails', 'rspec-support'].each do |project|
lines = []
Expand Down
2 changes: 2 additions & 0 deletions common_plaintext_files/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [JonRowe]
open_collective: rspec