govuk_document_types 0.7.1 → 0.9.3
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 +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +25 -0
- data/README.md +17 -22
- data/data/supertypes.yml +4 -12
- data/govuk_document_types.gemspec +1 -0
- data/lib/govuk_document_types.rb +27 -2
- data/lib/govuk_document_types/translations_railtie.rb +21 -0
- data/lib/govuk_document_types/version.rb +1 -1
- data/rails/locale/en.yml +28 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adad4f61a5d78fa9a467e79a12d0bafc4b54c1f0c5f6d7acbf0c458914936d6e
|
4
|
+
data.tar.gz: b1c6c9604283374fd65653ad1b241464a2e37aff574dbcfe99b159ebcbc9410e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 761e2b47246c3e50a6b2b719f5932eb1845b2bf869f3670e5bc5b37ab75cec4edddc46cda0e1434d9c5bde20009662a195b31e34434acf98853ad85fb5756c57
|
7
|
+
data.tar.gz: d623119238d20bf59edc1d35dd97156c308b43638dd04538e90cf6c3244bb06b4f5735413a86a0187d5c6afd62b11b79c82eeaeb8441bb1cad0a4e0ca8ed3766
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
# 0.9.3
|
2
|
+
|
3
|
+
* Added `standard` subtype to the guidance group
|
4
|
+
|
5
|
+
# 0.9.2
|
6
|
+
|
7
|
+
* Moved `case_study` from policy papers and consultations to news and comms.
|
8
|
+
|
9
|
+
# 0.9.1
|
10
|
+
|
11
|
+
* Removed `contact` from the guidance group.
|
12
|
+
|
13
|
+
# 0.9.0
|
14
|
+
|
15
|
+
* Add translations to content purpose supergroup titles
|
16
|
+
|
17
|
+
# 0.8.0
|
18
|
+
|
19
|
+
* Adds `GovukDocumentTypes.supergroup_subgroups` as a way to retrieve
|
20
|
+
subgroups registered to the specified supergroups.
|
21
|
+
* Adds `GovukDocumentTypes.supergroup_document_types` as a way to retrieve
|
22
|
+
document types registered to the specified supergroups.
|
23
|
+
* Adds `GovukDocumentTypes.subgroup_document_types` as a way to retrieve
|
24
|
+
document types registered to the specified subgroups.
|
25
|
+
|
1
26
|
# 0.7.1
|
2
27
|
|
3
28
|
* Add `hrmc_manual` format to `guidance` `content_purpose_subgroup`
|
data/README.md
CHANGED
@@ -5,26 +5,29 @@ of document types.
|
|
5
5
|
|
6
6
|
https://docs.publishing.service.gov.uk/document-types.html
|
7
7
|
|
8
|
-
|
9
|
-
[rummager][rummager]. **Don't use it in your project**.
|
8
|
+
## Usage
|
10
9
|
|
11
|
-
## Long term vision
|
12
10
|
|
13
|
-
|
11
|
+
Find the supertypes for a document type:
|
14
12
|
|
15
|
-
|
13
|
+
```rb
|
14
|
+
supertypes = GovukDocumentTypes.supertypes(document_type: "detailed_guide")
|
15
|
+
supertypes["content_purpose_subgroup"]
|
16
|
+
=> "guidance"
|
17
|
+
```
|
16
18
|
|
17
|
-
|
18
|
-
2. [Add the supertype][rummager-pr] in Rummager so that it can be indexed and searched with. Bump the gem in Rummager.
|
19
|
-
3. [Add the type to content-schemas][schemas-pr]
|
20
|
-
4. [Add the type to the content-store][content-store-pr]
|
21
|
-
5. Bump the gem version in [publishing-api][publishing-api]
|
19
|
+
Find the document types for a supertype:
|
22
20
|
|
23
|
-
|
21
|
+
```rb
|
22
|
+
GovukDocumentTypes.supergroup_document_types("policy_and_engagement")
|
23
|
+
=> ["case_study", "closed_consultation", "consultation_outcome", "impact_assessment", "open_consultation", "policy_paper"]
|
24
|
+
```
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
## How to add or update a supertype
|
27
|
+
|
28
|
+
1. Add it to [data/supertypes.yml](data/supertypes.yml) in this gem and release a new version
|
29
|
+
2. Bump the gem version across GOV.UK apps using [Dependabot](https://app.dependabot.com/)
|
30
|
+
3. Run the `rummager:update_supertypes` rake task in Search-api to set the correct supertypes in each document in the Elasticsearch indices. Do this _after_ bumping the gem version because this rake task uses information in the gem to find the correct supertype for the document_type defined in each document.
|
28
31
|
|
29
32
|
## Running the test suite
|
30
33
|
|
@@ -35,11 +38,3 @@ bundle exec rake
|
|
35
38
|
## License
|
36
39
|
|
37
40
|
[MIT License](LICENSE.txt)
|
38
|
-
|
39
|
-
[rummager-pr]: https://github.com/alphagov/rummager/pull/756
|
40
|
-
[govuk-content-schemas]: https://github.com/alphagov/govuk-content-schemas
|
41
|
-
[schemas-pr]: https://github.com/alphagov/govuk-content-schemas/pull/551
|
42
|
-
[content-store-pr]: https://github.com/alphagov/content-store/pull/268
|
43
|
-
|
44
|
-
[publishing-api]: https://github.com/alphagov/publishing-api
|
45
|
-
[rummager]: https://github.com/alphagov/rummager
|
data/data/supertypes.yml
CHANGED
@@ -161,8 +161,6 @@ content_purpose_document_supertype:
|
|
161
161
|
# "Tags"
|
162
162
|
- document_collection
|
163
163
|
- mainstream_browse_page
|
164
|
-
- policy
|
165
|
-
- policy_area
|
166
164
|
- taxon
|
167
165
|
- topic
|
168
166
|
|
@@ -224,8 +222,6 @@ user_journey_document_supertype:
|
|
224
222
|
- license_finder
|
225
223
|
- mainstream_browse_page
|
226
224
|
- organisation
|
227
|
-
- policy
|
228
|
-
- policy_area
|
229
225
|
- search
|
230
226
|
- service_manual_homepage
|
231
227
|
- service_manual_topic
|
@@ -392,6 +388,7 @@ content_purpose_subgroup:
|
|
392
388
|
- drug_safety_update
|
393
389
|
- id: news
|
394
390
|
document_types:
|
391
|
+
- case_study
|
395
392
|
- news_article
|
396
393
|
- news_story
|
397
394
|
- press_release
|
@@ -441,7 +438,6 @@ content_purpose_subgroup:
|
|
441
438
|
- manual_section
|
442
439
|
- guidance
|
443
440
|
- map
|
444
|
-
- contact
|
445
441
|
- calendar
|
446
442
|
- statutory_guidance
|
447
443
|
- notice
|
@@ -449,6 +445,7 @@ content_purpose_subgroup:
|
|
449
445
|
- travel_advice
|
450
446
|
- promotional
|
451
447
|
- hmrc_manual
|
448
|
+
- standard
|
452
449
|
- id: business_support
|
453
450
|
document_types:
|
454
451
|
- international_development_fund
|
@@ -458,7 +455,6 @@ content_purpose_subgroup:
|
|
458
455
|
- id: policy
|
459
456
|
document_types:
|
460
457
|
- impact_assessment
|
461
|
-
- case_study
|
462
458
|
- policy_paper
|
463
459
|
- id: consultations
|
464
460
|
document_types:
|
@@ -521,6 +517,7 @@ content_purpose_supergroup:
|
|
521
517
|
- correspondence
|
522
518
|
- speech
|
523
519
|
- government_response
|
520
|
+
- case_study
|
524
521
|
- id: services
|
525
522
|
document_types:
|
526
523
|
- completed_transaction
|
@@ -543,7 +540,6 @@ content_purpose_supergroup:
|
|
543
540
|
- manual_section
|
544
541
|
- guidance
|
545
542
|
- map
|
546
|
-
- contact
|
547
543
|
- calendar
|
548
544
|
- statutory_guidance
|
549
545
|
- notice
|
@@ -556,10 +552,10 @@ content_purpose_supergroup:
|
|
556
552
|
- business_finance_support_scheme
|
557
553
|
- statutory_instrument
|
558
554
|
- hmrc_manual
|
555
|
+
- standard
|
559
556
|
- id: policy_and_engagement
|
560
557
|
document_types:
|
561
558
|
- impact_assessment
|
562
|
-
- case_study
|
563
559
|
- policy_paper
|
564
560
|
- open_consultation
|
565
561
|
- closed_consultation
|
@@ -584,7 +580,3 @@ content_purpose_supergroup:
|
|
584
580
|
- aaib_report
|
585
581
|
- raib_report
|
586
582
|
- maib_report
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
data/lib/govuk_document_types.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
+
require "govuk_document_types/translations_railtie" if defined?(Rails)
|
1
2
|
require "govuk_document_types/version"
|
2
3
|
require "yaml"
|
3
4
|
|
4
5
|
module GovukDocumentTypes
|
5
|
-
|
6
|
+
SUPERTYPES = YAML.load_file(File.dirname(__FILE__) + "/../data/supertypes.yml")
|
6
7
|
SUPERGROUPS = YAML.load_file(File.dirname(__FILE__) + "/../data/supergroups.yml")
|
7
8
|
|
8
9
|
def self.supertypes(document_type:)
|
9
10
|
types = {}
|
10
11
|
|
11
|
-
|
12
|
+
SUPERTYPES.each do |name, definition|
|
12
13
|
group_data = definition["items"].find do |supertype|
|
13
14
|
supertype['document_types'].include?(document_type)
|
14
15
|
end
|
@@ -24,4 +25,28 @@ module GovukDocumentTypes
|
|
24
25
|
groups = SUPERGROUPS["content_purpose_supergroup"]["items"]
|
25
26
|
groups.select { |g| ids.include?(g["id"]) }
|
26
27
|
end
|
28
|
+
|
29
|
+
def self.supergroup_subgroups(*supergroup_ids)
|
30
|
+
SUPERGROUPS
|
31
|
+
.dig('content_purpose_supergroup', 'items')
|
32
|
+
.select { |supergroup| supergroup_ids.include?(supergroup['id']) }
|
33
|
+
.map { |supergroup| supergroup['subgroups'] }
|
34
|
+
.flatten
|
35
|
+
.uniq
|
36
|
+
.sort
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.supergroup_document_types(*supergroup_ids)
|
40
|
+
subgroup_document_types(*supergroup_subgroups(*supergroup_ids))
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.subgroup_document_types(*subgroup_ids)
|
44
|
+
SUPERTYPES
|
45
|
+
.dig('content_purpose_subgroup', 'items')
|
46
|
+
.select { |subgroup| subgroup_ids.include?(subgroup['id']) }
|
47
|
+
.map { |subgroup| subgroup['document_types'] }
|
48
|
+
.flatten
|
49
|
+
.uniq
|
50
|
+
.sort
|
51
|
+
end
|
27
52
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails'
|
2
|
+
module GovukDocumentTypes
|
3
|
+
class TranslationsRailtie < ::Rails::Railtie
|
4
|
+
initializer 'govuk_document_types' do |app|
|
5
|
+
GovukDocumentTypes::TranslationsRailtie.instance_eval do
|
6
|
+
pattern = pattern_from app.config.i18n.available_locales
|
7
|
+
add("rails/locale/#{pattern}.yml")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.add(pattern)
|
12
|
+
files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)]
|
13
|
+
I18n.load_path.concat(files)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.pattern_from(args)
|
17
|
+
array = Array(args || [])
|
18
|
+
array.blank? ? '*' : "{#{array.join ','}}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/rails/locale/en.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
content_purpose_supergroup:
|
4
|
+
guidance_and_regulation: Guidance and regulation
|
5
|
+
news_and_communications: News and communications
|
6
|
+
policy_and_engagement: Policy papers and consultations
|
7
|
+
research_and_statistics: "Research and statistics"
|
8
|
+
services: Services
|
9
|
+
transparency: Transparency and freedom of information releases
|
10
|
+
content_purpose_subgroup:
|
11
|
+
announcements: Announcements
|
12
|
+
business_support: Business funds and grants
|
13
|
+
consultations: Consultations
|
14
|
+
decisions: Decisions
|
15
|
+
freedom_of_information_releases: Freedom of information releases
|
16
|
+
guidance: Guidance
|
17
|
+
incidents: Incident reports
|
18
|
+
news: News
|
19
|
+
policy: Policy papers
|
20
|
+
regulation: Regulation
|
21
|
+
research: Research
|
22
|
+
safety_alerts: Safety alerts
|
23
|
+
services: Services
|
24
|
+
speeches_and_statements: Speeches and statements
|
25
|
+
statistics: Statistics
|
26
|
+
transactions: Transactions
|
27
|
+
transparency_data: Transparency data
|
28
|
+
updates_and_alerts: Updates and alerts
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_document_types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i18n-spec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Gem to share document type groupings
|
56
70
|
email:
|
57
71
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -75,7 +89,9 @@ files:
|
|
75
89
|
- data/supertypes.yml
|
76
90
|
- govuk_document_types.gemspec
|
77
91
|
- lib/govuk_document_types.rb
|
92
|
+
- lib/govuk_document_types/translations_railtie.rb
|
78
93
|
- lib/govuk_document_types/version.rb
|
94
|
+
- rails/locale/en.yml
|
79
95
|
homepage: https://github.com/alphagov/govuk_document_types
|
80
96
|
licenses:
|
81
97
|
- MIT
|
@@ -95,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
111
|
- !ruby/object:Gem::Version
|
96
112
|
version: '0'
|
97
113
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.7.6
|
114
|
+
rubygems_version: 3.1.4
|
100
115
|
signing_key:
|
101
116
|
specification_version: 4
|
102
117
|
summary: Gem to share document type groupings
|