Sha256: ca3f525771f3a71d7cc7096de017ed94892d94a104c6bff69b3439589a5b0122
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
# coding: utf-8 require 'rinfo/engine' require 'rinfo/cache' require 'git' require 'time' class Rinfo autoload :VERSION, 'rinfo/version' class << self attr_writer :filename def inform! if should_inform? JSON.pretty_generate(rinfo) else fail ActionController::RoutingError, 'Not Found' end end def should_inform? ([:all, env.to_sym] & env_blacklist).empty? end def env_blacklist @env_blacklist ||= [:prod, :production] end def env_blacklist=(args) @env_blacklist = [*args].map(&:to_sym) end def filename @filename ||= 'rinfo.json' end private def rinfo { deployed_by: author, deployed_at: date, rails_env: env, branch: branch, rev: rev } end def git @git ||= Git.open(root) end def root Rails.root end def env Rails.env end def author name = git.config('user.name') name.blank? ? git.log.first.author.name : name end def date git.log.first.date.iso8601 end def branch git.lib.branch_current end def rev git.revparse('HEAD') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rinfo-0.2.0 | lib/rinfo.rb |