Sha256: 9ee1a6a33ba94e7b539d6e092bf919beddab98ed617fb16e3acc8a1be4892cf5

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'fileutils'
require 'open-uri'
require 'json'
require 'erb'


module Bourdain
  module Checks
    class Check < Bourdain::Resource
    protected
      def gemfile_version gem_name
        gemfile_lock = File.read 'Gemfile.lock'
        gemfile_lock =~ /#{gem_name} \((.*?)\)/
        $1
      end

      def rubygems_version gem_name
        versions_url = "https://rubygems.org/api/v1/versions/#{gem_name}.json"
        open(versions_url) do |f|
          versions = JSON::parse f.read
          versions = versions.sort_by { |v| v['number'] }
          versions.last['number']
        end
      end

      def work_tree repo
        "--work-tree=#{File.join(Dir.pwd, repo)}"
      end

      def git_dir repo
        "--git-dir=#{File.join(Dir.pwd, repo, '.git')}"
      end

      def youre_behind? repo
        `git #{git_dir repo} log ..origin/master --oneline`.split("\n").length > 0
      end

      def youre_ahead? repo
        `git #{git_dir repo} log origin/master.. --oneline`.split("\n").length > 0
      end

      def youre_dirty? repo
        `git #{git_dir repo} #{work_tree repo} diff HEAD --numstat`.split("\n").length > 0
      end
    end
  end
end

require_relative 'checks/chef'
require_relative 'checks/hooks'
require_relative 'checks/bourdain'
require_relative 'checks/cookbooks'
require_relative 'checks/ssh_config'

Version data entries

1 entries across 1 versions & 1 rubygems

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