cf-app-utils 0.2 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +23 -7
- data/lib/cf-app-utils/cf/app/credentials.rb +6 -0
- data/lib/cf-app-utils/cf/app/service.rb +8 -0
- metadata +17 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7c74061e68cd361e8c46c461906b9a187ef1efb
|
4
|
+
data.tar.gz: 55bf5352c5cb652fd3b14b62d6c54cb68f5410ef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62fa32eea74739117c19db4474c55720aae8960fef4795b84d4f347652070889fa96bd69abe5f9111bd5524b619442d017535123626abcf63715910f54cf17f7
|
7
|
+
data.tar.gz: e0a9c7557397e177e0f687556a4c7b1b6393211e76e6f87a347c76cdafd9ec9a721e991ec8fce94ecdd7cafed30616a4f8602e8acd96d7b951cabceb4e88c37a
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Helper methods for apps running on Cloud Foundry.
|
4
4
|
|
5
|
+
## Download
|
6
|
+
|
7
|
+
https://rubygems.org/gems/cf-app-utils
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -26,18 +30,30 @@ Require and use the gem in your application:
|
|
26
30
|
require 'cf-app-utils'
|
27
31
|
```
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
Returns the credentials hash for a given service that you have bound to
|
32
|
-
your application.
|
33
|
+
You can then grab the credentials hash:
|
33
34
|
|
34
35
|
```ruby
|
35
|
-
# Get credentials for the service with the given name
|
36
|
+
# Get credentials for the service instance with the given name
|
36
37
|
CF::App::Credentials.find_by_service_name('master-db')
|
37
38
|
|
38
|
-
# Get credentials for the first service with the given tag
|
39
|
+
# Get credentials for the first service instance with the given tag
|
39
40
|
CF::App::Credentials.find_by_service_tag('relational')
|
40
41
|
|
41
|
-
# Get credentials for
|
42
|
+
# Get credentials for all service instances with the given tag
|
43
|
+
CF::APP::Credentials.find_all_by_service_tag('relational')
|
44
|
+
|
45
|
+
# Get credentials for all service instances that match all of the given tags
|
46
|
+
CF::App::Credentials.find_all_by_all_service_tags(['cleardb', 'relational'])
|
47
|
+
|
48
|
+
# Get credentials for the first service instance with the given label
|
42
49
|
CF::App::Credentials.find_by_service_label('cleardb')
|
50
|
+
|
51
|
+
# Get credentials for all service instances with the given label
|
52
|
+
CF::App::Credentials.find_all_by_service_label('cleardb')
|
53
|
+
```
|
54
|
+
|
55
|
+
The keys in the hash are strings. For example, to get the `uri` value you can do:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
cleardb_url = credentials['uri']
|
43
59
|
```
|
@@ -20,6 +20,12 @@ module CF::App
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# Returns credentials for the service instances with all the given +tags+.
|
24
|
+
def find_all_by_all_service_tags(tags)
|
25
|
+
return [] if tags.empty?
|
26
|
+
|
27
|
+
Service.find_all_by_tags(tags).map { |service| service['credentials'] }
|
28
|
+
end
|
23
29
|
|
24
30
|
# Returns credentials for the first service instance with the given +label+.
|
25
31
|
def find_by_service_label(label)
|
@@ -19,6 +19,14 @@ module CF::App
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def find_all_by_tags(tags)
|
23
|
+
all.select do |service|
|
24
|
+
tags.inject(true) do |contains_all_tags, tag|
|
25
|
+
contains_all_tags && service['tags'] && service['tags'].include?(tag)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
def find_by_label(label)
|
23
31
|
find_all_by_label(label).first
|
24
32
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf-app-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.4'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Cloud Foundry
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Helper methods for apps running on Cloud Foundry
|
@@ -66,35 +59,34 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- lib/cf-app-utils/cf/app/credentials.rb
|
70
|
-
- lib/cf-app-utils/cf/app/service.rb
|
71
|
-
- lib/cf-app-utils/cf.rb
|
72
|
-
- lib/cf-app-utils.rb
|
73
62
|
- LICENSE.txt
|
74
63
|
- README.md
|
64
|
+
- lib/cf-app-utils.rb
|
65
|
+
- lib/cf-app-utils/cf.rb
|
66
|
+
- lib/cf-app-utils/cf/app/credentials.rb
|
67
|
+
- lib/cf-app-utils/cf/app/service.rb
|
75
68
|
homepage: ''
|
76
69
|
licenses:
|
77
70
|
- MIT
|
71
|
+
metadata: {}
|
78
72
|
post_install_message:
|
79
73
|
rdoc_options: []
|
80
74
|
require_paths:
|
81
75
|
- lib
|
82
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
77
|
requirements:
|
85
|
-
- -
|
78
|
+
- - ">="
|
86
79
|
- !ruby/object:Gem::Version
|
87
80
|
version: '0'
|
88
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
82
|
requirements:
|
91
|
-
- -
|
83
|
+
- - ">="
|
92
84
|
- !ruby/object:Gem::Version
|
93
85
|
version: '0'
|
94
86
|
requirements: []
|
95
87
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
88
|
+
rubygems_version: 2.2.2
|
97
89
|
signing_key:
|
98
|
-
specification_version:
|
90
|
+
specification_version: 4
|
99
91
|
summary: Helper methods for apps running on Cloud Foundry
|
100
92
|
test_files: []
|