Class: Aggkit::Env::Pathfinder
- Inherits:
-
Object
- Object
- Aggkit::Env::Pathfinder
- Defined in:
- lib/aggkit/env.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #each_env ⇒ Object
- #each_parent ⇒ Object
-
#initialize(path) ⇒ Pathfinder
constructor
A new instance of Pathfinder.
Constructor Details
#initialize(path) ⇒ Pathfinder
Returns a new instance of Pathfinder.
177 178 179 |
# File 'lib/aggkit/env.rb', line 177 def initialize(path) @path = File.realpath(File.(path)) end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
175 176 177 |
# File 'lib/aggkit/env.rb', line 175 def path @path end |
Instance Method Details
#each_env ⇒ Object
191 192 193 194 195 196 197 198 199 |
# File 'lib/aggkit/env.rb', line 191 def each_env Dir.chdir(File.join(path, 'envs')) do Dir.glob('**/*').select do |f| File.directory? f end.select do |f| File.exist?(File.join(f, '.env')) || File.exist?(File.join(f, 'docker-compose.yml')) || File.exist?(File.join(f, 'docker-compose.yaml')) end.sort end end |
#each_parent ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/aggkit/env.rb', line 181 def each_parent current = path.split(File::SEPARATOR) Enumerator.new do |y| until current.empty? y << current.join(File::SEPARATOR) current.pop end end end |