w3c_api 0.1.0 → 0.1.1
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 +4 -4
- data/LICENSE.md +1 -1
- data/README.adoc +845 -436
- data/lib/w3c_api/cli.rb +20 -20
- data/lib/w3c_api/client.rb +66 -195
- data/lib/w3c_api/commands/affiliation.rb +33 -33
- data/lib/w3c_api/commands/ecosystem.rb +47 -47
- data/lib/w3c_api/commands/group.rb +68 -68
- data/lib/w3c_api/commands/output_formatter.rb +11 -11
- data/lib/w3c_api/commands/participation.rb +20 -22
- data/lib/w3c_api/commands/series.rb +26 -26
- data/lib/w3c_api/commands/specification.rb +77 -52
- data/lib/w3c_api/commands/translation.rb +18 -18
- data/lib/w3c_api/commands/user.rb +60 -60
- data/lib/w3c_api/hal.rb +164 -0
- data/lib/w3c_api/models/account.rb +44 -0
- data/lib/w3c_api/models/affiliation.rb +54 -65
- data/lib/w3c_api/models/affiliation_index.rb +11 -0
- data/lib/w3c_api/models/call_for_translation.rb +15 -39
- data/lib/w3c_api/models/chair_index.rb +11 -0
- data/lib/w3c_api/models/charter.rb +48 -89
- data/lib/w3c_api/models/charter_index.rb +11 -0
- data/lib/w3c_api/models/connected_account.rb +21 -30
- data/lib/w3c_api/models/ecosystem.rb +20 -42
- data/lib/w3c_api/models/{ecosystems.rb → ecosystem_index.rb} +4 -10
- data/lib/w3c_api/models/evangelist_index.rb +11 -0
- data/lib/w3c_api/models/extension.rb +5 -7
- data/lib/w3c_api/models/group.rb +63 -142
- data/lib/w3c_api/models/group_index.rb +12 -0
- data/lib/w3c_api/models/join_emails.rb +5 -7
- data/lib/w3c_api/models/participant_index.rb +11 -0
- data/lib/w3c_api/models/participation.rb +31 -90
- data/lib/w3c_api/models/participation_index.rb +11 -0
- data/lib/w3c_api/models/photo.rb +26 -0
- data/lib/w3c_api/models/serie.rb +21 -51
- data/lib/w3c_api/models/{series.rb → serie_index.rb} +22 -13
- data/lib/w3c_api/models/spec_version.rb +69 -83
- data/lib/w3c_api/models/spec_version_index.rb +13 -0
- data/lib/w3c_api/models/spec_version_ref.rb +11 -13
- data/lib/w3c_api/models/specification.rb +54 -66
- data/lib/w3c_api/models/specification_index.rb +10 -0
- data/lib/w3c_api/models/team_contact_index.rb +11 -0
- data/lib/w3c_api/models/testimonial.rb +17 -0
- data/lib/w3c_api/models/translation.rb +33 -72
- data/lib/w3c_api/models/{translations.rb → translation_index.rb} +4 -12
- data/lib/w3c_api/models/user.rb +95 -165
- data/lib/w3c_api/models/user_index.rb +11 -0
- data/lib/w3c_api/models.rb +35 -12
- data/lib/w3c_api/version.rb +1 -1
- data/lib/w3c_api.rb +3 -2
- metadata +35 -19
- data/lib/w3c_api/models/affiliations.rb +0 -33
- data/lib/w3c_api/models/base.rb +0 -39
- data/lib/w3c_api/models/call_for_translation_ref.rb +0 -15
- data/lib/w3c_api/models/charters.rb +0 -17
- data/lib/w3c_api/models/collection_base.rb +0 -79
- data/lib/w3c_api/models/delegate_enumerable.rb +0 -54
- data/lib/w3c_api/models/groups.rb +0 -38
- data/lib/w3c_api/models/link.rb +0 -17
- data/lib/w3c_api/models/participations.rb +0 -17
- data/lib/w3c_api/models/series_collection.rb +0 -17
- data/lib/w3c_api/models/spec_versions.rb +0 -17
- data/lib/w3c_api/models/specifications.rb +0 -17
- data/lib/w3c_api/models/users.rb +0 -44
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'lutaml/model'
|
4
|
-
require 'json'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
module W3cApi
|
8
|
-
module Models
|
9
|
-
class CollectionBase < Lutaml::Model::Serializable
|
10
|
-
# Common methods for all W3C API model collections
|
11
|
-
extend DelegateEnumerable
|
12
|
-
|
13
|
-
def self.collection_instance_class(klass, attribute)
|
14
|
-
@collection_instance_class ||= klass
|
15
|
-
@collection_attribute = attribute
|
16
|
-
end
|
17
|
-
|
18
|
-
# Create a model instance from a hash response
|
19
|
-
def self.from_response(data)
|
20
|
-
return new({ @collection_attribute => [] }) if data.nil?
|
21
|
-
|
22
|
-
# Handle the case where data is expected to have 'items' key
|
23
|
-
if data.is_a?(Hash)
|
24
|
-
return new({ @collection_attribute => [] }) unless data.key?(:items) || data.key?('items')
|
25
|
-
|
26
|
-
items_key = data.key?(:items) ? :items : 'items'
|
27
|
-
items = data[items_key] || []
|
28
|
-
|
29
|
-
# Set pagination metadata
|
30
|
-
result = new
|
31
|
-
data.each do |key, value|
|
32
|
-
next if key == items_key
|
33
|
-
|
34
|
-
result.send("#{key}=", value) if result.respond_to?("#{key}=")
|
35
|
-
end
|
36
|
-
|
37
|
-
# Process items array
|
38
|
-
transformed_items = items.map do |item|
|
39
|
-
@collection_instance_class.new(transform_keys(item))
|
40
|
-
end
|
41
|
-
|
42
|
-
result.send("#{@collection_attribute}=", transformed_items)
|
43
|
-
return result
|
44
|
-
|
45
|
-
# Handle case where response is a hash but doesn't contain 'items'
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
# Handle case where data is directly the items array
|
50
|
-
if data.is_a?(Array)
|
51
|
-
transformed_data = data.map do |item|
|
52
|
-
@collection_instance_class.new(transform_keys(item))
|
53
|
-
end
|
54
|
-
return new({ @collection_attribute => transformed_data })
|
55
|
-
end
|
56
|
-
|
57
|
-
# For backward compatibility, try to create a model instance anyway
|
58
|
-
new({ @collection_attribute => [] })
|
59
|
-
end
|
60
|
-
|
61
|
-
# Utility function to transform kebab-case to snake_case
|
62
|
-
def self.transform_keys(data)
|
63
|
-
case data
|
64
|
-
when Hash
|
65
|
-
result = {}
|
66
|
-
data.each do |key, value|
|
67
|
-
snake_key = key.to_s.tr('-', '_').to_sym
|
68
|
-
result[snake_key] = transform_keys(value)
|
69
|
-
end
|
70
|
-
result
|
71
|
-
when Array
|
72
|
-
data.map { |item| transform_keys(item) }
|
73
|
-
else
|
74
|
-
data
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,54 +0,0 @@
|
|
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
|
@@ -1,38 +0,0 @@
|
|
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
|
data/lib/w3c_api/models/link.rb
DELETED
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'lutaml/model'
|
4
|
-
require_relative 'spec_version'
|
5
|
-
require_relative 'delegate_enumerable'
|
6
|
-
require_relative 'collection_base'
|
7
|
-
|
8
|
-
module W3cApi
|
9
|
-
module Models
|
10
|
-
class SpecVersions < CollectionBase
|
11
|
-
attribute :spec_versions, SpecVersion, collection: true
|
12
|
-
|
13
|
-
delegate_enumerable :spec_versions
|
14
|
-
collection_instance_class SpecVersion, :spec_versions
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'lutaml/model'
|
4
|
-
require_relative 'specification'
|
5
|
-
require_relative 'delegate_enumerable'
|
6
|
-
require_relative 'collection_base'
|
7
|
-
|
8
|
-
module W3cApi
|
9
|
-
module Models
|
10
|
-
class Specifications < CollectionBase
|
11
|
-
attribute :specifications, Specification, collection: true
|
12
|
-
|
13
|
-
delegate_enumerable :specifications
|
14
|
-
collection_instance_class Specification, :specifications
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/w3c_api/models/users.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'lutaml/model'
|
4
|
-
require_relative 'user'
|
5
|
-
require_relative 'delegate_enumerable'
|
6
|
-
require_relative 'collection_base'
|
7
|
-
|
8
|
-
# {
|
9
|
-
# "page"=>1,
|
10
|
-
# "limit"=>100,
|
11
|
-
# "pages"=>8,
|
12
|
-
# "total"=>709,
|
13
|
-
# "_links"=>{
|
14
|
-
# "up"=>{
|
15
|
-
# "href"=>"https://api.w3.org/affiliations/35662"
|
16
|
-
# },
|
17
|
-
# "participants"=>[
|
18
|
-
# {
|
19
|
-
# "href"=>"https://api.w3.org/users/p3dte6mpoj4sgw888w8kw4w4skwosck",
|
20
|
-
# "title"=>"Tab Atkins Jr."
|
21
|
-
# },
|
22
|
-
# {
|
23
|
-
# "href"=>"https://api.w3.org/users/l88ca27n2b4sk00cogosk0skw4s8osc",
|
24
|
-
# "title"=>"Chris Wilson"
|
25
|
-
# },
|
26
|
-
# {
|
27
|
-
# "href"=>"https://api.w3.org/users/kjqsxbe6kioko4s88s4wocws848kgw8",
|
28
|
-
# "title"=>"David Baron"
|
29
|
-
# },
|
30
|
-
# {
|
31
|
-
# "href"=>"https://api.w3.org/users/t9qq83owlzkck404w0o44so8owc00gg",
|
32
|
-
# "title"=>"Rune Lillesveen"
|
33
|
-
# },
|
34
|
-
|
35
|
-
module W3cApi
|
36
|
-
module Models
|
37
|
-
class Users < CollectionBase
|
38
|
-
attribute :users, User, collection: true
|
39
|
-
|
40
|
-
delegate_enumerable :users
|
41
|
-
collection_instance_class User, :users
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|