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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/README.adoc +845 -436
  4. data/lib/w3c_api/cli.rb +20 -20
  5. data/lib/w3c_api/client.rb +66 -195
  6. data/lib/w3c_api/commands/affiliation.rb +33 -33
  7. data/lib/w3c_api/commands/ecosystem.rb +47 -47
  8. data/lib/w3c_api/commands/group.rb +68 -68
  9. data/lib/w3c_api/commands/output_formatter.rb +11 -11
  10. data/lib/w3c_api/commands/participation.rb +20 -22
  11. data/lib/w3c_api/commands/series.rb +26 -26
  12. data/lib/w3c_api/commands/specification.rb +77 -52
  13. data/lib/w3c_api/commands/translation.rb +18 -18
  14. data/lib/w3c_api/commands/user.rb +60 -60
  15. data/lib/w3c_api/hal.rb +164 -0
  16. data/lib/w3c_api/models/account.rb +44 -0
  17. data/lib/w3c_api/models/affiliation.rb +54 -65
  18. data/lib/w3c_api/models/affiliation_index.rb +11 -0
  19. data/lib/w3c_api/models/call_for_translation.rb +15 -39
  20. data/lib/w3c_api/models/chair_index.rb +11 -0
  21. data/lib/w3c_api/models/charter.rb +48 -89
  22. data/lib/w3c_api/models/charter_index.rb +11 -0
  23. data/lib/w3c_api/models/connected_account.rb +21 -30
  24. data/lib/w3c_api/models/ecosystem.rb +20 -42
  25. data/lib/w3c_api/models/{ecosystems.rb → ecosystem_index.rb} +4 -10
  26. data/lib/w3c_api/models/evangelist_index.rb +11 -0
  27. data/lib/w3c_api/models/extension.rb +5 -7
  28. data/lib/w3c_api/models/group.rb +63 -142
  29. data/lib/w3c_api/models/group_index.rb +12 -0
  30. data/lib/w3c_api/models/join_emails.rb +5 -7
  31. data/lib/w3c_api/models/participant_index.rb +11 -0
  32. data/lib/w3c_api/models/participation.rb +31 -90
  33. data/lib/w3c_api/models/participation_index.rb +11 -0
  34. data/lib/w3c_api/models/photo.rb +26 -0
  35. data/lib/w3c_api/models/serie.rb +21 -51
  36. data/lib/w3c_api/models/{series.rb → serie_index.rb} +22 -13
  37. data/lib/w3c_api/models/spec_version.rb +69 -83
  38. data/lib/w3c_api/models/spec_version_index.rb +13 -0
  39. data/lib/w3c_api/models/spec_version_ref.rb +11 -13
  40. data/lib/w3c_api/models/specification.rb +54 -66
  41. data/lib/w3c_api/models/specification_index.rb +10 -0
  42. data/lib/w3c_api/models/team_contact_index.rb +11 -0
  43. data/lib/w3c_api/models/testimonial.rb +17 -0
  44. data/lib/w3c_api/models/translation.rb +33 -72
  45. data/lib/w3c_api/models/{translations.rb → translation_index.rb} +4 -12
  46. data/lib/w3c_api/models/user.rb +95 -165
  47. data/lib/w3c_api/models/user_index.rb +11 -0
  48. data/lib/w3c_api/models.rb +35 -12
  49. data/lib/w3c_api/version.rb +1 -1
  50. data/lib/w3c_api.rb +3 -2
  51. metadata +35 -19
  52. data/lib/w3c_api/models/affiliations.rb +0 -33
  53. data/lib/w3c_api/models/base.rb +0 -39
  54. data/lib/w3c_api/models/call_for_translation_ref.rb +0 -15
  55. data/lib/w3c_api/models/charters.rb +0 -17
  56. data/lib/w3c_api/models/collection_base.rb +0 -79
  57. data/lib/w3c_api/models/delegate_enumerable.rb +0 -54
  58. data/lib/w3c_api/models/groups.rb +0 -38
  59. data/lib/w3c_api/models/link.rb +0 -17
  60. data/lib/w3c_api/models/participations.rb +0 -17
  61. data/lib/w3c_api/models/series_collection.rb +0 -17
  62. data/lib/w3c_api/models/spec_versions.rb +0 -17
  63. data/lib/w3c_api/models/specifications.rb +0 -17
  64. 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
@@ -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
@@ -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