Class: Aggkit::Env::Pathfinder

Inherits:
Object
  • Object
show all
Defined in:
lib/aggkit/env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path(path))
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



175
176
177
# File 'lib/aggkit/env.rb', line 175

def path
  @path
end

Instance Method Details

#each_envObject



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_parentObject



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