Class: Kompo::KompoIgnore

Inherits:
Object
  • Object
show all
Defined in:
lib/kompo/kompo_ignore.rb

Overview

Handler for .kompoignore file Uses pathspec gem for gitignore-compatible pattern matching

Constant Summary collapse

FILENAME =
".kompoignore"

Instance Method Summary collapse

Constructor Details

#initialize(project_dir) ⇒ KompoIgnore

Returns a new instance of KompoIgnore.



11
12
13
14
# File 'lib/kompo/kompo_ignore.rb', line 11

def initialize(project_dir)
  @project_dir = project_dir
  @pathspec = load_pathspec
end

Instance Method Details

#enabled?Boolean

Check if .kompoignore file exists and is enabled

Returns:

  • (Boolean)

    true if .kompoignore file exists



27
28
29
# File 'lib/kompo/kompo_ignore.rb', line 27

def enabled?
  !@pathspec.nil?
end

#ignore?(relative_path) ⇒ Boolean

Check if the given relative path should be ignored

Parameters:

  • relative_path (String)

    Path relative to work_dir

Returns:

  • (Boolean)

    true if the path should be ignored



19
20
21
22
23
# File 'lib/kompo/kompo_ignore.rb', line 19

def ignore?(relative_path)
  return false unless @pathspec

  @pathspec.match(relative_path)
end