Sha256: 1e90943f645893df4ddfa4907a8de549d265dd20b33b0aaa5262ece14402e054
Contents?: true
Size: 917 Bytes
Versions: 3
Compression:
Stored size: 917 Bytes
Contents
module GovukSchemas class Example # Find all examples for a schema # # @param schema_name [String] like "detailed_guide", "policy" or "publication" # @return [Array] array of example content items def self.find_all(schema_name) Dir.glob("#{GovukSchemas::CONTENT_SCHEMA_DIR}/formats/#{schema_name}/frontend/examples/*.json").map do |filename| json = File.read(filename) JSON.parse(json) end end # Find an example by name # # @param schema_name [String] like "detailed_guide", "policy" or "publication" # @param example_name [String] the name of the example JSON file # @return [Hash] the example content item def self.find(schema_name, example_name:) path = "/formats/#{schema_name}/frontend/examples/#{example_name}.json" json = File.read("#{GovukSchemas::CONTENT_SCHEMA_DIR}#{path}") JSON.parse(json) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
govuk_schemas-2.2.0 | lib/govuk_schemas/example.rb |
govuk_schemas-2.1.1 | lib/govuk_schemas/example.rb |
govuk_schemas-2.1.0 | lib/govuk_schemas/example.rb |