govuk_publishing_components 21.63.3 → 21.64.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dfe72210f443a0c8d4f94c41fc1996bffa3fe47b772ecc7851c4c223612d4c5
4
- data.tar.gz: 299ba77eba106b9d4ba23257ff645fefa8b9a6ea5e5aa010f9f564a821d0fa73
3
+ metadata.gz: 19018ea589b383f250f5b7298d06301f5b55e196b475b092e80f707f09bd399b
4
+ data.tar.gz: 1748c5cd55d806fe8e5ef22025ad348a5fe720a045d7879644980224693f8986
5
5
  SHA512:
6
- metadata.gz: b9a85dda00e7198025eff0c30434c57ccf72e10840d81d32f8990ad9cb08d6989735eb387cfad56d09486e56d848662d27df14c14686dd47e24f5e444da2f02e
7
- data.tar.gz: 0b95e6218d7772692270f7257545fe62a30608e9627f8f7b527e621f11a1f70d319af5b07a066c1fdbe5618fbfed1d580e4793f29f8b99a425bbe14de7a39f67
6
+ metadata.gz: 209e7cf684d04b5be7ad3c45ad8a0083c2da82c170877fca927b51b5c422e89f82de285b9c2131f5db65996aac0a28af4a7c680d34ffb827ba382b0682314d10
7
+ data.tar.gz: 17df0e8345e4fb29baaf8c3c61eeb63c68acaebdcc30a3f4cdc07e857b18f1b45368d1178717008b5027c9de1c2fffb2d4c9d84ee20c4db976376937939e4aec
@@ -12,18 +12,22 @@ module GovukPublishingComponents
12
12
  }.freeze
13
13
 
14
14
  # Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
15
- def self.call(content_item)
16
- new(content_item).breadcrumbs
15
+ def self.call(content_item, query_parameters = nil)
16
+ new(content_item, query_parameters).breadcrumbs
17
17
  end
18
18
 
19
- attr_reader :content_item
19
+ attr_reader :content_item, :query_parameters
20
20
 
21
- def initialize(content_item)
21
+ def initialize(content_item, query_parameters = nil)
22
22
  @content_item = content_item
23
+ @query_parameters = query_parameters
23
24
  end
24
25
 
25
26
  def taxon
26
- @taxon ||= priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
27
+ @taxon ||= begin
28
+ default_taxon = priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
29
+ preferred_taxon || default_taxon
30
+ end
27
31
  end
28
32
 
29
33
  def breadcrumbs
@@ -39,6 +43,12 @@ module GovukPublishingComponents
39
43
 
40
44
  private
41
45
 
46
+ def preferred_taxon
47
+ if preferred_priority_taxon
48
+ priority_taxons.find { |t| t["content_id"] == preferred_priority_taxon }
49
+ end
50
+ end
51
+
42
52
  def priority_taxons
43
53
  return [] unless content_item["links"].is_a?(Hash)
44
54
 
@@ -57,6 +67,10 @@ module GovukPublishingComponents
57
67
  def priority_taxon?(taxon)
58
68
  PRIORITY_TAXONS.values.include?(taxon["content_id"])
59
69
  end
70
+
71
+ def preferred_priority_taxon
72
+ query_parameters["priority-taxon"] if query_parameters
73
+ end
60
74
  end
61
75
  end
62
76
  end
@@ -30,7 +30,7 @@ module GovukPublishingComponents
30
30
  end
31
31
 
32
32
  def priority_breadcrumbs
33
- @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item)
33
+ @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item, query_parameters)
34
34
  end
35
35
 
36
36
  def topic_breadcrumbs
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.63.3".freeze
2
+ VERSION = "21.64.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.63.3
4
+ version: 21.64.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: 2020-09-03 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config