Sha256: c14d253481e38cbf32f8ca6542566dd8083b61bfffbc542bf8a407570a9bf630

Contents?: true

Size: 1.88 KB

Versions: 5

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(hooks) { %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 'kitchen_hooks'
        latest_version = rubygems_version 'kitchen_hooks'

        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

5 entries across 5 versions & 1 rubygems

Version Path
bourdain-1.3.3 lib/bourdain/resources/checks/hooks.rb
bourdain-1.3.2 lib/bourdain/resources/checks/hooks.rb
bourdain-1.3.1 lib/bourdain/resources/checks/hooks.rb
bourdain-1.3.0 lib/bourdain/resources/checks/hooks.rb
bourdain-1.2.22 lib/bourdain/resources/checks/hooks.rb