plek 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plek.rb +14 -20
- data/lib/plek/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce9ccd2cdfbd98e5f5d400b89afc268e7ac85eede91425d6999a45d8c8241e7
|
4
|
+
data.tar.gz: fb644ee1e4abefa8d133083e6dae182c4d6292cd9079a39e890a7d81a7d7846e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 152b9b257a2d0ccc8dc1a0854e0e63ee75464173561d4b6eb781caafbb9a89abcd56ff9bb0cd31bb24f297a23a45d07f6bbd45ceb7911ff34ca88b8539391211
|
7
|
+
data.tar.gz: df7e4c1d134ede43491e7bb1e8ff0f1568bf3e9b39a64a2487fae48f800fdda709ca43f092bbaa1eca451a6e3324a7d5c33d73b6e23ea9947032d2efb6e85dd5
|
data/lib/plek.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "plek/version"
|
2
|
+
require "uri"
|
3
3
|
|
4
4
|
# Plek resolves service names to a corresponding base URL.
|
5
5
|
#
|
@@ -17,10 +17,10 @@ class Plek
|
|
17
17
|
class NoConfigurationError < StandardError; end
|
18
18
|
|
19
19
|
# The fallback parent domain to use in development mode.
|
20
|
-
DEV_DOMAIN =
|
20
|
+
DEV_DOMAIN = "dev.gov.uk".freeze
|
21
21
|
|
22
22
|
# Domains to return http URLs for.
|
23
|
-
HTTP_DOMAINS = [
|
23
|
+
HTTP_DOMAINS = [DEV_DOMAIN].freeze
|
24
24
|
|
25
25
|
attr_accessor :parent_domain, :external_domain
|
26
26
|
|
@@ -63,19 +63,19 @@ class Plek
|
|
63
63
|
# @return [String] The base URL for the service.
|
64
64
|
def find(service, options = {})
|
65
65
|
name = name_for(service)
|
66
|
-
if service_uri = defined_service_uri_for(name)
|
66
|
+
if (service_uri = defined_service_uri_for(name))
|
67
67
|
return service_uri
|
68
68
|
end
|
69
69
|
|
70
70
|
host = "#{name}.#{options[:external] ? external_domain : parent_domain}"
|
71
71
|
|
72
|
-
if host_prefix = ENV[
|
72
|
+
if (host_prefix = ENV["PLEK_HOSTNAME_PREFIX"])
|
73
73
|
host = "#{host_prefix}#{host}"
|
74
74
|
end
|
75
75
|
|
76
76
|
if options[:scheme_relative]
|
77
77
|
"//#{host}".freeze
|
78
|
-
elsif options[:force_http]
|
78
|
+
elsif options[:force_http] || HTTP_DOMAINS.include?(parent_domain)
|
79
79
|
"http://#{host}".freeze
|
80
80
|
else
|
81
81
|
"https://#{host}".freeze
|
@@ -107,13 +107,6 @@ class Plek
|
|
107
107
|
env_var_or_dev_fallback("GOVUK_ASSET_ROOT") { find("static") }
|
108
108
|
end
|
109
109
|
|
110
|
-
# Find the asset host used to serve assets to the public
|
111
|
-
#
|
112
|
-
# @return [String] The public-facing asset base URL
|
113
|
-
def public_asset_host
|
114
|
-
env_var_or_dev_fallback("GOVUK_ASSET_HOST") { find("static") }
|
115
|
-
end
|
116
|
-
|
117
110
|
# Find the base URL for the public website frontend.
|
118
111
|
#
|
119
112
|
# @return [String] The website base URL.
|
@@ -140,7 +133,7 @@ class Plek
|
|
140
133
|
name = service.to_s.dup
|
141
134
|
name.downcase!
|
142
135
|
name.strip!
|
143
|
-
name.gsub!(/[^a-z\.-]+/,
|
136
|
+
name.gsub!(/[^a-z\.-]+/, "")
|
144
137
|
name
|
145
138
|
end
|
146
139
|
|
@@ -164,10 +157,10 @@ class Plek
|
|
164
157
|
end
|
165
158
|
end
|
166
159
|
|
167
|
-
|
160
|
+
private
|
168
161
|
|
169
162
|
def env_var_or_dev_fallback(var_name, fallback_str = nil)
|
170
|
-
if var = ENV[var_name]
|
163
|
+
if (var = ENV[var_name])
|
171
164
|
var
|
172
165
|
elsif ENV["RAILS_ENV"] == "production" || ENV["RACK_ENV"] == "production"
|
173
166
|
raise(NoConfigurationError, "Expected #{var_name} to be set. Perhaps you should run your task through govuk_setenv <appname>?")
|
@@ -179,12 +172,13 @@ class Plek
|
|
179
172
|
end
|
180
173
|
|
181
174
|
def defined_service_uri_for(service)
|
182
|
-
service_name = service.upcase.gsub(/-/,
|
175
|
+
service_name = service.upcase.gsub(/-/, "_")
|
183
176
|
var_name = "PLEK_SERVICE_#{service_name}_URI"
|
184
177
|
|
185
|
-
if (uri = ENV[var_name]
|
178
|
+
if (uri = ENV[var_name]) && !uri.empty?
|
186
179
|
return uri
|
187
180
|
end
|
188
|
-
|
181
|
+
|
182
|
+
nil
|
189
183
|
end
|
190
184
|
end
|
data/lib/plek/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: climate_control
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -39,7 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-govuk
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -83,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
97
|
- !ruby/object:Gem::Version
|
84
98
|
version: '0'
|
85
99
|
requirements: []
|
86
|
-
rubygems_version: 3.0.
|
100
|
+
rubygems_version: 3.0.3
|
87
101
|
signing_key:
|
88
102
|
specification_version: 4
|
89
103
|
summary: Locations for services
|