govuk_schemas 2.2.0 → 2.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/govuk_schemas/example.rb +16 -3
- data/lib/govuk_schemas/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0159a5f0fe899f67971dd67034deba8635b35e8d
|
4
|
+
data.tar.gz: aac60f618ada4ceaf5dd8393c92b3481f4a73d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f523a79a97ea8b5f2b2d0628acf9fe63a39e12bc90e93c86a1500f0c40ada8227096c0e9193e265ed586c77fe005d703764312fe18e3e6af5d73debb2b37ef06
|
7
|
+
data.tar.gz: 255d1f6196893e54f95eb1bd80ac579251030bc9c248a84eb5d4ee49f04e8cd1620cd29f9a8af3495832c55f5e8f44f6c8ac43ee64cb8e79ba83e1b2533105f1
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,7 @@ module GovukSchemas
|
|
5
5
|
# @param schema_name [String] like "detailed_guide", "policy" or "publication"
|
6
6
|
# @return [Array] array of example content items
|
7
7
|
def self.find_all(schema_name)
|
8
|
-
Dir.glob("#{
|
8
|
+
Dir.glob("#{examples_path(schema_name)}/*.json").map do |filename|
|
9
9
|
json = File.read(filename)
|
10
10
|
JSON.parse(json)
|
11
11
|
end
|
@@ -17,9 +17,22 @@ module GovukSchemas
|
|
17
17
|
# @param example_name [String] the name of the example JSON file
|
18
18
|
# @return [Hash] the example content item
|
19
19
|
def self.find(schema_name, example_name:)
|
20
|
-
|
21
|
-
json = File.read("#{GovukSchemas::CONTENT_SCHEMA_DIR}#{path}")
|
20
|
+
json = File.read("#{examples_path(schema_name)}/#{example_name}.json")
|
22
21
|
JSON.parse(json)
|
23
22
|
end
|
23
|
+
|
24
|
+
# Examples are changing location in schemas, this allows this utility
|
25
|
+
# to work with both locations
|
26
|
+
#
|
27
|
+
# @param schema_name [String] like "detailed_guide", "policy" or "publication"
|
28
|
+
# @return [String] the path to use for examples
|
29
|
+
def self.examples_path(schema_name)
|
30
|
+
examples_dir = "#{GovukSchemas::CONTENT_SCHEMA_DIR}/examples"
|
31
|
+
if Dir.exist?(examples_dir)
|
32
|
+
"#{examples_dir}/#{schema_name}/frontend"
|
33
|
+
else
|
34
|
+
"#{GovukSchemas::CONTENT_SCHEMA_DIR}/formats/#{schema_name}/frontend/examples"
|
35
|
+
end
|
36
|
+
end
|
24
37
|
end
|
25
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_schemas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
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: 2017-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|