Sha256: f91a4a00fdb06867e616088461645faa8d57b479d7d259aeb9194e9097df13b0

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'roo_on_rails/checks/base'
require 'fileutils'

module RooOnRails
  module Checks
    module Documentation
      class Playbook < Base
        LOCATION = 'PLAYBOOK.md'.freeze

        def intro
          'Looking for an on-call Playbook...'
        end

        def call
          fail! "no playbook at #{LOCATION}." if playbook_missing?
          fail! 'playbook still contains FIXME template sections' if playbook_unfinished?
          pass  'playbook found, legion on-call engineers thank you.'
        end

        def fix
          if !playbook_missing? && playbook_unfinished?
            fail! 'please add detail to your playbook, removing FIXME sections'
          end

          FileUtils.cp(
            File.join(__dir__, 'playbook_template.md'),
            LOCATION
          )
        end

        private

        def playbook_unfinished?
          # The regexp is so that you can still refer to strings saying FIXME in your readme
          # if you need to, by putting the phrase in backticks: `FIXME`
          !File.read(LOCATION).match(/FIXME(?!`)/).nil?
        end

        def playbook_missing?
          !File.exist?(LOCATION)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roo_on_rails-1.10.0 lib/roo_on_rails/checks/documentation/playbook.rb
roo_on_rails-1.9.0 lib/roo_on_rails/checks/documentation/playbook.rb
roo_on_rails-1.8.1 lib/roo_on_rails/checks/documentation/playbook.rb
roo_on_rails-1.8.0 lib/roo_on_rails/checks/documentation/playbook.rb