Skip to content

Commit 4da2cf2

Browse files
committed
Rename markdown utils to plaintext
1 parent cfb2ebe commit 4da2cf2

File tree

7 files changed

+28
-20
lines changed

7 files changed

+28
-20
lines changed

Rakefile

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ namespace :travis do
295295
end
296296
end
297297

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

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

319319
file_names.map do |file|
320320
comments_added = false
321-
content = markdown_file_content(file, project_name)
321+
content = plaintext_file_content(file, project_name)
322322

323323
lines = content.each_line.each_with_object([]) do |line, all|
324324
if !github_template_file?(file) && !comments_added && !line.start_with?('#!')
325-
all.concat([
326-
"<!---\n",
327-
"This file was generated on #{Time.now.iso8601} from the rspec-dev repo.\n",
328-
"DO NOT modify it by hand as your changes will get lost the next time it is generated.\n",
329-
"-->\n\n",
330-
])
325+
if file.extname =- "yml"
326+
all.concat([
327+
"# This file was generated on #{Time.now.iso8601} from the rspec-dev repo.\n",
328+
"# DO NOT modify it by hand as your changes will get lost the next time it is generated.\n"
329+
])
330+
else
331+
all.concat([
332+
"<!---\n",
333+
"This file was generated on #{Time.now.iso8601} from the rspec-dev repo.\n",
334+
"DO NOT modify it by hand as your changes will get lost the next time it is generated.\n",
335+
"-->\n\n",
336+
])
337+
end
331338
comments_added = true
332339
end
333340

334341
all << line
335342
end
336343

337344
ReadFile.new(
338-
file.relative_path_from(markdown_root).sub(/\.erb$/, ''),
345+
file.relative_path_from(plaintext_root).sub(/\.erb$/, ''),
339346
lines.join,
340347
file.stat.mode
341348
)
@@ -349,20 +356,20 @@ namespace :common_markdown_files do
349356
end
350357
end
351358

352-
def markdown_file_content(file, project_name)
359+
def plaintext_file_content(file, project_name)
353360
raw_contents = file.read
354361
return raw_contents unless file.extname == ".erb"
355362
ERBRenderer.new(project_name, raw_contents).render
356363
end
357364

358-
desc "Update common markdown files"
365+
desc "Update common plaintext files"
359366
task :update_files do
360-
update_common_markdown_files_in_repos
367+
update_common_plaintext_files_in_repos
361368
end
362369

363-
desc "Updates the common markdown files files and creates a PR"
370+
desc "Updates the common plaintext files files and creates a PR"
364371
task :create_pr_with_updates do
365-
force_update update_common_markdown_files_in_repos
372+
force_update update_common_plaintext_files_in_repos
366373
end
367374
end
368375

@@ -380,6 +387,7 @@ end
380387

381388
desc "generate release notes from changelogs"
382389
task :release_notes, :target do |_, args|
390+
383391
target = args[:target] || 'blog'
384392
['rspec-core', 'rspec-expectations', 'rspec-mocks', 'rspec-rails', 'rspec-support'].each do |project|
385393
lines = []

0 commit comments

Comments
 (0)