Sha256: c996b92083680e2c85425144c24372e955df1f91c4a582ca8aaf59e6550ee6a9

Contents?: true

Size: 862 Bytes

Versions: 3

Compression:

Stored size: 862 Bytes

Contents

module GitTrip
  module Gitter

    # Handles fetching git repository information from a directory.
    class Dir < Gitter::Base
      # <tt>dir</tt> should be a path to a git repository (containing a .git/ subdirectory).
      def initialize(dir, options = {})
        raise Errors::DirNotFound unless File.exists?(dir)
        @repo = Grit::Repo.new(dir)
        @data = {}
        setup_data_hash
      end

      private

      # Loads the <tt>@data</tt> hash with repository information.
      def setup_data_hash
        load_repo_commits
      end

      # Loads a hash of commits into <tt>@data[:commits]</tt>.
      def load_repo_commits
        commits = []
        @repo.commits(@repo.head.name, @repo.commit_count).map do |c|
          commits << c.to_s
        end
        @data[:commits] = commits
      end
    end # of Dir

  end # of Gitter
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-trip-0.0.3 lib/git-trip/gitter/dir.rb
git-trip-0.0.4 lib/git-trip/gitter/dir.rb
git-trip-0.0.5 lib/git-trip/gitter/dir.rb