Sha256: 1e0dbd9770b7334dd30efb54dc8c08189b3566ce60d637807e1ecf59964e2766
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 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 do |v| maj, min, rel = v['number'].split('.', 3).map(&:to_i) rel + min * 1000 + maj * 100_000 end versions.last['number'] end end def repo_dir repo File.join(Dir.pwd, repo) end def work_tree repo "--work-tree=#{repo_dir repo}" end def git_dir repo "--git-dir=#{File.join repo_dir(repo), '.git'}" end def fetch repo `git #{git_dir repo} fetch >/dev/null 2>&1` end def youre_behind? repo fetch repo behind = `git #{git_dir repo} log ..origin/master --oneline`.split("\n").length > 0 raise unless $?.exitstatus.zero? return behind end def youre_ahead? repo fetch repo ahead = `git #{git_dir repo} log origin/master.. --oneline`.split("\n").length > 0 raise unless $?.exitstatus.zero? return ahead end def youre_dirty? repo dirty = `git #{git_dir repo} #{work_tree repo} diff HEAD --numstat`.split("\n").length > 0 raise unless $?.exitstatus.zero? return dirty end end end end require_relative 'checks/chef' require_relative 'checks/bourdain' require_relative 'checks/cookbooks'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bourdain-1.5.1 | lib/bourdain/resources/checks.rb |
bourdain-1.5.0 | lib/bourdain/resources/checks.rb |