bubbles-rest-client 0.2.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +1 -0
- data/.gitignore +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +77 -0
- data/CONTRIBUTING.md +31 -0
- data/README.md +7 -112
- data/Rakefile +2 -7
- data/bubbles.gemspec +5 -4
- data/lib/bubbles.rb +3 -6
- data/lib/bubbles/config.rb +128 -106
- data/lib/bubbles/endpoint.rb +17 -3
- data/lib/bubbles/rest_client_resources.rb +258 -106
- data/lib/bubbles/rest_environment.rb +45 -3
- data/lib/bubbles/version.rb +1 -1
- data/lib/tasks/coverage.rake +22 -0
- data/lib/tasks/spec.rake +5 -0
- metadata +31 -13
- data/Gemfile.lock +0 -85
@@ -1,6 +1,6 @@
|
|
1
1
|
module Bubbles
|
2
2
|
class RestEnvironment
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :host, :port, :api_key, :api_key_name
|
4
4
|
|
5
5
|
##
|
6
6
|
# Construct a new instance of +RestEnvironment+.
|
@@ -9,17 +9,59 @@ module Bubbles
|
|
9
9
|
# @param [String] host The host to communicate with.
|
10
10
|
# @param [Integer] port The port on which the communication channel should operate.
|
11
11
|
# @param [String] api_key (Optional) The API key to use to identify your client with the API. Defaults to +nil+.
|
12
|
+
# @param [String] api_key_name (Optional) The name of the header that will specify the API key. Defaults to +"X-API-Key"+.
|
12
13
|
#
|
13
|
-
def initialize(scheme='https', host='api.foamfactory.com', port=443, api_key=nil)
|
14
|
+
def initialize(scheme='https', host='api.foamfactory.com', port=443, api_key=nil, api_key_name='X-API-Key')
|
14
15
|
@scheme = scheme
|
15
16
|
@port = port
|
16
17
|
|
17
|
-
if @scheme == 'http' && @port ==
|
18
|
+
if @scheme == 'http' && @port == nil
|
18
19
|
@port = 80
|
20
|
+
elsif @scheme == 'https' && @port == nil
|
21
|
+
@port = 443
|
19
22
|
end
|
20
23
|
|
21
24
|
@host = host
|
22
25
|
@api_key = api_key
|
26
|
+
@api_key_name = api_key_name
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Retrieve the name of the API key to be used.
|
31
|
+
#
|
32
|
+
# This will be the "key" portion of the key-value of the API key header.
|
33
|
+
#
|
34
|
+
# @return [String] The API key name, if set; "X-API-Key", otherwise.
|
35
|
+
#
|
36
|
+
def api_key_name
|
37
|
+
@api_key_name
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Retrieve an API key from this +RestEnvironment+, but only if a specific +Endpoint+ requires it.
|
42
|
+
#
|
43
|
+
# If an +Endpoint+ has +api_key_required+ set to +true+, this method will return the API for the current
|
44
|
+
# +RestEnvironment+. If not, then it will return +nil+, rather than just blindly returning the API key for every
|
45
|
+
# possible retrieval, even if the +Endpoint+ doesn't require it.
|
46
|
+
#
|
47
|
+
# @return [String] The API key for this +RestEnvironment+, if the specified +Endpoint+ requires it; +nil+,
|
48
|
+
# otherwise.
|
49
|
+
#
|
50
|
+
def get_api_key_if_needed(endpoint)
|
51
|
+
if endpoint.api_key_required?
|
52
|
+
@api_key
|
53
|
+
else
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Retrieve the scheme of the current +RestEnvironment+, as a +Symbol+.
|
60
|
+
#
|
61
|
+
# @return [Symbol] The scheme of the current +RestEnvironment+, as a +Symbol+.
|
62
|
+
#
|
63
|
+
def scheme
|
64
|
+
@scheme.to_s
|
23
65
|
end
|
24
66
|
end
|
25
67
|
end
|
data/lib/bubbles/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'os'
|
4
|
+
|
5
|
+
namespace :spec do
|
6
|
+
desc "Create rspec coverage"
|
7
|
+
task :coverage do
|
8
|
+
ENV['COVERAGE'] = 'true'
|
9
|
+
Rake::Task["spec"].execute
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :coverage do
|
13
|
+
desc 'View coverage information'
|
14
|
+
task :view => [:coverage] do
|
15
|
+
if OS.mac?
|
16
|
+
`open coverage/index.html`
|
17
|
+
elsif OS.posix?
|
18
|
+
`sensible-browser coverage/index.html`
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/tasks/spec.rake
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bubbles-rest-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.1.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.5'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.5'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: vcr
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '3.8'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: os
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: addressable
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,9 +172,12 @@ executables: []
|
|
158
172
|
extensions: []
|
159
173
|
extra_rdoc_files: []
|
160
174
|
files:
|
175
|
+
- ".github/FUNDING.yml"
|
161
176
|
- ".gitignore"
|
177
|
+
- ".travis.yml"
|
178
|
+
- CODE_OF_CONDUCT.md
|
179
|
+
- CONTRIBUTING.md
|
162
180
|
- Gemfile
|
163
|
-
- Gemfile.lock
|
164
181
|
- LICENSE
|
165
182
|
- README.md
|
166
183
|
- Rakefile
|
@@ -171,6 +188,8 @@ files:
|
|
171
188
|
- lib/bubbles/rest_client_resources.rb
|
172
189
|
- lib/bubbles/rest_environment.rb
|
173
190
|
- lib/bubbles/version.rb
|
191
|
+
- lib/tasks/coverage.rake
|
192
|
+
- lib/tasks/spec.rake
|
174
193
|
homepage: https://github.com/FoamFactory/bubbles
|
175
194
|
licenses:
|
176
195
|
- MPL-2.0
|
@@ -191,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
210
|
- !ruby/object:Gem::Version
|
192
211
|
version: '0'
|
193
212
|
requirements: []
|
194
|
-
|
195
|
-
rubygems_version: 2.6.11
|
213
|
+
rubygems_version: 3.0.8
|
196
214
|
signing_key:
|
197
215
|
specification_version: 4
|
198
216
|
summary: A gem for easily defining client REST interfaces in Ruby
|
data/Gemfile.lock
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bubbles-rest-client (0.2.0)
|
5
|
-
addressable (~> 2.5)
|
6
|
-
rest-client (~> 2.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.5.2)
|
12
|
-
public_suffix (>= 2.0.2, < 4.0)
|
13
|
-
ansi (1.5.0)
|
14
|
-
builder (3.2.3)
|
15
|
-
crack (0.4.3)
|
16
|
-
safe_yaml (~> 1.0.0)
|
17
|
-
diff-lcs (1.3)
|
18
|
-
docile (1.3.1)
|
19
|
-
domain_name (0.5.20180417)
|
20
|
-
unf (>= 0.0.5, < 1.0.0)
|
21
|
-
hashdiff (0.3.4)
|
22
|
-
http-cookie (1.0.3)
|
23
|
-
domain_name (~> 0.5)
|
24
|
-
json (2.0.2)
|
25
|
-
mime-types (3.2.2)
|
26
|
-
mime-types-data (~> 3.2015)
|
27
|
-
mime-types-data (3.2019.0331)
|
28
|
-
minitest (5.11.3)
|
29
|
-
minitest-reporters (1.1.19)
|
30
|
-
ansi
|
31
|
-
builder
|
32
|
-
minitest (>= 5.0)
|
33
|
-
ruby-progressbar
|
34
|
-
netrc (0.11.0)
|
35
|
-
public_suffix (3.0.3)
|
36
|
-
rake (10.5.0)
|
37
|
-
rest-client (2.0.2)
|
38
|
-
http-cookie (>= 1.0.2, < 2.0)
|
39
|
-
mime-types (>= 1.16, < 4.0)
|
40
|
-
netrc (~> 0.8)
|
41
|
-
rspec (3.8.0)
|
42
|
-
rspec-core (~> 3.8.0)
|
43
|
-
rspec-expectations (~> 3.8.0)
|
44
|
-
rspec-mocks (~> 3.8.0)
|
45
|
-
rspec-core (3.8.0)
|
46
|
-
rspec-support (~> 3.8.0)
|
47
|
-
rspec-expectations (3.8.2)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.8.0)
|
50
|
-
rspec-mocks (3.8.0)
|
51
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.8.0)
|
53
|
-
rspec-support (3.8.0)
|
54
|
-
ruby-progressbar (1.9.0)
|
55
|
-
safe_yaml (1.0.4)
|
56
|
-
simplecov (0.16.1)
|
57
|
-
docile (~> 1.1)
|
58
|
-
json (>= 1.8, < 3)
|
59
|
-
simplecov-html (~> 0.10.0)
|
60
|
-
simplecov-html (0.10.2)
|
61
|
-
unf (0.1.4)
|
62
|
-
unf_ext
|
63
|
-
unf_ext (0.0.7.6)
|
64
|
-
vcr (3.0.3)
|
65
|
-
webmock (3.0.1)
|
66
|
-
addressable (>= 2.3.6)
|
67
|
-
crack (>= 0.3.2)
|
68
|
-
hashdiff
|
69
|
-
|
70
|
-
PLATFORMS
|
71
|
-
ruby
|
72
|
-
|
73
|
-
DEPENDENCIES
|
74
|
-
bubbles-rest-client!
|
75
|
-
bundler (~> 2.0.0)
|
76
|
-
minitest (~> 5.0)
|
77
|
-
minitest-reporters (~> 1.1)
|
78
|
-
rake (~> 10.0)
|
79
|
-
rspec (~> 3.8)
|
80
|
-
simplecov (~> 0.16)
|
81
|
-
vcr (~> 3.0)
|
82
|
-
webmock (~> 3.0)
|
83
|
-
|
84
|
-
BUNDLED WITH
|
85
|
-
2.0.1
|