lws 7.2.4 → 7.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lws.rb +1 -2
- data/lib/lws/apps/auth.rb +5 -7
- data/lib/lws/apps/corporate_website.rb +5 -6
- data/lib/lws/apps/digital_signage.rb +5 -6
- data/lib/lws/apps/generic.rb +22 -2
- data/lib/lws/apps/maps.rb +5 -6
- data/lib/lws/apps/presence.rb +5 -6
- data/lib/lws/apps/resource.rb +5 -6
- data/lib/lws/apps/ticket.rb +5 -6
- data/lib/lws/config.rb +16 -4
- data/lib/lws/version.rb +1 -1
- data/test/config/full.yml +1 -0
- data/test/setup_test.rb +26 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d062091468c34f7dfcdefce30fc76940eac3f9350200029ca6474e63a3264314
|
4
|
+
data.tar.gz: 0a3669c523669251467f169ca2a70980fb3bcdb43fb0e86e26eb4ee1df5da2f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37b19c793a36fbc741e3b6242d31229dd394cc7f54e281acf6ad686d7bccf6d332b168bb65f54d9d5cdbe336dd7a16df65b440dca9bca570c2893c1ff11d3d94
|
7
|
+
data.tar.gz: 430f4a6cb0a4b0b5441edbb185fc840c5606caae8f258ae4c0272c609294ca49a31693e8aaea0d521f5cbb7d4b38ccafe1c487b032052e93acfd8b296a76fbcd
|
data/lib/lws.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
|
9
9
|
# Netherlands, info@leftclick.eu, +3185-4444-004.
|
10
10
|
|
11
|
-
|
12
11
|
require "faraday_middleware"
|
13
12
|
require "faraday/http_cache"
|
14
13
|
require "hashie"
|
@@ -112,7 +111,7 @@ module LWS
|
|
112
111
|
# @param api_url [String] The endpoint URL of the API
|
113
112
|
# @return [Faraday::Connection] A Faraday connection that makes requests to the API
|
114
113
|
def self.setup_api(api_url)
|
115
|
-
api = Faraday.new(url: api_url) do |c|
|
114
|
+
api = Faraday.new(url: api_url, proxy: config.proxy) do |c|
|
116
115
|
# Request
|
117
116
|
if config.caching_object
|
118
117
|
c.use FaradayMiddleware::Caching, config.caching_object
|
data/lib/lws/apps/auth.rb
CHANGED
@@ -14,18 +14,16 @@ module LWS::Auth
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Auth app
|
18
21
|
ENDPOINT = { production: "https://leftclick.cloud/" ,
|
19
22
|
development: "https://dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
class << self
|
25
|
-
attr_accessor :api
|
26
|
-
end
|
27
|
-
@api = LWS.setup_api(LWS.config.endpoints[:auth] ||
|
28
|
-
ENDPOINT[LWS.config.environment])
|
26
|
+
include LWS::Generic
|
29
27
|
|
30
28
|
### Generic classes
|
31
29
|
|
@@ -14,17 +14,16 @@ module LWS::CorporateWebsite
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Corporate Website app
|
18
21
|
ENDPOINT = { production: "https://www.leftclick.cloud/",
|
19
22
|
development: "https://www-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:corporate_website] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
@@ -14,17 +14,16 @@ module LWS::DigitalSignage
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Digital Signage app
|
18
21
|
ENDPOINT = { production: "https://cm.leftclick.cloud/" ,
|
19
22
|
development: "https://cm-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:digital_signage] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/apps/generic.rb
CHANGED
@@ -14,6 +14,26 @@
|
|
14
14
|
# This module contains classes that are present in all applications.
|
15
15
|
module LWS::Generic
|
16
16
|
|
17
|
+
def self.included(app_mod)
|
18
|
+
app_mod.module_eval do |mod|
|
19
|
+
|
20
|
+
# Set up the API using the configured or default endpoint for the current
|
21
|
+
# environment.
|
22
|
+
endpoints = mod.const_get(:ENDPOINT)
|
23
|
+
app_name = mod.name.demodulize.underscore.to_sym
|
24
|
+
@api = LWS.setup_api(LWS.config.endpoints[app_name] ||
|
25
|
+
endpoints[LWS.config.environment])
|
26
|
+
|
27
|
+
def self.api
|
28
|
+
@api
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.endpoint
|
32
|
+
@api.url_prefix.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
17
37
|
# = The generic model class
|
18
38
|
#
|
19
39
|
# This model forms the base for all LWS models.
|
@@ -205,7 +225,7 @@ module LWS::Generic
|
|
205
225
|
|
206
226
|
# An API connection to Active Storage (with JSON request/response, but
|
207
227
|
# without caching).
|
208
|
-
@as_connection = Faraday.new(url: api.url_prefix) do |c|
|
228
|
+
@as_connection = Faraday.new(url: api.url_prefix, proxy: config.proxy) do |c|
|
209
229
|
# Request
|
210
230
|
c.request :json
|
211
231
|
c.use LWS::Middleware::RequestHeaders, config.api_token
|
@@ -225,7 +245,7 @@ module LWS::Generic
|
|
225
245
|
|
226
246
|
# A plain file connection to LWS (with token autnentication and caching but without
|
227
247
|
# JSON request/response).
|
228
|
-
@lws_connection = Faraday.new(url: api.url_prefix) do |c|
|
248
|
+
@lws_connection = Faraday.new(url: api.url_prefix, proxy: config.proxy) do |c|
|
229
249
|
# Request
|
230
250
|
if config.caching_object
|
231
251
|
c.use FaradayMiddleware::Caching, config.caching_object
|
data/lib/lws/apps/maps.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Maps
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Maps app
|
18
21
|
ENDPOINT = { production: "https://maps.leftclick.cloud/",
|
19
22
|
development: "https://maps-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:maps] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/apps/presence.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Presence
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Presence app
|
18
21
|
ENDPOINT = { production: "https://presence.leftclick.cloud/",
|
19
22
|
development: "https://presence-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:presence] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/apps/resource.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Resource
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Resource app
|
18
21
|
ENDPOINT = { production: "https://resource.leftclick.cloud/",
|
19
22
|
development: "https://resource-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:resource] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/apps/ticket.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Ticket
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Ticket app
|
18
21
|
ENDPOINT = { production: "https://ticket.leftclick.cloud/",
|
19
22
|
development: "https://ticket-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:ticket] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/config.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
|
9
9
|
# Netherlands, info@leftclick.eu, +3185-4444-004.
|
10
10
|
|
11
|
-
|
12
11
|
module LWS
|
13
12
|
|
14
13
|
# = The LWS API configuration class
|
@@ -20,7 +19,9 @@ module LWS
|
|
20
19
|
# configured for the library to work properly!
|
21
20
|
class Config < Hashie::Dash
|
22
21
|
# The list of properties that can be set using a config file.
|
23
|
-
VALID_FILE_PROPERTIES =
|
22
|
+
VALID_FILE_PROPERTIES =
|
23
|
+
[:api_token, :endpoints, :environment, :http_debug, :http_debug_headers,
|
24
|
+
:json_debug, :proxy]
|
24
25
|
|
25
26
|
#@!attribute api_token
|
26
27
|
# @return [String, nil] the API token necessary to gain access
|
@@ -76,6 +77,14 @@ module LWS
|
|
76
77
|
# (Rails logger, Logger, etc.)
|
77
78
|
property :logger
|
78
79
|
|
80
|
+
#@!attribute proxy
|
81
|
+
# When passing a Hash, it should at least contain +:uri+ as key with
|
82
|
+
# a String or URI as value and optionally the +:user+ and +:password+
|
83
|
+
# keys with appropriate values.
|
84
|
+
# @return [Hash, String, URI] the proxy configuration, either as URL or
|
85
|
+
# as a Hash
|
86
|
+
property :proxy
|
87
|
+
|
79
88
|
#@!attribute stubbing
|
80
89
|
# @return [String] the path to a directory with stubbing fixtures
|
81
90
|
# (setting this enables the default stubs)
|
@@ -121,9 +130,10 @@ module LWS
|
|
121
130
|
# an environment key that selects the default environment (unless
|
122
131
|
# overriden by the +LC_LWS_ENV+ environment variable).
|
123
132
|
#
|
124
|
-
# @example A elaborate configuration that sets the development environment as default, enables debugging and overrides an endpoint
|
133
|
+
# @example A elaborate configuration that sets the proxy and the development environment as default, enables debugging and overrides an endpoint
|
125
134
|
# default:
|
126
135
|
# environment: "development"
|
136
|
+
# proxy: "http://proxyserver:8080"
|
127
137
|
#
|
128
138
|
# production:
|
129
139
|
# api_token: "my-prod-api-token"
|
@@ -144,11 +154,13 @@ module LWS
|
|
144
154
|
def load_config_file(config_file, force_environment = nil)
|
145
155
|
return false unless File.exist? config_file
|
146
156
|
config_data = YAML.load_file(config_file)
|
157
|
+
default_config = config_data["default"] || {}
|
158
|
+
|
147
159
|
self.environment = force_environment ||
|
148
160
|
ENV["LC_LWS_ENV"] ||
|
149
161
|
config_data.dig("default", "environment") ||
|
150
162
|
self.environment
|
151
|
-
config = config_data[self.environment.to_s] || {}
|
163
|
+
config = default_config.merge(config_data[self.environment.to_s] || {})
|
152
164
|
|
153
165
|
config.each_pair do |key, value|
|
154
166
|
unless VALID_FILE_PROPERTIES.include? key.to_sym
|
data/lib/lws/version.rb
CHANGED
data/test/config/full.yml
CHANGED
data/test/setup_test.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
|
9
9
|
# Netherlands, info@leftclick.eu, +3185-4444-004.
|
10
10
|
|
11
|
-
|
12
11
|
require "test_helper"
|
13
12
|
|
14
13
|
class TestSetup < MiniTest::Test
|
@@ -132,6 +131,7 @@ class TestSetup < MiniTest::Test
|
|
132
131
|
assert_equal(true, LWS.config.http_debug)
|
133
132
|
assert_equal(true, LWS.config.http_debug_headers)
|
134
133
|
assert_equal(true, LWS.config.json_debug)
|
134
|
+
assert_equal("http://user:password@proxyserver:8080", LWS.config.proxy)
|
135
135
|
|
136
136
|
with_env("LC_LWS_ENV" => "production") do
|
137
137
|
reconfigure do |config|
|
@@ -148,4 +148,29 @@ class TestSetup < MiniTest::Test
|
|
148
148
|
assert_equal(:development, LWS.config.environment)
|
149
149
|
end
|
150
150
|
|
151
|
+
def test_proxy
|
152
|
+
proxy_url = "http://user:password@proxyserver:8080"
|
153
|
+
reconfigure do |config|
|
154
|
+
config.proxy = proxy_url
|
155
|
+
end
|
156
|
+
|
157
|
+
assert_equal(proxy_url, LWS.config.proxy)
|
158
|
+
assert_equal("http://user:password@proxyserver:8080", LWS::Auth.api.proxy.uri.to_s)
|
159
|
+
assert_equal("user", LWS::Auth.api.proxy.user)
|
160
|
+
assert_equal("password", LWS::Auth.api.proxy.password)
|
161
|
+
|
162
|
+
proxy_options =
|
163
|
+
{ uri: Addressable::URI.parse("http://proxyserver:8080"),
|
164
|
+
user: "user",
|
165
|
+
password: "password" }
|
166
|
+
reconfigure do |config|
|
167
|
+
config.proxy = proxy_options
|
168
|
+
end
|
169
|
+
|
170
|
+
assert_equal(proxy_options, LWS.config.proxy)
|
171
|
+
assert_equal("http://proxyserver:8080", LWS::Auth.api.proxy.uri.to_s)
|
172
|
+
assert_equal("user", LWS::Auth.api.proxy.user)
|
173
|
+
assert_equal("password", LWS::Auth.api.proxy.password)
|
174
|
+
end
|
175
|
+
|
151
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.2.
|
4
|
+
version: 7.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeftClick B.V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday-http-cache
|