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.



196
197
198
199
# File 'lib/aggkit/env.rb', line 196

def initialize path
  raise "env path #{path} is not directory!" if !File.directory?(File.expand_path(path))
  @env_root = File.realpath(File.expand_path(path))
end

Instance Attribute Details

#env_root ⇒ Object

Returns the value of attribute env_root.



194
195
196
# File 'lib/aggkit/env.rb', line 194

def env_root
  @env_root
end

Instance Method Details

#core?(path) ⇒ Boolean

Returns:

  • (Boolean)


220
221
222
# File 'lib/aggkit/env.rb', line 220

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

#core_root ⇒ Object



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

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

#project_root ⇒ Object



201
202
203
204
205
# File 'lib/aggkit/env.rb', line 201

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)


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

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