publishing_platform_schemas 0.1.1 → 0.1.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9908506b494629e6db1c0e9f7913926bb57d7e7bba972b9cca8f688ee48a3f
|
4
|
+
data.tar.gz: ae8b12485e1e19ad35971943ca96b50b4703b43d6e16aebcfbb904fa2ab670f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f1ac7e89d3353f4f83a1f95629022c19328ac7d8942dd95914d7447ef3b2832b1ec89351f12e05300a1bd70698c4b823de8b9c69775957ba58b2c7c6fb9ab4
|
7
|
+
data.tar.gz: c8da8abc17516ec011c1fa469080b6955513b1b0cc36bbba3a28ac16cbbe40c09851b7573b7e1fa234913869c17960d0972c107887f29de6959113ba12c8c6c6
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module PublishingPlatformSchemas
|
2
|
+
class Example
|
3
|
+
# Find all examples for a schema
|
4
|
+
#
|
5
|
+
# @param schema_name [String] like "detailed_guide", "policy" or "publication"
|
6
|
+
# @return [Array] array of example content items
|
7
|
+
def self.find_all(schema_name)
|
8
|
+
Dir.glob("#{examples_path(schema_name)}/*.json").map do |filename|
|
9
|
+
json = File.read(filename)
|
10
|
+
JSON.parse(json)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Find an example by name
|
15
|
+
#
|
16
|
+
# @param schema_name [String] like "detailed_guide", "policy" or "publication"
|
17
|
+
# @param example_name [String] the name of the example JSON file
|
18
|
+
# @return [Hash] the example content item
|
19
|
+
def self.find(schema_name, example_name:)
|
20
|
+
json = File.read("#{examples_path(schema_name)}/#{example_name}.json")
|
21
|
+
JSON.parse(json)
|
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 = "#{PublishingPlatformSchemas.content_schema_dir}/examples"
|
31
|
+
if Dir.exist?(examples_dir)
|
32
|
+
"#{examples_dir}/#{schema_name}/frontend"
|
33
|
+
else
|
34
|
+
"#{PublishingPlatformSchemas.content_schema_dir}/formats/#{schema_name}/frontend/examples"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishing_platform_schemas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Publishing Platform
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-03 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: json-schema
|
@@ -73,7 +72,6 @@ dependencies:
|
|
73
72
|
- !ruby/object:Gem::Version
|
74
73
|
version: '0'
|
75
74
|
description: Gem to work with the Publishing Platform content schemas
|
76
|
-
email:
|
77
75
|
executables: []
|
78
76
|
extensions: []
|
79
77
|
extra_rdoc_files: []
|
@@ -91,14 +89,13 @@ files:
|
|
91
89
|
- bin/console
|
92
90
|
- bin/setup
|
93
91
|
- lib/publishing_platform_schemas.rb
|
92
|
+
- lib/publishing_platform_schemas/example.rb
|
94
93
|
- lib/publishing_platform_schemas/schema.rb
|
95
94
|
- lib/publishing_platform_schemas/version.rb
|
96
95
|
- publishing_platform_schemas.gemspec
|
97
|
-
homepage:
|
98
96
|
licenses:
|
99
97
|
- MIT
|
100
98
|
metadata: {}
|
101
|
-
post_install_message:
|
102
99
|
rdoc_options: []
|
103
100
|
require_paths:
|
104
101
|
- lib
|
@@ -113,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
110
|
- !ruby/object:Gem::Version
|
114
111
|
version: '0'
|
115
112
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
-
signing_key:
|
113
|
+
rubygems_version: 3.6.6
|
118
114
|
specification_version: 4
|
119
115
|
summary: Gem to work with the Publishing Platform content schemas
|
120
116
|
test_files: []
|