publishing_platform_schemas 0.1.0 → 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: 88231446d780966954fa7df80621e314cb2d885e187402b7d68e8ee2d10513e2
4
- data.tar.gz: 33fd84d51fab3235f9f5089153939493a7c4a66eca9553a8288e77e55bd3cd74
3
+ metadata.gz: 0b9908506b494629e6db1c0e9f7913926bb57d7e7bba972b9cca8f688ee48a3f
4
+ data.tar.gz: ae8b12485e1e19ad35971943ca96b50b4703b43d6e16aebcfbb904fa2ab670f9
5
5
  SHA512:
6
- metadata.gz: 2d0f1ebc0dc699816e80c3fadf1a88678f5f44b9c0963b8e2c3e797adb908bc1f3f9a5a96ea4a6982cbe5bb2ff83daf8c3b9c57f56ea1ace47f1f51fd172b74f
7
- data.tar.gz: 6671a6f2e8996641695e7b48b76f658180e9945986e81a90ed32c6f92e0352a0e25ac26daac258e1edb7136b51023a5e48e99010d7b930265275db653191718c
6
+ metadata.gz: 12f1ac7e89d3353f4f83a1f95629022c19328ac7d8942dd95914d7447ef3b2832b1ec89351f12e05300a1bd70698c4b823de8b9c69775957ba58b2c7c6fb9ab4
7
+ data.tar.gz: c8da8abc17516ec011c1fa469080b6955513b1b0cc36bbba3a28ac16cbbe40c09851b7573b7e1fa234913869c17960d0972c107887f29de6959113ba12c8c6c6
@@ -0,0 +1,12 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ - package-ecosystem: github-actions
9
+ directory: "/"
10
+ schedule:
11
+ interval: daily
12
+ open-pull-requests-limit: 10
@@ -0,0 +1,46 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ # This matrix job runs the test suite against multiple Ruby versions
7
+ test_matrix:
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [3.2, 3.3]
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - name: Clone content-schemas
16
+ uses: actions/checkout@v4
17
+ with:
18
+ repository: publishing-platform/publishing-api
19
+ ref: main
20
+ path: tmp/publishing-api
21
+ token: ${{ secrets.PUBLISHING_PLATFORM_CI_GITHUB_API_TOKEN }}
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - run: bundle exec rake
27
+ env:
28
+ PUBLISHING_PLATFORM_CONTENT_SCHEMAS_PATH: tmp/publishing-api/content_schemas
29
+
30
+ # Branch protection rules cannot directly depend on status checks from matrix jobs.
31
+ # So instead we define `test` as a dummy job which only runs after the preceding `test_matrix` checks have passed.
32
+ # Solution inspired by: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
33
+ test:
34
+ needs: test_matrix
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - run: echo "All matrix tests have passed 🚀"
38
+
39
+ publish:
40
+ needs: test
41
+ if: ${{ github.ref == 'refs/heads/main' }}
42
+ permissions:
43
+ contents: write
44
+ uses: publishing-platform/publishing-platform-infrastructure/.github/workflows/publish-rubygem.yml@main
45
+ secrets:
46
+ GEM_HOST_API_KEY: ${{ secrets.PUBLISHING_PLATFORM_RUBYGEMS_API_KEY }}
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.4
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "bundler/gem_tasks"
2
+ require "rubocop/rake_task"
4
3
  require "rspec/core/rake_task"
5
4
 
6
5
  RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
7
7
 
8
- task default: :spec
8
+ task default: %i[rubocop spec]
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublishingPlatformSchemas
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "publishing_platform_schemas/version"
4
4
  require_relative "publishing_platform_schemas/schema"
5
+ require_relative "publishing_platform_schemas/example"
5
6
 
6
7
  module PublishingPlatformSchemas
7
8
  def self.content_schema_dir=(path_to_schemas)
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.summary = "Gem to work with the Publishing Platform content schemas"
11
11
  spec.description = "Gem to work with the Publishing Platform content schemas"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = ">= 3.0"
13
+ spec.required_ruby_version = ">= 3.1"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
16
  spec.bindir = "exe"
@@ -20,5 +20,7 @@ Gem::Specification.new do |spec|
20
20
  # This should be kept in sync with the json-schema version of publishing-api.
21
21
  spec.add_dependency "json-schema", ">= 2.8", "< 4.4"
22
22
 
23
+ spec.add_development_dependency "climate_control"
23
24
  spec.add_development_dependency "publishing_platform_rubocop"
25
+ spec.add_development_dependency "simplecov"
24
26
  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.0
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: 2024-07-17 00:00:00.000000000 Z
10
+ date: 2025-04-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: json-schema
@@ -30,6 +29,20 @@ dependencies:
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
31
  version: '4.4'
32
+ - !ruby/object:Gem::Dependency
33
+ name: climate_control
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
33
46
  - !ruby/object:Gem::Dependency
34
47
  name: publishing_platform_rubocop
35
48
  requirement: !ruby/object:Gem::Requirement
@@ -44,16 +57,31 @@ dependencies:
44
57
  - - ">="
45
58
  - !ruby/object:Gem::Version
46
59
  version: '0'
60
+ - !ruby/object:Gem::Dependency
61
+ name: simplecov
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
47
74
  description: Gem to work with the Publishing Platform content schemas
48
- email:
49
75
  executables: []
50
76
  extensions: []
51
77
  extra_rdoc_files: []
52
78
  files:
53
- - ".github/workflows/main.yml"
79
+ - ".github/dependabot.yml"
80
+ - ".github/workflows/ci.yml"
54
81
  - ".gitignore"
55
82
  - ".rspec"
56
83
  - ".rubocop.yml"
84
+ - ".ruby-version"
57
85
  - Gemfile
58
86
  - LICENSE
59
87
  - README.md
@@ -61,14 +89,13 @@ files:
61
89
  - bin/console
62
90
  - bin/setup
63
91
  - lib/publishing_platform_schemas.rb
92
+ - lib/publishing_platform_schemas/example.rb
64
93
  - lib/publishing_platform_schemas/schema.rb
65
94
  - lib/publishing_platform_schemas/version.rb
66
95
  - publishing_platform_schemas.gemspec
67
- homepage:
68
96
  licenses:
69
97
  - MIT
70
98
  metadata: {}
71
- post_install_message:
72
99
  rdoc_options: []
73
100
  require_paths:
74
101
  - lib
@@ -76,15 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
103
  requirements:
77
104
  - - ">="
78
105
  - !ruby/object:Gem::Version
79
- version: '3.0'
106
+ version: '3.1'
80
107
  required_rubygems_version: !ruby/object:Gem::Requirement
81
108
  requirements:
82
109
  - - ">="
83
110
  - !ruby/object:Gem::Version
84
111
  version: '0'
85
112
  requirements: []
86
- rubygems_version: 3.3.7
87
- signing_key:
113
+ rubygems_version: 3.6.6
88
114
  specification_version: 4
89
115
  summary: Gem to work with the Publishing Platform content schemas
90
116
  test_files: []
@@ -1,27 +0,0 @@
1
- name: Ruby
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- name: Ruby ${{ matrix.ruby }}
14
- strategy:
15
- matrix:
16
- ruby:
17
- - '3.1.2'
18
-
19
- steps:
20
- - uses: actions/checkout@v3
21
- - name: Set up Ruby
22
- uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- bundler-cache: true
26
- - name: Run the default task
27
- run: bundle exec rake