Class: Wlog::FetchGitCommits

Inherits:
Commandable show all
Defined in:
lib/wlog/commands/fetch_git_commits.rb

Overview

Author:

  • Simon Symeonidis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, repo, author = nil) ⇒ FetchGitCommits

Configuration to query the git repo for the required commits. You can specify a date range and an author. You need to provide a path to the git repository.

Examples:

from_date = DateTime.now - 15
to_date   = DateTime.now + 5
repo      = '/home/jon/wlog/.git/'
cmd = FetchGitCommits.new(from_date, to_date, repo, 'jon')

Parameters:

  • from

    date start

  • to

    date end

  • repo

    location to the git repo

  • author (defaults to: nil)

    only show logs of that author. If none is given, fetch all authors



21
22
23
# File 'lib/wlog/commands/fetch_git_commits.rb', line 21

def initialize(from, to, repo, author=nil)
  @from, @to, @repo, @author = from, to, repo, author
end

Instance Attribute Details

#commitsObject

Returns the value of attribute commits.



31
32
33
# File 'lib/wlog/commands/fetch_git_commits.rb', line 31

def commits
  @commits
end

Instance Method Details

#executeObject

Run the parser on the repo; yield commits



26
27
28
29
# File 'lib/wlog/commands/fetch_git_commits.rb', line 26

def execute
  result = `#{run_git_cmd}`
  @commits = GitCommitParser.parse(result)
nil end