lws 7.2.3 → 7.2.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 +4 -4
- data/bin/lwsconsole +1 -1
- data/lib/lws.rb +1 -1
- data/lib/lws/apps/generic.rb +4 -2
- data/lib/lws/config.rb +27 -7
- data/lib/lws/version.rb +1 -1
- data/test/setup_test.rb +20 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 215d80612cb5ad547181deadb4a61244b8a108c3e1b6a24e52b288c9dcddc507
|
4
|
+
data.tar.gz: '0892759a406c54e49087e7e84ac6a0b433144c936ca8b74e8e3ab0d23a652933'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76bb918ff504f80e6d7e65bce4eaa8a229cdbc9b6b52bced17aa600f87d1b5e1b5ab32adac0e28de00c0b0f1fa49d326962ceaeb80087aac8e5f82914915777e
|
7
|
+
data.tar.gz: e63b88135279e691f345911a249d46a56d20c90534f6759ba64a3830f7c7b3074b0a67bc1206f972637a8a3c3a12b69e221e82cb6464f6b42f16662168de8f99
|
data/bin/lwsconsole
CHANGED
@@ -36,7 +36,7 @@ EOB
|
|
36
36
|
@options[:debug] = debug
|
37
37
|
end
|
38
38
|
opts.on("-e", "--environment=ENV", "select the LWS environment (default: production)") do |env|
|
39
|
-
@options[:environment] = env
|
39
|
+
@options[:environment] = env
|
40
40
|
end
|
41
41
|
opts.on("-t", "--token=TOKEN", "the LWS API token necessary to gain access") do |token|
|
42
42
|
@options[:token] = token
|
data/lib/lws.rb
CHANGED
@@ -81,7 +81,7 @@ module LWS
|
|
81
81
|
|
82
82
|
# Override the environment if needed
|
83
83
|
if ENV["LC_LWS_ENV"].present?
|
84
|
-
@@config.environment = ENV["LC_LWS_ENV"]
|
84
|
+
@@config.environment = ENV["LC_LWS_ENV"]
|
85
85
|
end
|
86
86
|
|
87
87
|
# Override the API token if needed (and no custom API token middleware
|
data/lib/lws/apps/generic.rb
CHANGED
@@ -203,11 +203,13 @@ module LWS::Generic
|
|
203
203
|
def self.use_api(api)
|
204
204
|
config = LWS.config
|
205
205
|
|
206
|
-
#
|
207
|
-
#
|
206
|
+
# An API connection to Active Storage (with JSON request/response, but
|
207
|
+
# without caching).
|
208
208
|
@as_connection = Faraday.new(url: api.url_prefix) do |c|
|
209
209
|
# Request
|
210
210
|
c.request :json
|
211
|
+
c.use LWS::Middleware::RequestHeaders, config.api_token
|
212
|
+
c.use config.api_token_middleware if config.api_token_middleware.present?
|
211
213
|
|
212
214
|
# Response
|
213
215
|
c.use LWS::JSONLogger, config.logger if config.json_debug
|
data/lib/lws/config.rb
CHANGED
@@ -81,8 +81,29 @@ module LWS
|
|
81
81
|
# (setting this enables the default stubs)
|
82
82
|
property :stubbing
|
83
83
|
|
84
|
-
#
|
84
|
+
# Sets the environment for the config.
|
85
|
+
#
|
86
|
+
# The provided environment can be a string in short and long format as well
|
87
|
+
# as a symbol.
|
88
|
+
#
|
89
|
+
# @param new_env [Symbol, String] the new environment to use
|
90
|
+
# @return [Symbol] the new environment
|
91
|
+
# @raise when an invalid environment is provided
|
92
|
+
def environment=(new_env)
|
93
|
+
real_env =
|
94
|
+
case new_env
|
95
|
+
when "prod", "production", :prod, :production
|
96
|
+
:production
|
97
|
+
when "dev", "development", :dev, :development
|
98
|
+
:development
|
99
|
+
else
|
100
|
+
raise "unsupported environment: #{new_env}"
|
101
|
+
end
|
102
|
+
self[:environment] = real_env
|
103
|
+
end
|
85
104
|
|
105
|
+
# Supplements the configuration with settings from a config file.
|
106
|
+
#
|
86
107
|
# The configuration file has a section per environment that indicates
|
87
108
|
# per property what to use if it is unset.
|
88
109
|
#
|
@@ -123,12 +144,11 @@ module LWS
|
|
123
144
|
def load_config_file(config_file, force_environment = nil)
|
124
145
|
return false unless File.exist? config_file
|
125
146
|
config_data = YAML.load_file(config_file)
|
126
|
-
environment = force_environment ||
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
self.environment
|
131
|
-
config = config_data[environment.to_s] || {}
|
147
|
+
self.environment = force_environment ||
|
148
|
+
ENV["LC_LWS_ENV"] ||
|
149
|
+
config_data.dig("default", "environment") ||
|
150
|
+
self.environment
|
151
|
+
config = config_data[self.environment.to_s] || {}
|
132
152
|
|
133
153
|
config.each_pair do |key, value|
|
134
154
|
unless VALID_FILE_PROPERTIES.include? key.to_sym
|
data/lib/lws/version.rb
CHANGED
data/test/setup_test.rb
CHANGED
@@ -47,6 +47,26 @@ class TestSetup < MiniTest::Test
|
|
47
47
|
assert_equal("test-token", LWS.config.api_token)
|
48
48
|
end
|
49
49
|
|
50
|
+
def test_environment_writer
|
51
|
+
LWS.config.environment = "prod"
|
52
|
+
assert_equal(:production, LWS.config.environment)
|
53
|
+
LWS.config.environment = "production"
|
54
|
+
assert_equal(:production, LWS.config.environment)
|
55
|
+
LWS.config.environment = :production
|
56
|
+
assert_equal(:production, LWS.config.environment)
|
57
|
+
|
58
|
+
LWS.config.environment = "dev"
|
59
|
+
assert_equal(:development, LWS.config.environment)
|
60
|
+
LWS.config.environment = "development"
|
61
|
+
assert_equal(:development, LWS.config.environment)
|
62
|
+
LWS.config.environment = :development
|
63
|
+
assert_equal(:development, LWS.config.environment)
|
64
|
+
|
65
|
+
assert_raises do
|
66
|
+
LWS.config.environment = "doesnotexist"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
50
70
|
def test_http_logging_without_logger
|
51
71
|
reconfigure(logger: nil,
|
52
72
|
http_debug: true,
|
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.4
|
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:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday-http-cache
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.10.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '2.0'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.10.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '2.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hashie
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|