Class: CleoQualityReview::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/configuration.rb

Overview

Configuration for file include/exclude patterns

Defined Under Namespace

Classes: Loader

Constant Summary collapse

DEFAULT_CONFIG_PATH =
File.expand_path("../../config/default.yml", __dir__)
LOCAL_CONFIG_PATH =
".cleo_quality_review.yaml"
ALL_TOOLS =
"AllTools"
INCLUDE =
"Include"
EXCLUDE =
"Exclude"
INHERIT_FROM =
"inherit_from"
GEM_DEFAULT_ALIASES =
["default", "gem:default"].freeze
MATCH_FLAGS =
File::FNM_PATHNAME | File::FNM_EXTGLOB

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Configuration

Returns a new instance of Configuration.

Parameters:

  • data (Hash)

    parsed configuration data



29
30
31
# File 'lib/cleo_quality_review/configuration.rb', line 29

def initialize(data)
  @data = data
end

Class Method Details

.load(root: Dir.pwd) ⇒ Configuration

Load configuration from default and local config files

Parameters:

  • root (String) (defaults to: Dir.pwd)

    root directory for local config lookup

Returns:



23
24
25
# File 'lib/cleo_quality_review/configuration.rb', line 23

def self.load(root: Dir.pwd)
  Loader.new(root: root).load
end

Instance Method Details

#exclude_patternsArray<String>

Returns glob patterns for files to exclude.

Returns:

  • (Array<String>)

    glob patterns for files to exclude



41
42
43
# File 'lib/cleo_quality_review/configuration.rb', line 41

def exclude_patterns
  patterns_for(EXCLUDE)
end

#include_patternsArray<String>

Returns glob patterns for files to include.

Returns:

  • (Array<String>)

    glob patterns for files to include



35
36
37
# File 'lib/cleo_quality_review/configuration.rb', line 35

def include_patterns
  patterns_for(INCLUDE)
end

#target_file?(path) ⇒ Boolean

Check if a file should be included based on configuration patterns

Parameters:

  • path (String)

    file path to check

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/cleo_quality_review/configuration.rb', line 49

def target_file?(path)
  normalized_path = normalize_path(path)

  matches_any?(include_patterns, normalized_path) && !matches_any?(exclude_patterns, normalized_path)
end