w3c_api 0.1.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 +7 -0
- data/LICENSE.md +33 -0
- data/README.adoc +1265 -0
- data/Rakefile +8 -0
- data/exe/w3c_api +6 -0
- data/lib/w3c_api/cli.rb +41 -0
- data/lib/w3c_api/client.rb +320 -0
- data/lib/w3c_api/commands/affiliation.rb +48 -0
- data/lib/w3c_api/commands/ecosystem.rb +57 -0
- data/lib/w3c_api/commands/group.rb +87 -0
- data/lib/w3c_api/commands/output_formatter.rb +18 -0
- data/lib/w3c_api/commands/participation.rb +34 -0
- data/lib/w3c_api/commands/series.rb +40 -0
- data/lib/w3c_api/commands/specification.rb +68 -0
- data/lib/w3c_api/commands/translation.rb +31 -0
- data/lib/w3c_api/commands/user.rb +77 -0
- data/lib/w3c_api/models/affiliation.rb +86 -0
- data/lib/w3c_api/models/affiliations.rb +33 -0
- data/lib/w3c_api/models/base.rb +39 -0
- data/lib/w3c_api/models/call_for_translation.rb +59 -0
- data/lib/w3c_api/models/call_for_translation_ref.rb +15 -0
- data/lib/w3c_api/models/charter.rb +110 -0
- data/lib/w3c_api/models/charters.rb +17 -0
- data/lib/w3c_api/models/collection_base.rb +79 -0
- data/lib/w3c_api/models/connected_account.rb +54 -0
- data/lib/w3c_api/models/delegate_enumerable.rb +54 -0
- data/lib/w3c_api/models/ecosystem.rb +72 -0
- data/lib/w3c_api/models/ecosystems.rb +33 -0
- data/lib/w3c_api/models/extension.rb +12 -0
- data/lib/w3c_api/models/group.rb +173 -0
- data/lib/w3c_api/models/groups.rb +38 -0
- data/lib/w3c_api/models/join_emails.rb +12 -0
- data/lib/w3c_api/models/link.rb +17 -0
- data/lib/w3c_api/models/participation.rb +109 -0
- data/lib/w3c_api/models/participations.rb +17 -0
- data/lib/w3c_api/models/serie.rb +88 -0
- data/lib/w3c_api/models/series.rb +41 -0
- data/lib/w3c_api/models/series_collection.rb +17 -0
- data/lib/w3c_api/models/spec_version.rb +96 -0
- data/lib/w3c_api/models/spec_version_ref.rb +18 -0
- data/lib/w3c_api/models/spec_versions.rb +17 -0
- data/lib/w3c_api/models/specification.rb +79 -0
- data/lib/w3c_api/models/specifications.rb +17 -0
- data/lib/w3c_api/models/translation.rb +162 -0
- data/lib/w3c_api/models/translations.rb +40 -0
- data/lib/w3c_api/models/user.rb +178 -0
- data/lib/w3c_api/models/users.rb +44 -0
- data/lib/w3c_api/models.rb +15 -0
- data/lib/w3c_api/version.rb +5 -0
- data/lib/w3c_api.rb +9 -0
- metadata +166 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module W3cApi
|
4
|
+
module Models
|
5
|
+
# Module for delegating Enumerable methods to a collection attribute
|
6
|
+
module DelegateEnumerable
|
7
|
+
# Define enumerable methods delegated to the specified collection attribute
|
8
|
+
# @param collection_attr [Symbol] The name of the collection attribute
|
9
|
+
def delegate_enumerable(collection_attr)
|
10
|
+
include Enumerable
|
11
|
+
|
12
|
+
define_method(:each) do |&block|
|
13
|
+
send(collection_attr).each(&block)
|
14
|
+
end
|
15
|
+
|
16
|
+
define_method(:map) do |&block|
|
17
|
+
send(collection_attr).map(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
define_method(:select) do |&block|
|
21
|
+
send(collection_attr).select(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
define_method(:[]) do |index|
|
25
|
+
send(collection_attr)[index]
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method(:first) do
|
29
|
+
send(collection_attr).first
|
30
|
+
end
|
31
|
+
|
32
|
+
define_method(:last) do
|
33
|
+
send(collection_attr).last
|
34
|
+
end
|
35
|
+
|
36
|
+
define_method(:empty?) do
|
37
|
+
send(collection_attr).empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
define_method(:size) do
|
41
|
+
send(collection_attr).size
|
42
|
+
end
|
43
|
+
|
44
|
+
define_method(:length) do
|
45
|
+
send(collection_attr).length
|
46
|
+
end
|
47
|
+
|
48
|
+
define_method(:to_a) do
|
49
|
+
send(collection_attr)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
require_relative 'link'
|
5
|
+
|
6
|
+
# {
|
7
|
+
# "name": "Data and knowledge"
|
8
|
+
# "shortname": "data"
|
9
|
+
# "_links": {
|
10
|
+
# "self": {
|
11
|
+
# "href": "https://api.w3.org/ecosystems/data"
|
12
|
+
# }
|
13
|
+
# "champion": {
|
14
|
+
# "href": "https://api.w3.org/users/t891ludoisggsccsw44o8goccc0s0ks"
|
15
|
+
# "title": "Pierre-Antoine Champin"
|
16
|
+
# }
|
17
|
+
# "evangelists": {
|
18
|
+
# "href": "https://api.w3.org/ecosystems/data/evangelists"
|
19
|
+
# }
|
20
|
+
# "groups": {
|
21
|
+
# "href": "https://api.w3.org/ecosystems/data/groups"
|
22
|
+
# }
|
23
|
+
# "member-organizations": {
|
24
|
+
# "href": "https://api.w3.org/ecosystems/data/member-organizations"
|
25
|
+
# }
|
26
|
+
# }
|
27
|
+
# }
|
28
|
+
|
29
|
+
module W3cApi
|
30
|
+
module Models
|
31
|
+
class EcosystemLinks < Lutaml::Model::Serializable
|
32
|
+
attribute :self, Link
|
33
|
+
attribute :champion, Link
|
34
|
+
attribute :evangelists, Link
|
35
|
+
attribute :groups, Link
|
36
|
+
attribute :member_organizations, Link
|
37
|
+
end
|
38
|
+
|
39
|
+
class Ecosystem < Base
|
40
|
+
attribute :name, :string
|
41
|
+
attribute :shortname, :string
|
42
|
+
attribute :href, :string
|
43
|
+
attribute :title, :string
|
44
|
+
attribute :_links, EcosystemLinks
|
45
|
+
|
46
|
+
# Return groups in this ecosystem
|
47
|
+
def groups(client = nil)
|
48
|
+
return nil unless client && _links&.groups
|
49
|
+
|
50
|
+
client.ecosystem_groups(shortname)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.from_response(response)
|
54
|
+
transformed_response = transform_keys(response)
|
55
|
+
|
56
|
+
ecosystem = new
|
57
|
+
transformed_response.each do |key, value|
|
58
|
+
case key
|
59
|
+
when :_links
|
60
|
+
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
61
|
+
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
62
|
+
end
|
63
|
+
ecosystem._links = EcosystemLinks.new(links)
|
64
|
+
else
|
65
|
+
ecosystem.send("#{key}=", value) if ecosystem.respond_to?("#{key}=")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
ecosystem
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lutaml/model'
|
4
|
+
require_relative 'ecosystem'
|
5
|
+
require_relative 'delegate_enumerable'
|
6
|
+
require_relative 'collection_base'
|
7
|
+
|
8
|
+
# {
|
9
|
+
# "page": 1,
|
10
|
+
# "limit": 100,
|
11
|
+
# "pages": 1,
|
12
|
+
# "total": 9,
|
13
|
+
# "_links": {
|
14
|
+
# "ecosystems": [
|
15
|
+
# {
|
16
|
+
# "href": "https://api.w3.org/ecosystems/advertising",
|
17
|
+
# "title": "Web Advertising"
|
18
|
+
# },
|
19
|
+
# {
|
20
|
+
# "href": "https://api.w3.org/ecosystems/e-commerce",
|
21
|
+
# "title": "E-commerce"
|
22
|
+
# },
|
23
|
+
|
24
|
+
module W3cApi
|
25
|
+
module Models
|
26
|
+
class Ecosystems < CollectionBase
|
27
|
+
attribute :ecosystems, Ecosystem, collection: true
|
28
|
+
|
29
|
+
delegate_enumerable :ecosystems
|
30
|
+
collection_instance_class Ecosystem, :ecosystems
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
require_relative 'join_emails'
|
5
|
+
require_relative 'link'
|
6
|
+
|
7
|
+
# {
|
8
|
+
# "id": 35422
|
9
|
+
# "name": "Accessibility Guidelines Working Group"
|
10
|
+
# "is_closed": false
|
11
|
+
# "description": "The mission of the Accessibility Guidelines Working Group (AG WG) is to develop specifications to make content on the Web accessible for people with disabilities and to participate in the development and maintenance of implementation support materials for the Web Content Accessibility Guidelines."
|
12
|
+
# "shortname": "ag"
|
13
|
+
# "discr": "w3cgroup"
|
14
|
+
# "_links": {
|
15
|
+
# "self": {
|
16
|
+
# "href": "https://api.w3.org/groups/wg/ag"
|
17
|
+
# }
|
18
|
+
# "homepage": {
|
19
|
+
# "href": "https://www.w3.org/WAI/GL/"
|
20
|
+
# }
|
21
|
+
# "users": {
|
22
|
+
# "href": "https://api.w3.org/groups/wg/ag/users"
|
23
|
+
# }
|
24
|
+
# "services": {
|
25
|
+
# "href": "https://api.w3.org/groups/wg/ag/services"
|
26
|
+
# }
|
27
|
+
# "specifications": {
|
28
|
+
# "href": "https://api.w3.org/groups/wg/ag/specifications"
|
29
|
+
# }
|
30
|
+
# "chairs": {
|
31
|
+
# "href": "https://api.w3.org/groups/wg/ag/chairs"
|
32
|
+
# }
|
33
|
+
# "team-contacts": {
|
34
|
+
# "href": "https://api.w3.org/groups/wg/ag/teamcontacts"
|
35
|
+
# }
|
36
|
+
# "charters": {
|
37
|
+
# "href": "https://api.w3.org/groups/wg/ag/charters"
|
38
|
+
# }
|
39
|
+
# "active-charter": {
|
40
|
+
# "href": "https://api.w3.org/groups/wg/ag/charters/492"
|
41
|
+
# }
|
42
|
+
# "join": {
|
43
|
+
# "href": "https://www.w3.org/groups/wg/ag/join"
|
44
|
+
# }
|
45
|
+
# "pp-status": {
|
46
|
+
# "href": "https://www.w3.org/groups/wg/ag/ipr"
|
47
|
+
# }
|
48
|
+
# "participations": {
|
49
|
+
# "href": "https://api.w3.org/groups/wg/ag/participations"
|
50
|
+
# }
|
51
|
+
# }
|
52
|
+
# "type": "working group"
|
53
|
+
# "start-date": "1997-10-06"
|
54
|
+
# "end-date": "2025-10-31"
|
55
|
+
# }
|
56
|
+
|
57
|
+
module W3cApi
|
58
|
+
module Models
|
59
|
+
class GroupLinks < Lutaml::Model::Serializable
|
60
|
+
attribute :self, Link
|
61
|
+
attribute :homepage, Link
|
62
|
+
attribute :users, Link
|
63
|
+
attribute :services, Link
|
64
|
+
attribute :specifications, Link
|
65
|
+
attribute :chairs, Link
|
66
|
+
attribute :team_contacts, Link
|
67
|
+
attribute :charters, Link
|
68
|
+
attribute :active_charter, Link
|
69
|
+
attribute :join, Link
|
70
|
+
attribute :pp_status, Link
|
71
|
+
attribute :participations, Link
|
72
|
+
end
|
73
|
+
|
74
|
+
class Group < Base
|
75
|
+
attribute :id, :integer
|
76
|
+
attribute :name, :string
|
77
|
+
attribute :type, :string
|
78
|
+
attribute :href, :string
|
79
|
+
attribute :title, :string
|
80
|
+
attribute :description, :string
|
81
|
+
attribute :shortname, :string
|
82
|
+
attribute :shortlink, :string
|
83
|
+
attribute :discr, :string
|
84
|
+
attribute :created, :string # Date-time format
|
85
|
+
attribute :start_date, :string # Date-time format
|
86
|
+
attribute :end_date, :string # Date-time format
|
87
|
+
attribute :is_closed, :boolean
|
88
|
+
attribute :patent_policy, :string
|
89
|
+
attribute :charter_closed, :boolean
|
90
|
+
attribute :join_emails, JoinEmails
|
91
|
+
attribute :_links, GroupLinks
|
92
|
+
|
93
|
+
# Return users in this group
|
94
|
+
def users(client = nil)
|
95
|
+
return nil unless client && _links&.users
|
96
|
+
|
97
|
+
client.group_users(id)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Return specifications in this group
|
101
|
+
def specifications(client = nil)
|
102
|
+
return nil unless client && _links&.specifications
|
103
|
+
|
104
|
+
client.group_specifications(id)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Return charters for this group
|
108
|
+
def charters(client = nil)
|
109
|
+
return nil unless client && _links&.charters
|
110
|
+
|
111
|
+
client.group_charters(id)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Return chairs for this group
|
115
|
+
def chairs(client = nil)
|
116
|
+
return nil unless client && _links&.chairs
|
117
|
+
|
118
|
+
client.group_chairs(id)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Return team contacts for this group
|
122
|
+
def team_contacts(client = nil)
|
123
|
+
return nil unless client && _links&.team_contacts
|
124
|
+
|
125
|
+
client.group_team_contacts(id)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Parse date strings to Date objects
|
129
|
+
def created_date
|
130
|
+
Date.parse(created) if created
|
131
|
+
rescue Date::Error
|
132
|
+
nil
|
133
|
+
end
|
134
|
+
|
135
|
+
def start_date_parsed
|
136
|
+
Date.parse(start_date) if start_date
|
137
|
+
rescue Date::Error
|
138
|
+
nil
|
139
|
+
end
|
140
|
+
|
141
|
+
def end_date_parsed
|
142
|
+
Date.parse(end_date) if end_date
|
143
|
+
rescue Date::Error
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
|
147
|
+
# Check if this group is active
|
148
|
+
def active?
|
149
|
+
!is_closed && (!end_date || Date.parse(end_date) > Date.today)
|
150
|
+
rescue Date::Error
|
151
|
+
!is_closed
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.from_response(response)
|
155
|
+
transformed_response = transform_keys(response)
|
156
|
+
|
157
|
+
group = new
|
158
|
+
transformed_response.each do |key, value|
|
159
|
+
case key
|
160
|
+
when :_links
|
161
|
+
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
162
|
+
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
163
|
+
end
|
164
|
+
group._links = GroupLinks.new(links)
|
165
|
+
else
|
166
|
+
group.send("#{key}=", value) if group.respond_to?("#{key}=")
|
167
|
+
end
|
168
|
+
end
|
169
|
+
group
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lutaml/model'
|
4
|
+
require_relative 'group'
|
5
|
+
require_relative 'delegate_enumerable'
|
6
|
+
require_relative 'collection_base'
|
7
|
+
|
8
|
+
# Response body:
|
9
|
+
# {
|
10
|
+
# "page": 1,
|
11
|
+
# "limit": 100,
|
12
|
+
# "pages": 3,
|
13
|
+
# "total": 257,
|
14
|
+
# "_links": {
|
15
|
+
# "groups": [
|
16
|
+
# {
|
17
|
+
# "href": "https://api.w3.org/groups/tf/ab-liaisons-to-bod",
|
18
|
+
# "title": "AB Liaisons to the Board of Directors"
|
19
|
+
# },
|
20
|
+
# {
|
21
|
+
# "href": "https://api.w3.org/groups/cg/a11yedge",
|
22
|
+
# "title": "Accessibility at the Edge Community Group"
|
23
|
+
# },
|
24
|
+
# {
|
25
|
+
# "href": "https://api.w3.org/groups/tf/wcag-act",
|
26
|
+
# "title": "Accessibility Conformance Testing (ACT) Task Force"
|
27
|
+
# },
|
28
|
+
|
29
|
+
module W3cApi
|
30
|
+
module Models
|
31
|
+
class Groups < CollectionBase
|
32
|
+
attribute :groups, Group, collection: true
|
33
|
+
|
34
|
+
delegate_enumerable :groups
|
35
|
+
collection_instance_class Group, :groups
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
# {
|
6
|
+
# "href"=>"https://api.w3.org/specifications/png-2/versions/20031110",
|
7
|
+
# "title"=>"Recommendation"
|
8
|
+
# }
|
9
|
+
|
10
|
+
module W3cApi
|
11
|
+
module Models
|
12
|
+
class Link < Lutaml::Model::Serializable
|
13
|
+
attribute :href, :string
|
14
|
+
attribute :title, :string
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
require_relative 'link'
|
5
|
+
|
6
|
+
# Example participation response:
|
7
|
+
# {
|
8
|
+
# "created": "2023-01-01T12:00:00Z",
|
9
|
+
# "_links": {
|
10
|
+
# "self": {
|
11
|
+
# "href": "https://api.w3.org/participations/123"
|
12
|
+
# },
|
13
|
+
# "group": {
|
14
|
+
# "href": "https://api.w3.org/groups/456",
|
15
|
+
# "title": "Example Group"
|
16
|
+
# },
|
17
|
+
# "user": {
|
18
|
+
# "href": "https://api.w3.org/users/789",
|
19
|
+
# "title": "John Doe"
|
20
|
+
# },
|
21
|
+
# "organization": {
|
22
|
+
# "href": "https://api.w3.org/affiliations/101",
|
23
|
+
# "title": "Example Organization"
|
24
|
+
# },
|
25
|
+
# "participants": {
|
26
|
+
# "href": "https://api.w3.org/participations/123/participants"
|
27
|
+
# }
|
28
|
+
# }
|
29
|
+
# }
|
30
|
+
|
31
|
+
module W3cApi
|
32
|
+
module Models
|
33
|
+
class ParticipationLinks < Lutaml::Model::Serializable
|
34
|
+
attribute :self, Link
|
35
|
+
attribute :group, Link
|
36
|
+
attribute :user, Link
|
37
|
+
attribute :organization, Link
|
38
|
+
attribute :participants, Link
|
39
|
+
end
|
40
|
+
|
41
|
+
class Participation < Base
|
42
|
+
attribute :title, :string
|
43
|
+
attribute :href, :string
|
44
|
+
attribute :created, :date_time # Date-time format
|
45
|
+
attribute :_links, ParticipationLinks
|
46
|
+
|
47
|
+
# Parse date strings to Date objects
|
48
|
+
def created_date
|
49
|
+
Date.parse(created) if created
|
50
|
+
rescue Date::Error
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get the group this participation is for
|
55
|
+
def group(client = nil)
|
56
|
+
return nil unless client && _links&.group
|
57
|
+
|
58
|
+
href = _links.group.href
|
59
|
+
id = href.split('/').last
|
60
|
+
client.group(id)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get the user participating
|
64
|
+
def user(client = nil)
|
65
|
+
return nil unless client && _links&.user
|
66
|
+
|
67
|
+
href = _links.user.href
|
68
|
+
id = href.split('/').last
|
69
|
+
client.user(id)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get the organization participating
|
73
|
+
def organization(client = nil)
|
74
|
+
return nil unless client && _links&.organization
|
75
|
+
|
76
|
+
href = _links.organization.href
|
77
|
+
id = href.split('/').last
|
78
|
+
client.affiliation(id)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Get participants in this participation
|
82
|
+
def participants(client = nil)
|
83
|
+
return nil unless client && _links&.participants
|
84
|
+
|
85
|
+
href = _links.participants.href
|
86
|
+
id = href.split('/').last
|
87
|
+
client.participation_participants(id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.from_response(response)
|
91
|
+
transformed_response = transform_keys(response)
|
92
|
+
|
93
|
+
participation = new
|
94
|
+
transformed_response.each do |key, value|
|
95
|
+
case key
|
96
|
+
when :_links
|
97
|
+
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
98
|
+
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
99
|
+
end
|
100
|
+
participation._links = ParticipationLinks.new(links)
|
101
|
+
else
|
102
|
+
participation.send("#{key}=", value) if participation.respond_to?("#{key}=")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
participation
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lutaml/model'
|
4
|
+
require_relative 'participation'
|
5
|
+
require_relative 'delegate_enumerable'
|
6
|
+
require_relative 'collection_base'
|
7
|
+
|
8
|
+
module W3cApi
|
9
|
+
module Models
|
10
|
+
class Participations < CollectionBase
|
11
|
+
attribute :participations, Participation, collection: true
|
12
|
+
|
13
|
+
delegate_enumerable :participations
|
14
|
+
collection_instance_class Participation, :participations
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
require_relative 'link'
|
5
|
+
|
6
|
+
# {
|
7
|
+
# "shortname": "css-backgrounds",
|
8
|
+
# "name": "CSS Backgrounds and Borders Module",
|
9
|
+
# "_links": {
|
10
|
+
# "self": {
|
11
|
+
# "href": "https://api.w3.org/specification-series/css-backgrounds"
|
12
|
+
# },
|
13
|
+
# "specifications": {
|
14
|
+
# "href": "https://api.w3.org/specification-series/css-backgrounds/specifications"
|
15
|
+
# },
|
16
|
+
# "current-specification": {
|
17
|
+
# "href": "https://api.w3.org/specifications/css-backgrounds-3"
|
18
|
+
# }
|
19
|
+
# }
|
20
|
+
# }
|
21
|
+
#
|
22
|
+
# {
|
23
|
+
# "shortname": "2dcontext",
|
24
|
+
# "name": "HTML Canvas 2D Context",
|
25
|
+
# "_links": {
|
26
|
+
# "self": {
|
27
|
+
# "href": "https://api.w3.org/specification-series/2dcontext"
|
28
|
+
# },
|
29
|
+
# "specifications": {
|
30
|
+
# "href": "https://api.w3.org/specification-series/2dcontext/specifications"
|
31
|
+
# },
|
32
|
+
# "current-specification": {
|
33
|
+
# "href": "https://api.w3.org/specifications/2dcontext"
|
34
|
+
# }
|
35
|
+
# }
|
36
|
+
# }
|
37
|
+
|
38
|
+
module W3cApi
|
39
|
+
module Models
|
40
|
+
class SerieLinks < Lutaml::Model::Serializable
|
41
|
+
attribute :self, Link
|
42
|
+
attribute :specifications, Link
|
43
|
+
attribute :current_specification, Link
|
44
|
+
end
|
45
|
+
|
46
|
+
class Serie < Base
|
47
|
+
attribute :shortname, :string
|
48
|
+
attribute :name, :string
|
49
|
+
attribute :href, :string
|
50
|
+
attribute :title, :string
|
51
|
+
attribute :_links, SerieLinks
|
52
|
+
|
53
|
+
# Get specifications in this series
|
54
|
+
def specifications(client = nil)
|
55
|
+
return nil unless client && _links&.specifications
|
56
|
+
|
57
|
+
client.series_specifications(shortname)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Get current specification in this series
|
61
|
+
def current_specification(client = nil)
|
62
|
+
return nil unless client && _links&.current_specification
|
63
|
+
|
64
|
+
href = _links.current_specification.href
|
65
|
+
shortname = href.split('/').last
|
66
|
+
client.specification(shortname)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.from_response(response)
|
70
|
+
transformed_response = transform_keys(response)
|
71
|
+
|
72
|
+
series = new
|
73
|
+
transformed_response.each do |key, value|
|
74
|
+
case key
|
75
|
+
when :_links
|
76
|
+
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
77
|
+
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
78
|
+
end
|
79
|
+
series._links = SerieLinks.new(links)
|
80
|
+
else
|
81
|
+
series.send("#{key}=", value) if series.respond_to?("#{key}=")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
series
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lutaml/model'
|
4
|
+
require_relative 'serie'
|
5
|
+
require_relative 'delegate_enumerable'
|
6
|
+
require_relative 'collection_base'
|
7
|
+
|
8
|
+
# {
|
9
|
+
# "page": 1,
|
10
|
+
# "limit": 1000,
|
11
|
+
# "pages": 2,
|
12
|
+
# "total": 1426,
|
13
|
+
# "_links": {
|
14
|
+
# "specification-series": [
|
15
|
+
# {
|
16
|
+
# "href": "https://api.w3.org/specification-series/2dcontext",
|
17
|
+
# "title": "2dcontext"
|
18
|
+
# },
|
19
|
+
# {
|
20
|
+
# "href": "https://api.w3.org/specification-series/abstract-ui",
|
21
|
+
# "title": "abstract-ui"
|
22
|
+
# },
|
23
|
+
# {
|
24
|
+
# "href": "https://api.w3.org/specification-series/cors",
|
25
|
+
# "title": "cors"
|
26
|
+
# },
|
27
|
+
# {
|
28
|
+
# "href": "https://api.w3.org/specification-series/accessibility-metrics-report",
|
29
|
+
# "title": "accessibility-metrics-report"
|
30
|
+
# },
|
31
|
+
|
32
|
+
module W3cApi
|
33
|
+
module Models
|
34
|
+
class Series < CollectionBase
|
35
|
+
attribute :series, Serie, collection: true
|
36
|
+
|
37
|
+
delegate_enumerable :series
|
38
|
+
collection_instance_class Serie, :series
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lutaml/model'
|
4
|
+
require_relative 'series'
|
5
|
+
require_relative 'delegate_enumerable'
|
6
|
+
require_relative 'collection_base'
|
7
|
+
|
8
|
+
module W3cApi
|
9
|
+
module Models
|
10
|
+
class SeriesCollection < CollectionBase
|
11
|
+
attribute :series, Series, collection: true
|
12
|
+
|
13
|
+
delegate_enumerable :series
|
14
|
+
collection_instance_class Series, :series
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|