Class: ArchUnit::Files::FluentApi::MatchPatternFileConditionBuilder
- Inherits:
-
Object
- Object
- ArchUnit::Files::FluentApi::MatchPatternFileConditionBuilder
- Defined in:
- lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb
Overview
Shared immutable state for positive and negated file predicate builders.
Direct Known Subclasses
NegatedMatchPatternFileConditionBuilder, PositiveMatchPatternFileConditionBuilder
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#project_locator ⇒ Object
readonly
Returns the value of attribute project_locator.
Instance Method Summary collapse
-
#adhere_to(condition, message) ⇒ CustomFileCondition
Applies a custom predicate to each selected FileInfo.
-
#be_in_folder(pattern, except: nil) ⇒ MatchPatternFileCondition
Requires selected files to match a containing-folder pattern.
-
#be_in_path(pattern, except: nil) ⇒ MatchPatternFileCondition
Requires selected files to match a complete-path pattern.
-
#depend_on_external_modules ⇒ DependOnExternalModuleConditionBuilder
Starts the object stage for standard-library and gem imports.
-
#depend_on_files ⇒ DependOnFileConditionBuilder
Starts the object stage for internal file dependencies.
-
#have_name(pattern, except: nil) ⇒ MatchPatternFileCondition
Requires selected files to match a basename pattern.
-
#initialize(scope, negated:) ⇒ MatchPatternFileConditionBuilder
constructor
A new instance of MatchPatternFileConditionBuilder.
-
#negated? ⇒ Boolean
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
#filters ⇒ Object (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_locator ⇒ Object (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) ⇒ CustomFileCondition
Applies a custom predicate to each selected FileInfo.
68 69 70 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 68 def adhere_to(condition, ) CustomFileCondition.new(self, condition:, message:) end |
#be_in_folder(pattern, except: nil) ⇒ MatchPatternFileCondition
Requires selected files to match a containing-folder pattern.
42 43 44 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 42 def be_in_folder(pattern, except: nil) matching(Common::RegexFactory.folder_matcher(pattern, except:)) end |
#be_in_path(pattern, except: nil) ⇒ MatchPatternFileCondition
Requires selected files to match a complete-path pattern.
48 49 50 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 48 def be_in_path(pattern, except: nil) matching(Common::RegexFactory.path_matcher(pattern, except:)) end |
#depend_on_external_modules ⇒ DependOnExternalModuleConditionBuilder
Starts the object stage for standard-library and gem imports.
60 61 62 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 60 def depend_on_external_modules DependOnExternalModuleConditionBuilder.new(self) end |
#depend_on_files ⇒ DependOnFileConditionBuilder
Starts the object stage for internal file dependencies.
54 55 56 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 54 def depend_on_files DependOnFileConditionBuilder.new(self) end |
#have_name(pattern, except: nil) ⇒ MatchPatternFileCondition
Requires selected files to match a basename pattern.
36 37 38 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 36 def have_name(pattern, except: nil) matching(Common::RegexFactory.filename_matcher(pattern, except:)) end |
#negated? ⇒ Boolean
30 31 32 |
# File 'lib/archunit/files/fluentapi/match_pattern_file_condition_builder.rb', line 30 def negated? @negated end |
ArchUnitRuby