plek 2.1.0 → 2.1.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -6
  3. data/lib/plek.rb +8 -4
  4. data/lib/plek/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db58b6a4a924d4c06eed2f4aa05251a733b71ccf
4
- data.tar.gz: 4a59305d33e96a082ecce8e9908aadacc8bc21f6
3
+ metadata.gz: 42c206eb83b9c41dc31647b2d72dc48efaaff889
4
+ data.tar.gz: 5c8371aed356ad734c2ce789e488e3a2c473d794
5
5
  SHA512:
6
- metadata.gz: db7341e606a4629f61f87ccf1cb2087f2b70a10bf3513cd301e6e867313eab3dc52ca3bfc6a2e69a900352f66f707634f8ebc33866e70d50ecba071f5d5f81d3
7
- data.tar.gz: afc6924a5f847f6268f16561caa194fbe491509d3f899b38bc36d022dd5f6c62e6a0c1f1920432b2d8f483d04646ef4a9dbbb02cd217471a5bcf0299233c3ea0
6
+ metadata.gz: dee761715a61b7ab2cd78b874b3ca0e22810893b31cdd9273b10ff629fdf5451572e409ed5015ca3685259197e74a2c3a2c14d83ebf942a84352c850b233ab26
7
+ data.tar.gz: 4049d5ad0a3f9b58a14109e0f47c677c80314b385b34ad1e78e3dfa11934c4d82012db7de2d9e9918d819274642ca4367411649a426a7113bc8888e3869e6cc7
data/README.md CHANGED
@@ -3,14 +3,28 @@
3
3
  "Plek" is Afrikaans. It means "Location". Plek is used to generate the correct
4
4
  base URLs for internal GOV.UK services, eg:
5
5
 
6
- ```ruby
7
- Plek.find('frontend')
8
6
  ```
7
+ # on a dev machine
8
+ > Plek.find('frontend')
9
+ => "http://frontend.dev.gov.uk"
10
+ # on a production machine
11
+ > Plek.find('frontend')
12
+ => "https://frontend.publishing.service.gov.uk"
13
+ ```
14
+
15
+ This means we can use this in our code and let our environment configuration
16
+ figure out the correct hosts for us at runtime.
17
+
18
+ In an environment where we have internal hostnames and external ones an option
19
+ of `external` can be provided to determine whether an internal or external
20
+ host is returned.
9
21
 
10
- returns `http://frontend.dev.gov.uk` on a development machine and
11
- `https://frontend.publishing.service.gov.uk` on a production machine. This
12
- means we can use this in our code and let our environment configuration figure
13
- out the correct hosts for us at runtime.
22
+ ```
23
+ > Plek.find('frontend')
24
+ => "https://frontend.integration.govuk-internal.digital"
25
+ > Plek.find('frontend', external: true)
26
+ => "https://frontend.integration.publishing.service.gov.uk"
27
+ ```
14
28
 
15
29
  ## Technical documentation
16
30
 
@@ -26,15 +26,19 @@ class Plek
26
26
 
27
27
  # Construct a new Plek instance.
28
28
  #
29
- # @param domain_to_use [String] Optionally override the parent domain to use.
30
- # If unspecified, this uses the +GOVUK_APP_DOMAIN+ environment variable.
29
+ # @param domain_to_use [String, nil] Optionally override the parent domain
30
+ # to use. If unspecified, this uses the +GOVUK_APP_DOMAIN+ environment
31
+ # variable.
31
32
  #
32
33
  # In development mode, this falls back to {DEV_DOMAIN} if the environment
33
34
  # variable is unset.
35
+ # @param external_domain [String, nil] Optionally override the external
36
+ # domain to use. If unspecified it will fall back to using
37
+ # +GOVUK_APP_DOMAIN_EXTERNAL+ and if that is unavailable the parent domain
38
+ # will be used
34
39
  def initialize(domain_to_use = nil, external_domain = nil)
35
40
  self.parent_domain = domain_to_use || env_var_or_dev_fallback("GOVUK_APP_DOMAIN", DEV_DOMAIN)
36
- self.external_domain = external_domain ||
37
- env_var_or_dev_fallback("GOVUK_APP_DOMAIN_EXTERNAL", DEV_DOMAIN)
41
+ self.external_domain = external_domain || ENV["GOVUK_APP_DOMAIN_EXTERNAL"] || parent_domain
38
42
  end
39
43
 
40
44
  # Find the base URL for a service/application. This constructs the URL from
@@ -1,3 +1,3 @@
1
1
  class Plek
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plek
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig R Webster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-30 00:00:00.000000000 Z
11
+ date: 2018-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake