plek 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plek.rb +14 -20
  3. data/lib/plek/version.rb +1 -1
  4. metadata +19 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f009f7c15f4e0b0fa5a5b5f3866e327101ff3ed1a7cc4527e5d3346398bcf3
4
- data.tar.gz: 8ed2fcfc3453d92b3a049f0941bf6026d0f6294f33b51bab9e0d69bfa6608af7
3
+ metadata.gz: dce9ccd2cdfbd98e5f5d400b89afc268e7ac85eede91425d6999a45d8c8241e7
4
+ data.tar.gz: fb644ee1e4abefa8d133083e6dae182c4d6292cd9079a39e890a7d81a7d7846e
5
5
  SHA512:
6
- metadata.gz: a7f2980ae077e50f4f277ad26ece95057c9f486f8f1883e24cb80f47f60b02fc35cd58ab7812642a7348a90d648b2223572609702220e281180e0f5e3b4a8610
7
- data.tar.gz: 48664f58cd9f619b78dea7db04afe260153ac596ce79977d5e07911ef23a68f0e308f9e71ff135ee4636c7ebc6eb9f85880bdf88ec94515a874bac2f2c32a57a
6
+ metadata.gz: 152b9b257a2d0ccc8dc1a0854e0e63ee75464173561d4b6eb781caafbb9a89abcd56ff9bb0cd31bb24f297a23a45d07f6bbd45ceb7911ff34ca88b8539391211
7
+ data.tar.gz: df7e4c1d134ede43491e7bb1e8ff0f1568bf3e9b39a64a2487fae48f800fdda709ca43f092bbaa1eca451a6e3324a7d5c33d73b6e23ea9947032d2efb6e85dd5
@@ -1,5 +1,5 @@
1
- require 'plek/version'
2
- require 'uri'
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 = 'dev.gov.uk'
20
+ DEV_DOMAIN = "dev.gov.uk".freeze
21
21
 
22
22
  # Domains to return http URLs for.
23
- HTTP_DOMAINS = [ DEV_DOMAIN ]
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['PLEK_HOSTNAME_PREFIX']
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] or HTTP_DOMAINS.include?(parent_domain)
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
- private
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] and ! uri.empty?)
178
+ if (uri = ENV[var_name]) && !uri.empty?
186
179
  return uri
187
180
  end
188
- return nil
181
+
182
+ nil
189
183
  end
190
184
  end
@@ -1,3 +1,3 @@
1
1
  class Plek
2
- VERSION = '3.0.0'
2
+ VERSION = "4.0.0".freeze
3
3
  end
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: 3.0.0
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: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
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: climate_control
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.1
100
+ rubygems_version: 3.0.3
87
101
  signing_key:
88
102
  specification_version: 4
89
103
  summary: Locations for services