Class: Servitor::ServiceLocator

Inherits:
Object
  • Object
show all
Defined in:
lib/service/service_locator.rb

Constant Summary collapse

FILENAMES =
%w(Servicefile .servicefile)
DEFAULT_SERVICES_DIR =
ENV['SERVITOR_SERVICES_DIR'] || File.join(ENV['HOME'],'git')

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.services_dirObject



12
13
14
# File 'lib/service/service_locator.rb', line 12

def services_dir
  @services_dir || DEFAULT_SERVICES_DIR
end

Class Method Details

.locate(service_name = nil) ⇒ Object

Locates the local service or a named service, returning a service config



17
18
19
20
21
22
23
24
25
# File 'lib/service/service_locator.rb', line 17

def locate(service_name = nil)
  if service_name
    dir = File.join(services_dir, service_name)
  else
    dir = Dir.pwd
  end
  file = service_file_in_dir(dir)
  ServiceFileParser.parse(file, dir)
end