Sha256: 7eb2eb4cc8af83c085b722c3f63365f33139e56f91c92c30aa56cfceacb735f3
Contents?: true
Size: 839 Bytes
Versions: 1
Compression:
Stored size: 839 Bytes
Contents
module GitMeta VERSION = "2.0.0" class Scanner attr_accessor :info REGEX = /(\S+):\s*(.+)$/ def initialize(text) self.info = Hash.new("") text.scan(REGEX) do |k,v| self.info[k] = v end end def ==(comrade) info == comrade.info end end class Hash < ::Hash def to_s inject("") do |result, hash| result += "#{hash[0]}: #{hash[1]}\n" # hash is an array of schema [key, value] end end end class Get attr_accessor :scanner, :key def initialize(sha, key=nil) output = IO.popen("git-cat-file -p #{sha}", 'r') do |git_cat_file| git_cat_file.read end self.scanner = Scanner.new(output) self.key = key end def to_s key ? @scanner.info[key] : @scanner.info.to_s end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git-meta-2.0.0 | lib/git_meta.rb |