plek 2.0.0 → 2.1.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 -3
  3. data/lib/plek/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a4e57ba04bdaed9c12a5cfda39e40b8a7b9e49a
4
- data.tar.gz: 7fb41bdf33d4f3ce101f339cdbd1daea95318438
3
+ metadata.gz: db58b6a4a924d4c06eed2f4aa05251a733b71ccf
4
+ data.tar.gz: 4a59305d33e96a082ecce8e9908aadacc8bc21f6
5
5
  SHA512:
6
- metadata.gz: cb81b99d7eae93c1acc01a321a56296d1c88595deef7ab9863e7f20b0486cddf8a4f3095001d5713d4f34d61ac41ca388d18ac9dd2d3a2b028e707d812294fa6
7
- data.tar.gz: 0529dd33cc435710a61861834c0202b25ec72e4dc0a47e97188856d3317f3905af833470a3e5bbc7420fa2dee79def7070e3e981381b7339b89aa5f049fe5b18
6
+ metadata.gz: db7341e606a4629f61f87ccf1cb2087f2b70a10bf3513cd301e6e867313eab3dc52ca3bfc6a2e69a900352f66f707634f8ebc33866e70d50ecba071f5d5f81d3
7
+ data.tar.gz: afc6924a5f847f6268f16561caa194fbe491509d3f899b38bc36d022dd5f6c62e6a0c1f1920432b2d8f483d04646ef4a9dbbb02cd217471a5bcf0299233c3ea0
@@ -22,7 +22,7 @@ class Plek
22
22
  # Domains to return http URLs for.
23
23
  HTTP_DOMAINS = [ DEV_DOMAIN ]
24
24
 
25
- attr_accessor :parent_domain
25
+ attr_accessor :parent_domain, :external_domain
26
26
 
27
27
  # Construct a new Plek instance.
28
28
  #
@@ -31,8 +31,10 @@ class Plek
31
31
  #
32
32
  # In development mode, this falls back to {DEV_DOMAIN} if the environment
33
33
  # variable is unset.
34
- def initialize(domain_to_use = nil)
34
+ def initialize(domain_to_use = nil, external_domain = nil)
35
35
  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)
36
38
  end
37
39
 
38
40
  # Find the base URL for a service/application. This constructs the URL from
@@ -61,7 +63,7 @@ class Plek
61
63
  return service_uri
62
64
  end
63
65
 
64
- host = "#{name}.#{parent_domain}"
66
+ host = "#{name}.#{options[:external] ? external_domain : parent_domain}"
65
67
 
66
68
  if host_prefix = ENV['PLEK_HOSTNAME_PREFIX']
67
69
  host = "#{host_prefix}#{host}"
@@ -76,6 +78,15 @@ class Plek
76
78
  end
77
79
  end
78
80
 
81
+ # Find the external URL for a service/application.
82
+ #
83
+ # @param service [String] the name of the service to lookup. This should be
84
+ # the hostname of the service.
85
+ # @param options [Hash] see the documentation for find.
86
+ def external_url_for(service, options = {})
87
+ find(service, options.merge(external: true))
88
+ end
89
+
79
90
  # Find the base URL for a service/application, and parse as a URI object.
80
91
  # This wraps #find and returns the parsed result.
81
92
  #
@@ -1,3 +1,3 @@
1
1
  class Plek
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
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.0.0
4
+ version: 2.1.0
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: 2017-03-10 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake