Class: FastIgnore::Matchers::ShebangRegexp
- Inherits:
-
Object
- Object
- FastIgnore::Matchers::ShebangRegexp
- Defined in:
- lib/fast_ignore/matchers/shebang_regexp.rb
Instance Attribute Summary collapse
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#squash_id ⇒ Object
readonly
Returns the value of attribute squash_id.
Instance Method Summary collapse
- #dir_only? ⇒ Boolean
- #file_only? ⇒ Boolean
-
#initialize(rule, negation) ⇒ ShebangRegexp
constructor
A new instance of ShebangRegexp.
-
#inspect ⇒ Object
:nocov:.
-
#match?(candidate) ⇒ Boolean
:nocov:.
- #squash(list) ⇒ Object
- #weight ⇒ Object
Constructor Details
#initialize(rule, negation) ⇒ ShebangRegexp
Returns a new instance of ShebangRegexp.
9 10 11 12 13 14 15 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 9 def initialize(rule, negation) @rule = rule @return_value = negation ? :allow : :ignore @squash_id = negation ? :allow_shebang : :ignore_shebang freeze end |
Instance Attribute Details
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
7 8 9 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 7 def rule @rule end |
#squash_id ⇒ Object (readonly)
Returns the value of attribute squash_id.
6 7 8 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 6 def squash_id @squash_id end |
Instance Method Details
#dir_only? ⇒ Boolean
25 26 27 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 25 def dir_only? false end |
#file_only? ⇒ Boolean
21 22 23 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 21 def file_only? true end |
#inspect ⇒ Object
:nocov:
30 31 32 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 30 def inspect "#<ShebangRegexp #{@return_value} /#{@rule.to_s[26..-4]}/>" end |
#match?(candidate) ⇒ Boolean
:nocov:
35 36 37 38 39 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 35 def match?(candidate) return false if candidate.filename.include?('.') @return_value if candidate.first_line.match?(@rule) end |
#squash(list) ⇒ Object
17 18 19 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 17 def squash(list) self.class.new(::Regexp.union(list.map(&:rule)), @return_value == :allow) end |
#weight ⇒ Object
41 42 43 |
# File 'lib/fast_ignore/matchers/shebang_regexp.rb', line 41 def weight 2 end |