Created
February 5, 2024 05:58
-
-
Save KonnorRogers/34cfdba440eb11b373a0c3773c8003ae to your computer and use it in GitHub Desktop.
Bulk write files ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files = %w[ | |
bad-input-validator.md | |
custom-error-validator.md | |
mirror-validator.md | |
pattern-mismatch-validator.md | |
range-overflow-validator.md | |
range-underflow-validator.md | |
step-mismatch-validator.md | |
too-long-validator.md | |
too-short-validator.md | |
type-mismatch-validator.md | |
value-missing-validator.md | |
] | |
def titleize(str) | |
str.gsub(".md", "").gsub(/-/, " ").split(" ").map(&:capitalize).join(" ") | |
end | |
files.each do |filename| | |
File.write("./docs/src/_documentation/references/validators/#{filename}", <<~MD | |
--- | |
title: #{titleize(filename)} | |
permalink: /references/validators/#{File.basename(filename)} | |
--- | |
MD | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment