Class: Aggkit::Env::Project

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Project

Returns a new instance of Project.



209
210
211
212
213
# File 'lib/aggkit/env.rb', line 209

def initialize(path)
  raise "env path #{path} is not directory!" unless File.directory?(File.expand_path(path))

  @env_root = File.realpath(File.expand_path(path))
end

Instance Attribute Details

#env_rootObject

Returns the value of attribute env_root.



207
208
209
# File 'lib/aggkit/env.rb', line 207

def env_root
  @env_root
end

Instance Method Details

#core?(path) ⇒ Boolean

Returns:

  • (Boolean)


234
235
236
# File 'lib/aggkit/env.rb', line 234

def core?(path)
  return File.realpath(File.expand_path(path)) if File.exist?("#{path}/.core")
end

#core_rootObject



221
222
223
224
225
# File 'lib/aggkit/env.rb', line 221

def core_root
  @core_root = Pathfinder.new(project_root).each_parent.find do |path|
    core?(path)
  end
end

#project_rootObject



215
216
217
218
219
# File 'lib/aggkit/env.rb', line 215

def project_root
  @project_root = Pathfinder.new(env_root).each_parent.find do |path|
    root?(path)
  end || (raise "Can't find project root")
end

#root?(path) ⇒ Boolean

Returns:

  • (Boolean)


227
228
229
230
231
232
# File 'lib/aggkit/env.rb', line 227

def root?(path)
  return File.realpath(File.expand_path(path)) if File.directory?("#{path}/.git") ||
    File.exist?("#{path}/base-service.yml") ||
    File.exist?("#{path}/common-services.yml") ||
    File.directory?("#{path}/envs")
end