Sha256: cf71456bde3856bf28bb5abca8d151fe81a43c6ec097630ff036260c05589e07

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# -*- encoding : utf-8 -*-
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

4 entries across 4 versions & 1 rubygems

Version Path
lolcommits-0.9.2 lib/lolcommits/vcs_info.rb
lolcommits-0.9.2.pre1 lib/lolcommits/vcs_info.rb
lolcommits-0.9.1 lib/lolcommits/vcs_info.rb
lolcommits-0.9.1.pre1 lib/lolcommits/vcs_info.rb