Sha256: 953f8df5ad77fc67ca4ae189f101f9d17e19942c3cc38da90bba3858b489e0aa

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

module Bourdain
  module Checks

    class HooksCheck < Check
      usage :check, <<-END
        Check the local copy of the Kitchen Hooks
        hooks
      END


      def initialize _
        super []
        return unless require_chef!
        check_hooks!
      end



    private
      def check_hooks!
        # Ensure we have an up-to-date copy of the Kitchen Hooks
        hooks = File.join('utils', 'hooks')

        ahead_of_remote = false
        unless Dir.exists? hooks
          log.warn  "Hm, I don't see a copy of the Kitchen Hooks. I'll fix that for you..."
          %x| git clone git@git.bluejeansnet.com:kitchen-hooks.git #{hooks} |
          log.info  "Your copy of the Kitchen Hooks is now up-to-date."

        else
          if youre_dirty? hooks
            log.warn  "Your copy of the Kitchen Hooks is dirty."
          elsif youre_ahead? hooks
            log.warn  "Your copy of the Kitchen Hooks is ahead of the remote."
            ahead_of_remote = true
          elsif youre_behind? hooks
            log.warn  "Hey, looks like your copy of the Kitchen Hooks is out-of-date. I'll fix that for you..."
            Dir.chdir(bourdain) { %x| git pull | }
            log.info  "Your copy of the Kitchen Hooks is now up-to-date."
          else
            log.info  "Your copy of the Kitchen Hooks looks up-to-date."
          end
        end

        local_version = gemfile_version 'bourdain'
        latest_version = rubygems_version 'bourdain'

        if latest_version == local_version
          log.info 'Your Kitchen is bundled with the latest Kitchen Hooks.'
        elsif local_version < latest_version
          log.error 'Your Kitchen is bundled with older Kitchen Hooks. Try "bundle update kitchen_hooks".'
          error!
        else
          log.warn "You appear to have unreleased Kitchen Hooks. I hope you know what you're doing..."
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bourdain-1.2.16 lib/bourdain/resources/checks/hooks.rb
bourdain-1.2.15 lib/bourdain/resources/checks/hooks.rb