Sha256: 3ff70418ed7c59d07ee0a498420d96ca10e8a6273d54e4a11d7a473a67963f5c
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 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/hooks' require_relative 'checks/bourdain' require_relative 'checks/cookbooks' require_relative 'checks/ssh_config'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bourdain-1.3.3 | lib/bourdain/resources/checks.rb |
bourdain-1.3.2 | lib/bourdain/resources/checks.rb |