ruby-koans/scripts/update-progress.rb

11 lines
366 B
Ruby
Raw Permalink Normal View History

2023-12-27 08:48:51 +00:00
#!/usr/bin/env ruby
pattern = /(<!--\s*AUTOGEN:pct\s*-->\n)(.*)(\n<!--\s*END:pct\s*-->)/m
readme_contents = File.read('README.md')
new_pct = ARGV[0]
badge = "![](https://img.shields.io/badge/Progress-#{new_pct}%25-orange)"
new_readme_contents = readme_contents.gsub(pattern, %{\\1#{badge}\\3})
puts new_readme_contents
File.write('README.md', new_readme_contents)