Class: DTK::DSL::FileType::Match
- Inherits:
-
Object
- Object
- DTK::DSL::FileType::Match
- Defined in:
- lib/dsl/file_type/match.rb
Class Method Summary collapse
-
.matches?(file_type, file_path, opts = {}) ⇒ Boolean
opts can have keys: :exact (Booelan) - meaning regexp completely matches file_path; otherwise it means jsut match the end.
Instance Method Summary collapse
Class Method Details
.matches?(file_type, file_path, opts = {}) ⇒ Boolean
opts can have keys:
:exact (Booelan) - meaning regexp completely matches file_path; otherwise it means jsut match the end
29 30 31 |
# File 'lib/dsl/file_type/match.rb', line 29 def self.matches?(file_type, file_path, opts = {}) new(file_type).matches?(file_path, opts = {}) end |
Instance Method Details
#matches?(file_path, opts = {}) ⇒ Boolean
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dsl/file_type/match.rb', line 33 def matches?(file_path, opts = {}) file_path = remove_multiple_slashes(file_path) if opts[:exact] file_path =~ regexp_exact else # extra check to see if regexp is just for file part or has '/' seperators # if just for file then we can have more restrictive match if regexp.source =~ Regexp.new('/') file_path =~ regexp_match_end else file_path.split('/').last =~ regexp_exact end end end |