Sha256: 9f987ce8dc302f2280da6d838987e0c2ea3496a092366f88d48882eabb88db76

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

module Lolcommits
  # base class ala plugin.rb
  class VCSInfo
    attr_accessor :sha, :message, :repo_internal_path, :repo, :url,
                  :author_name, :author_email, :branch

    def self.repo_root?(path = '.')
      GitInfo.repo_root?(path) || MercurialInfo.repo_root?(path)
    end

    def self.base_message(method)
      raise NotImplementedError, "#{self.class.name} is a base class; implement '#{method}' in a subclass", caller
    end

    def self.local_name(path = '.')
      if GitInfo.repo_root?(path)
        GitInfo.local_name(path)
      elsif MercurialInfo.repo_root?(path)
        MercurialInfo.local_name(path)
      else
        raise "'#{File.expand_path(path)}' is not the root of a supported VCS"
      end
    end

    def initialize
      base_message(__method__)
    end

    def branch
      base_message(__method__)
    end

    def message
      base_message(__method__)
    end

    def sha
      base_message(__method__)
    end

    def repo_internal_path
      base_message(__method__)
    end

    def url
      base_message(__method__)
    end

    def repo
      base_message(__method__)
    end

    def author_name
      base_message(__method__)
    end

    def author_email
      base_message(__method__)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lolcommits-0.9.5 lib/lolcommits/vcs_info.rb
lolcommits-0.9.5.pre1 lib/lolcommits/vcs_info.rb
lolcommits-0.9.4 lib/lolcommits/vcs_info.rb
lolcommits-0.9.4.pre1 lib/lolcommits/vcs_info.rb
lolcommits-0.9.3 lib/lolcommits/vcs_info.rb
lolcommits-0.9.3.pre3 lib/lolcommits/vcs_info.rb
lolcommits-0.9.3.pre2 lib/lolcommits/vcs_info.rb
lolcommits-0.9.3.pre1 lib/lolcommits/vcs_info.rb