Class: Locd::Pattern::Workdir
- Inherits:
-
Locd::Pattern
- Object
- Locd::Pattern
- Locd::Pattern::Workdir
- Defined in:
- lib/locd/pattern.rb
Overview
A Locd::Pattern that matches against Agent workdir.
Instance Attribute Summary collapse
-
#cwd ⇒ Pathname
readonly
"Current" absolute directory path that a relative #raw_path would have been expanded against.
-
#path ⇒ Pathname
readonly
Expanded absolute path to test Agent#workdir against.
-
#recursive ⇒ Boolean
readonly
When
true, pattern will additionally match any agents who's Agent#workdir is a subdirectory of the #path.
Attributes inherited from Locd::Pattern
Instance Method Summary collapse
-
#initialize(source, recursive: false, cwd: Pathname.getwd) ⇒ Workdir
constructor
Instantiate a new
Locd::Pattern::Workdir. -
#match?(agent) ⇒ Boolean
See if this patten matches an agent.
Methods inherited from Locd::Pattern
Constructor Details
#initialize(source, recursive: false, cwd: Pathname.getwd) ⇒ Workdir
Instantiate a new Locd::Pattern::Workdir.
200 201 202 203 204 205 |
# File 'lib/locd/pattern.rb', line 200 def initialize source, recursive: false, cwd: Pathname.getwd super source @cwd = cwd.to_pn @recursive = recursive @path = Pathname.new( source ). @cwd end |
Instance Attribute Details
#cwd ⇒ Pathname (readonly)
"Current" absolute directory path that a relative #raw_path would have been expanded against.
169 170 171 |
# File 'lib/locd/pattern.rb', line 169 def cwd @cwd end |
#path ⇒ Pathname (readonly)
Expanded absolute path to test Agent#workdir against.
184 185 186 |
# File 'lib/locd/pattern.rb', line 184 def path @path end |
#recursive ⇒ Boolean (readonly)
When true, pattern will additionally match any agents who's
Agent#workdir is a subdirectory of the #path.
177 178 179 |
# File 'lib/locd/pattern.rb', line 177 def recursive @recursive end |
Instance Method Details
#match?(agent) ⇒ Boolean
See if this patten matches an agent.
216 217 218 219 220 221 222 |
# File 'lib/locd/pattern.rb', line 216 def match? agent if recursive agent.workdir.to_s.start_with?( path.to_s + '/' ) else agent.workdir == path end end |