Class: CodeManifest::Rule
- Inherits:
-
Object
- Object
- CodeManifest::Rule
- Defined in:
- lib/code_manifest/rule.rb
Instance Attribute Summary collapse
-
#exclude ⇒ Object
readonly
Returns the value of attribute exclude.
-
#glob ⇒ Object
readonly
Returns the value of attribute glob.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Rule
constructor
A new instance of Rule.
- #match?(file) ⇒ Boolean
Constructor Details
#initialize(pattern) ⇒ Rule
Returns a new instance of Rule.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/code_manifest/rule.rb', line 7 def initialize(pattern) @exclude = false @glob = pattern if glob.start_with?("!") @exclude = true @glob = glob.delete_prefix("!") end if File.absolute_path?(glob) @glob = glob.delete_prefix(File::SEPARATOR) else @glob = File.join("**", glob) end end |
Instance Attribute Details
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
5 6 7 |
# File 'lib/code_manifest/rule.rb', line 5 def exclude @exclude end |
#glob ⇒ Object (readonly)
Returns the value of attribute glob.
5 6 7 |
# File 'lib/code_manifest/rule.rb', line 5 def glob @glob end |
Instance Method Details
#match?(file) ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/code_manifest/rule.rb', line 23 def match?(file) if File.absolute_path?(file) prefix = File.join(CodeManifest.root, "/") file = file.delete_prefix(prefix) end File.fnmatch?(glob, file, Manifest::GLOB_OPTIONS) end |