Class: CF::App::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/cf-app-utils/cf/app/service.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(env = ENV) ⇒ Service

Returns a new instance of Service.



5
6
7
# File 'lib/cf-app-utils/cf/app/service.rb', line 5

def initialize(env = ENV)
  @env = env
end

Instance Method Details

#find_all_by_label(label) ⇒ Object



37
38
39
40
41
# File 'lib/cf-app-utils/cf/app/service.rb', line 37

def find_all_by_label(label)
  all.select do |service|
    service['label'].match /^#{label}(-.*)?$/
  end
end

#find_all_by_tag(tag) ⇒ Object



19
20
21
22
23
# File 'lib/cf-app-utils/cf/app/service.rb', line 19

def find_all_by_tag(tag)
  all.select do |service|
    service['tags'].include?(tag)
  end
end

#find_all_by_tags(tags) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/cf-app-utils/cf/app/service.rb', line 25

def find_all_by_tags(tags)
  all.select do |service|
    tags.inject(true) do |contains_all_tags, tag|
      contains_all_tags && service['tags'] && service['tags'].include?(tag)
    end
  end
end

#find_by_label(label) ⇒ Object



33
34
35
# File 'lib/cf-app-utils/cf/app/service.rb', line 33

def find_by_label(label)
  find_all_by_label(label).first
end

#find_by_name(name) ⇒ Object



9
10
11
12
13
# File 'lib/cf-app-utils/cf/app/service.rb', line 9

def find_by_name(name)
  all.detect do |service|
    service['name'] == name
  end
end

#find_by_tag(tag) ⇒ Object



15
16
17
# File 'lib/cf-app-utils/cf/app/service.rb', line 15

def find_by_tag(tag)
  find_all_by_tag(tag).first
end