Class: ArchUnit::Files::FluentApi::MatchPatternFileConditionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb

Overview

Shared immutable state for positive and negated file predicate builders.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, negated:) ⇒ MatchPatternFileConditionBuilder

Returns a new instance of MatchPatternFileConditionBuilder.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 16

def initialize(scope, negated:)
  unless scope.is_a?(FileConditionBuilder)
    raise ArgumentError, 'scope must be a FileConditionBuilder'
  end
  unless [true, false].include?(negated)
    raise ArgumentError, 'negated must be true or false'
  end

  @project_locator = scope.project_locator
  @filters = scope.filters
  @negated = negated
  freeze
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



14
15
16
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 14

def filters
  @filters
end

#project_locatorObject (readonly)

Returns the value of attribute project_locator.



14
15
16
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 14

def project_locator
  @project_locator
end

Instance Method Details

#adhere_to(condition, message) ⇒ Object



54
55
56
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 54

def adhere_to(condition, message)
  CustomFileCondition.new(self, condition:, message:)
end

#be_in_folder(pattern, except: nil) ⇒ Object



38
39
40
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 38

def be_in_folder(pattern, except: nil)
  matching(Common::RegexFactory.folder_matcher(pattern, except:))
end

#be_in_path(pattern, except: nil) ⇒ Object



42
43
44
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 42

def be_in_path(pattern, except: nil)
  matching(Common::RegexFactory.path_matcher(pattern, except:))
end

#depend_on_external_modulesObject



50
51
52
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 50

def depend_on_external_modules
  DependOnExternalModuleConditionBuilder.new(self)
end

#depend_on_filesObject



46
47
48
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 46

def depend_on_files
  DependOnFileConditionBuilder.new(self)
end

#have_name(pattern, except: nil) ⇒ Object



34
35
36
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 34

def have_name(pattern, except: nil)
  matching(Common::RegexFactory.filename_matcher(pattern, except:))
end

#negated?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 30

def negated?
  @negated
end