publishing_platform_location 0.2.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77c35943b03cb4e040b83b274fd950ac14eda328a0931a72dc442897009bf38c
4
- data.tar.gz: 77a17a9950dc7ccef0db815343b06cc88ad45f7484c63e2344d6987de9c75847
3
+ metadata.gz: f00b714fabf803b85a9dec4c1fca3219d9b947127f2ea201812f788628ebca51
4
+ data.tar.gz: 02efac1aeb47df4e2be0bf3883c9a4e27f08ddb1b266296128c9b4952392d1f5
5
5
  SHA512:
6
- metadata.gz: 17182fe6879038f28913b772f58700c20de117f891d0aeefd64b7b5d7e6bcb7d2d216b584b42f4740a5c348120c0276726ebb4e3f75451cea46632aba4ac5e43
7
- data.tar.gz: 605844317f619c688c4d2b7deb83501e88cb13b4cc5e6685a561d250a3c4a718adeaa2eeb3b8d0db4ca585f13fdf28e5e6b5b6ba721978445801ac4170ba550e
6
+ metadata.gz: 961d671ce82053d8c34bf6c35f853228a6d3bf2df1d695e7b1b7d03a5b09ad3e5c238603ab8809ca38df9798c7471fd12b6f6a31ad07b79c4d3f3466ab7bec80
7
+ data.tar.gz: 16c2d52914e5d2e176a3b4082478e5e3a0a808d466313150ac218498f25bc6c3df6f2e28f8f9685383dc5b61673ea36ef61536940cb62e01412b6312d371bacb
data/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # publishing_platform_location
1
+ # Publishing Platform Location
2
2
  Generates URLs for publishing platform services based on environment.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PublishingPlatformLocation
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -10,24 +10,25 @@ class PublishingPlatformLocation
10
10
  # The fallback parent domain to use in development mode.
11
11
  DEV_DOMAIN = "dev.publishing-platform.co.uk"
12
12
 
13
- attr_reader :parent_domain, :external_domain, :host_prefix
13
+ attr_reader :parent_domain, :external_domain
14
14
 
15
15
  # Construct a new PublishingPlatformLocation instance.
16
16
  def initialize(domain_to_use = nil, external_domain = nil)
17
17
  @parent_domain = domain_to_use || env_var_or_fallback("PUBLISHING_PLATFORM_APP_DOMAIN", DEV_DOMAIN) # empty string for internal services
18
18
  @external_domain = external_domain || ENV.fetch("PUBLISHING_PLATFORM_APP_DOMAIN_EXTERNAL", @parent_domain)
19
- @host_prefix = ENV.fetch("PUBLISHING_PLATFORM_LOCATION_HOSTNAME_PREFIX", "")
19
+ @host_prefix = ENV.fetch("PUBLISHING_PLATFORM_LOCATION_HOSTNAME_PREFIX", "")
20
+ @unprefixable_hosts = ENV.fetch("PUBLISHING_PLATFORM_LOCATION_UNPREFIXABLE_HOSTS", "").split(",").map(&:strip)
20
21
  end
21
22
 
22
23
  # Find the base URL for a service/application.
23
24
  def find(service, options = {})
24
25
  name = valid_service_name(service)
25
26
 
26
- name = "#{host_prefix}#{name}"
27
-
28
27
  if (service_uri = defined_service_uri_for(name))
29
28
  return service_uri
30
- end
29
+ end
30
+
31
+ name = "#{host_prefix}#{name}" unless unprefixable_hosts.include?(name)
31
32
 
32
33
  domain = options[:external] ? external_domain : parent_domain
33
34
  domain_suffix = domain.empty? ? "" : ".#{domain}" # empty string for internal services
@@ -59,6 +60,8 @@ class PublishingPlatformLocation
59
60
 
60
61
  private
61
62
 
63
+ attr_reader :host_prefix, :unprefixable_hosts
64
+
62
65
  def valid_service_name(name)
63
66
  service_name = name.to_s
64
67
  return service_name if service_name.match?(/\A[a-z1-9.-]+\z/)
@@ -86,11 +89,11 @@ private
86
89
  # environment variable.
87
90
  #
88
91
  # e.g. if PUBLISHING_PLATFORM_LOCATION_SERVICE_CHEESE_THING_URI
89
- # was set, +PublishingPlatformLocation.new.find('cheese-thing')+
90
- # would return the value of that variable.
92
+ # was set, +PublishingPlatformLocation.new.find('cheese-thing')+
93
+ # would return the value of that variable.
91
94
  def defined_service_uri_for(service)
92
95
  service_name = service.upcase.tr("-", "_")
93
96
  uri = ENV.fetch("PUBLISHING_PLATFORM_LOCATION_SERVICE_#{service_name}_URI", "")
94
97
  uri.empty? ? nil : uri
95
- end
98
+ end
96
99
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publishing_platform_location
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Publishing Platform
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: climate_control
@@ -38,8 +37,21 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: simplecov
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
41
54
  description: Generates URLs for publishing platform services based on environment.
42
- email:
43
55
  executables: []
44
56
  extensions: []
45
57
  extra_rdoc_files: []
@@ -48,11 +60,9 @@ files:
48
60
  - README.md
49
61
  - lib/publishing_platform_location.rb
50
62
  - lib/publishing_platform_location/version.rb
51
- homepage:
52
63
  licenses:
53
64
  - MIT
54
65
  metadata: {}
55
- post_install_message:
56
66
  rdoc_options: []
57
67
  require_paths:
58
68
  - lib
@@ -60,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
70
  requirements:
61
71
  - - ">="
62
72
  - !ruby/object:Gem::Version
63
- version: '3.0'
73
+ version: '3.2'
64
74
  required_rubygems_version: !ruby/object:Gem::Requirement
65
75
  requirements:
66
76
  - - ">="
67
77
  - !ruby/object:Gem::Version
68
78
  version: '0'
69
79
  requirements: []
70
- rubygems_version: 3.3.7
71
- signing_key:
80
+ rubygems_version: 4.0.9
72
81
  specification_version: 4
73
82
  summary: Generates URLs for publishing platform services based on environment.
74
83
  test_files: []