govuk_schemas 2.2.0 → 2.3.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
  SHA1:
3
- metadata.gz: 1e3774ac312636e52ae77ba38deab3b6f1e749cf
4
- data.tar.gz: 43ab66a728f531e8881da0daf96ec0327b42baf5
3
+ metadata.gz: 0159a5f0fe899f67971dd67034deba8635b35e8d
4
+ data.tar.gz: aac60f618ada4ceaf5dd8393c92b3481f4a73d13
5
5
  SHA512:
6
- metadata.gz: 231ae75cf41f46f6417a365b1b9bf39bad8fdf49cc65e3dec554371cd6dcbb92b6f47db3e3c1615c14d535c91ae37ad8511790ac72cc08560683b59b9022c72c
7
- data.tar.gz: 772c6a9f27ca821ac05d2a5eae881b9be999b25649c6143efe56507c88156f47b900031ef69617390f0726ad5f32dcab0fbf841d112c8cba62d2f1f5c693572c
6
+ metadata.gz: f523a79a97ea8b5f2b2d0628acf9fe63a39e12bc90e93c86a1500f0c40ada8227096c0e9193e265ed586c77fe005d703764312fe18e3e6af5d73debb2b37ef06
7
+ data.tar.gz: 255d1f6196893e54f95eb1bd80ac579251030bc9c248a84eb5d4ee49f04e8cd1620cd29f9a8af3495832c55f5e8f44f6c8ac43ee64cb8e79ba83e1b2533105f1
@@ -1,3 +1,7 @@
1
+ # 2.3.0
2
+
3
+ * Allow looking up examples to work with schemas stored in `formats/{format}/{schema_type}/examples/` and `examples/{format}/{schema_type}/` to allow schema examples to move.
4
+
1
5
  # 2.2.0
2
6
 
3
7
  * Add RSpec test helpers
@@ -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("#{GovukSchemas::CONTENT_SCHEMA_DIR}/formats/#{schema_name}/frontend/examples/*.json").map do |filename|
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
- path = "/formats/#{schema_name}/frontend/examples/#{example_name}.json"
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
@@ -1,4 +1,4 @@
1
1
  module GovukSchemas
2
2
  # @private
3
- VERSION = "2.2.0".freeze
3
+ VERSION = "2.3.0".freeze
4
4
  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.2.0
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-08-09 00:00:00.000000000 Z
11
+ date: 2017-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema