Class: GitFame::Filter

Inherits:
Base
  • Object
show all
Defined in:
lib/git_fame/filter.rb

Constant Summary collapse

OPT =
File::FNM_EXTGLOB | File::FNM_DOTMATCH | File::FNM_CASEFOLD | File::FNM_PATHNAME

Instance Method Summary collapse

Instance Method Details

#call(hunk) {|lines, orig_path, oid, name, email| ... } ⇒ void

This method returns an undefined value.

Invokes block if hunk is valid

Parameters:

  • hunk (Hash)

Yield Parameters:

  • lines (Integer)
  • orig_path (Pathname)
  • oid (String)
  • name (String)
  • email (String)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git_fame/filter.rb', line 26

def call(hunk, &block)
  case [hunk, attributes]
  in [{ orig_path: path, final_signature: { time: created_at } }, { after: }] unless created_at > after
    say("File %s ignored due to [created > after] (%p > %p)", path, created_at, after)
  in [{ orig_path: path, final_signature: { time: created_at } }, { before: }] unless created_at < before
    say("File %s ignored due to [created < before] (%p < %p)", path, created_at, before)
  in [{ orig_path: path}, { exclude: excluded }] if excluded.any? { File.fnmatch?(_1, path, OPT) }
    say("File %s excluded by [exclude] (%p)", path, excluded)
  in [{ orig_path: path }, { include: included }] unless included.any? { File.fnmatch?(_1, path, OPT) }
    say("File %s excluded by [include] (%p)", path, included)
  in [{ orig_path: path }, { extensions: }] unless extensions.any? { File.extname(path) == _1 }
    say("File %s excluded by [extensions] (%p)", path, extensions)
  in [{final_signature: { name:, email:}, final_commit_id: oid, lines_in_hunk: lines, orig_path: path}, Hash]
    block[lines, path, oid, name, email]
  end
end