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.
168 169 170 |
# File 'lib/aggkit/env.rb', line 168 def initialize path @path = File.realpath(File.(path)) end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
166 167 168 |
# File 'lib/aggkit/env.rb', line 166 def path @path end |
Instance Method Details
#each_env ⇒ Object
182 183 184 185 186 187 188 189 190 |
# File 'lib/aggkit/env.rb', line 182 def each_env Dir.chdir(File.join(path, 'envs')) do Dir.glob('**/*').select do |f| File.directory? f end.select do |f| File.exists?(File.join(f, '.env')) || File.exists?(File.join(f, 'docker-compose.yml')) || File.exists?(File.join(f, 'docker-compose.yaml')) end.sort end end |
#each_parent ⇒ Object
172 173 174 175 176 177 178 179 180 |
# File 'lib/aggkit/env.rb', line 172 def each_parent current = path.split(File::SEPARATOR) Enumerator.new do |y| while !current.empty? do y << current.join(File::SEPARATOR) current.pop end end end |