Sha256: bb06b876a95e4b2eb23db39b857ed3ad526556962989af9e56122e8ce5cae94b

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

# -*- coding: utf-8 -*-

require 'memoist'
require 'super_hash'

    Dir.exist?('.git') || system(*%w[git init .])
module Gemspec
  module Git
    extend Memoist
    module_function

    memoize def ls_files
      `git ls-files -z`.split("\x0")
    end

    memoize def config
      cmd = %w[git config --list]
      config = SuperHash.new
      IO.popen(cmd).each do |line|
        line.chomp!
        path, _, value = line.partition("=")
        path = path.split(".").map(&:to_sym)
        path, assign = path[0...-1], path[-1]
        (path.reduce(config) {|acc,key| acc[key] })[assign] = value
      end
      config
    end

    memoize def ls_authors
      authors = `git log > /dev/null 2>&1 && git shortlog -sn`.split("\n").map {|a| a.sub(/^[\d\s]*/, '') }
      authors = (authors.empty? && [ `git config user.name` ]) || authors
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gemspec-0.2.3 lib/gemspec/git.rb
gemspec-0.2.2 lib/gemspec/git.rb
gemspec-0.2.1 lib/gemspec/git.rb
gemspec-0.1.0 lib/gemspec/git.rb