Class: RubyBindgen::Generators::CMake::Guard
- Inherits:
-
Object
- Object
- RubyBindgen::Generators::CMake::Guard
- Defined in:
- lib/ruby-bindgen/generators/cmake/guard.rb
Defined Under Namespace
Classes: GuardMatch
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
Instance Method Summary collapse
-
#initialize(condition:, patterns:, base_path:) ⇒ Guard
constructor
A new instance of Guard.
- #match(file_paths:, directory_paths:) ⇒ Object
Constructor Details
#initialize(condition:, patterns:, base_path:) ⇒ Guard
Returns a new instance of Guard.
9 10 11 12 13 14 |
# File 'lib/ruby-bindgen/generators/cmake/guard.rb', line 9 def initialize(condition:, patterns:, base_path:) @condition = condition.to_s @patterns = Array(patterns).map do |pattern| (pattern.to_s, base_path) end end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
7 8 9 |
# File 'lib/ruby-bindgen/generators/cmake/guard.rb', line 7 def condition @condition end |
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
7 8 9 |
# File 'lib/ruby-bindgen/generators/cmake/guard.rb', line 7 def patterns @patterns end |
Instance Method Details
#match(file_paths:, directory_paths:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby-bindgen/generators/cmake/guard.rb', line 16 def match(file_paths:, directory_paths:) matched_files = [] matched_directories = [] patterns.each do |pattern| files = file_paths.select do |path| path_match?(pattern, path) end directories = directory_paths.select do |path| path_match?(pattern, path) end warn_unmatched(pattern) if files.empty? && directories.empty? matched_files.concat(files) matched_directories.concat(directories) end GuardMatch.new(condition: condition, directories: matched_directories.uniq.sort, files: matched_files.uniq.sort) end |