Class: Lbrt::Service

Inherits:
Object
  • Object
show all
Includes:
Logger::Helper
Defined in:
lib/lbrt/service.rb

Defined Under Namespace

Classes: DSL, Exporter

Instance Method Summary collapse

Methods included from Logger::Helper

#log

Constructor Details

#initialize(client, options = {}) ⇒ Service

Returns a new instance of Service.



21
22
23
24
25
# File 'lib/lbrt/service.rb', line 21

def initialize(client, options = {})
  @client = client
  @options = options
  @driver = Lbrt::Driver.new(@client, @options)
end

Instance Method Details

#apply(file) ⇒ Object



32
33
34
# File 'lib/lbrt/service.rb', line 32

def apply(file)
  walk(file)
end

#export(export_options = {}) ⇒ Object



27
28
29
30
# File 'lib/lbrt/service.rb', line 27

def export(export_options = {})
  exported = Lbrt::Service::Exporter.export(@client, @options)
  Lbrt::Service::DSL.convert(exported, @options)
end

#listObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lbrt/service.rb', line 4

def list
  json = {}
  service_by_key = build_service_by_key

  service_by_key.each do |service_key, srvc|
    service_id = srvc.delete('id')
    type, title = service_key

    json[service_id] = {
      type: type,
      title: title,
    }.merge(srvc)
  end

  puts JSON.pretty_generate(json)
end