DannyBen/sla

View on GitHub
Runfile

Summary

Maintainability
Test Coverage
require "fileutils"
require "sla"

title   "SLA Developer Toolkit"
summary "Runfile tasks for building the SLA gem"
version SLA::VERSION

import_gem 'runfile-tasks/gem', gemname: 'sla'
import_gem 'runfile-tasks/docker', image: 'dannyben/sla', version: SLA::VERSION

usage  "mockserver"
help   "Start the mock server"
action :mockserver do |args|
  system 'httpme mock'
end

help   "flush the spec cache"
action :flush do
  FileUtils.rm_f Dir["spec/cache/*"]
  say 'Flushed spec/cache/*'
  FileUtils.rm_f Dir["cache/*"]
  say 'Flushed cache/*'
end

usage  "sla -- COMMANDS..."
help   "run sla from source"
action :sla do |args|
  exec "bundle exec bin/sla #{args['COMMANDS'].join ' '}"
end

usage  "mock [-- OPTIONS...]"
help   "run against the localhost mock"
action :mock do |args|
  unless args['OPTIONS'].empty?
    options = args['OPTIONS'].join ' '
    options = " #{options}"
  end
  exec "bundle exec bin/sla localhost:3000 -c1#{options}"
end

usage  "hash URL"
help   "show cache hash for a URL"
action :hash do |args|
  say Digest::MD5.hexdigest args['URL']
end

help   "run the dev/test.rb script"
action :dev do
  Dir.chdir 'dev' do
    system  "bundle exec ruby test.rb"
  end
end