Class: Querly::Tagging
- Inherits:
-
Object
- Object
- Querly::Tagging
- Defined in:
- lib/querly/tagging.rb
Instance Attribute Summary collapse
-
#path_pattern ⇒ Object
readonly
Returns the value of attribute path_pattern.
-
#tags_set ⇒ Object
readonly
Returns the value of attribute tags_set.
Instance Method Summary collapse
- #applicable?(script) ⇒ Boolean
-
#initialize(path_pattern:, tags_set:) ⇒ Tagging
constructor
A new instance of Tagging.
Constructor Details
#initialize(path_pattern:, tags_set:) ⇒ Tagging
Returns a new instance of Tagging.
6 7 8 9 |
# File 'lib/querly/tagging.rb', line 6 def initialize(path_pattern:, tags_set:) @path_pattern = path_pattern @tags_set = end |
Instance Attribute Details
#path_pattern ⇒ Object (readonly)
Returns the value of attribute path_pattern.
3 4 5 |
# File 'lib/querly/tagging.rb', line 3 def path_pattern @path_pattern end |
#tags_set ⇒ Object (readonly)
Returns the value of attribute tags_set.
4 5 6 |
# File 'lib/querly/tagging.rb', line 4 def @tags_set end |
Instance Method Details
#applicable?(script) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/querly/tagging.rb', line 11 def applicable?(script) return true unless path_pattern pattern_components = path_pattern.split('/') script_path = if script.path.absolute? script.path else script.path.realpath end path_components = script_path.to_s.split(File::Separator) path_components.each_cons(pattern_components.size) do |slice| if slice == pattern_components return true end end false end |