DannyBen/voicemaker

View on GitHub
Runfile

Summary

Maintainability
Test Coverage
require "pretty_trace/enable-trim"

title   "Voicemaker Developer Toolbelt"
summary "Runfile tasks for building the Voicemaker gem"

import_gem 'runfile-tasks/gem'
import_gem 'runfile-tasks/yard'
import 'debug'

help   "Run test mock server"
usage  "mockserver"
action :mockserver do |args|
  exec "ruby spec/mock_api/server.rb"
end

help   "Inject the --help output to the README"
action :'readme-patch' do
  commands = [
    "",
    "voices --help",
    "tts --help",
    "new --help",
    "project --help",
  ]

  tag = "<!-- USAGE -->"
  help = []
  commands.each do |command|
    help << "### `$ voicemaker #{command}`\n\n"
    help << '```'
    help << `bundle exec voicemaker #{command}`
    help << '```'
    help << ''
  end
  help = help.join "\n"

  readme = File.read 'README.md'
  output = readme.gsub /#{tag}(.*)#{tag}/m, "#{tag}\n#{help}\n#{tag}"
  File.write 'README.md', output
end