w3c_api 0.1.3 → 0.1.5

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +16 -1
  3. data/.rubocop_todo.yml +23 -32
  4. data/README.adoc +297 -827
  5. data/Rakefile +3 -3
  6. data/demo/rate_limiting_demo.rb +135 -0
  7. data/demo/test_embed_functionality.rb +88 -0
  8. data/demo/test_improved_embed_functionality.rb +92 -0
  9. data/examples/rate_limiting_stress_test.rb +239 -0
  10. data/exe/w3c_api +1 -1
  11. data/lib/w3c_api/cli.rb +29 -28
  12. data/lib/w3c_api/client.rb +30 -7
  13. data/lib/w3c_api/commands/affiliation.rb +15 -12
  14. data/lib/w3c_api/commands/ecosystem.rb +22 -15
  15. data/lib/w3c_api/commands/group.rb +32 -25
  16. data/lib/w3c_api/commands/output_formatter.rb +1 -1
  17. data/lib/w3c_api/commands/participation.rb +11 -9
  18. data/lib/w3c_api/commands/series.rb +11 -9
  19. data/lib/w3c_api/commands/specification.rb +59 -45
  20. data/lib/w3c_api/commands/specification_version.rb +21 -12
  21. data/lib/w3c_api/commands/translation.rb +7 -6
  22. data/lib/w3c_api/commands/user.rb +36 -24
  23. data/lib/w3c_api/embed.rb +40 -0
  24. data/lib/w3c_api/hal.rb +374 -164
  25. data/lib/w3c_api/models/account.rb +3 -3
  26. data/lib/w3c_api/models/affiliation.rb +8 -7
  27. data/lib/w3c_api/models/affiliation_index.rb +3 -2
  28. data/lib/w3c_api/models/call_for_translation.rb +4 -3
  29. data/lib/w3c_api/models/chair_index.rb +2 -2
  30. data/lib/w3c_api/models/charter.rb +5 -5
  31. data/lib/w3c_api/models/charter_index.rb +3 -2
  32. data/lib/w3c_api/models/connected_account.rb +2 -2
  33. data/lib/w3c_api/models/deliverer_index.rb +3 -2
  34. data/lib/w3c_api/models/ecosystem.rb +8 -6
  35. data/lib/w3c_api/models/ecosystem_index.rb +3 -2
  36. data/lib/w3c_api/models/editor_index.rb +2 -2
  37. data/lib/w3c_api/models/evangelist_index.rb +3 -2
  38. data/lib/w3c_api/models/group.rb +16 -13
  39. data/lib/w3c_api/models/group_index.rb +2 -2
  40. data/lib/w3c_api/models/groups.rb +2 -2
  41. data/lib/w3c_api/models/participant_index.rb +3 -2
  42. data/lib/w3c_api/models/participation.rb +6 -5
  43. data/lib/w3c_api/models/participation_index.rb +3 -2
  44. data/lib/w3c_api/models/photo.rb +1 -1
  45. data/lib/w3c_api/models/serie.rb +6 -4
  46. data/lib/w3c_api/models/serie_index.rb +3 -2
  47. data/lib/w3c_api/models/spec_version.rb +10 -7
  48. data/lib/w3c_api/models/spec_version_index.rb +3 -2
  49. data/lib/w3c_api/models/spec_version_predecessor_index.rb +3 -2
  50. data/lib/w3c_api/models/spec_version_successor_index.rb +3 -2
  51. data/lib/w3c_api/models/specification.rb +17 -9
  52. data/lib/w3c_api/models/specification_index.rb +3 -2
  53. data/lib/w3c_api/models/team_contact_index.rb +3 -2
  54. data/lib/w3c_api/models/testimonial.rb +2 -2
  55. data/lib/w3c_api/models/translation.rb +4 -4
  56. data/lib/w3c_api/models/translation_index.rb +3 -2
  57. data/lib/w3c_api/models/user.rb +16 -11
  58. data/lib/w3c_api/models/user_index.rb +2 -2
  59. data/lib/w3c_api/models.rb +52 -37
  60. data/lib/w3c_api/version.rb +1 -1
  61. data/lib/w3c_api.rb +8 -7
  62. metadata +10 -19
@@ -1,14 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
- require 'rainbow'
5
- require 'pp'
6
- require_relative 'hal'
3
+ require "json"
4
+ require "rainbow"
5
+ require "pp"
6
+ require_relative "hal"
7
7
 
8
8
  module W3cApi
9
9
  class Client
10
+ # Class method to list endpoints that support embed parameter
11
+ def self.embed_supported_endpoints
12
+ hal_instance = W3cApi::Hal.instance
13
+ endpoints_with_embed = []
14
+
15
+ hal_instance.register.models.each do |endpoint_id, endpoint_config|
16
+ # Check if this endpoint has embed parameter support
17
+ has_embed = endpoint_config[:parameters].any? do |param|
18
+ param.name == "embed" && param.location == :query
19
+ end
20
+
21
+ endpoints_with_embed << endpoint_id if has_embed
22
+ end
23
+
24
+ endpoints_with_embed.sort
25
+ end
26
+
27
+ # Instance method to check if a specific endpoint supports embed
28
+ def embed_supported?(endpoint_id)
29
+ self.class.embed_supported_endpoints.include?(endpoint_id)
30
+ end
31
+
10
32
  # Specification methods
11
- def specifications(options = nil)
33
+ def specifications(options = {})
12
34
  fetch_resource(:specification_index, **(options || {}))
13
35
  end
14
36
 
@@ -26,7 +48,7 @@ module W3cApi
26
48
  :specification_resource_version_resource,
27
49
  shortname: shortname,
28
50
  version: version,
29
- **options
51
+ **options,
30
52
  )
31
53
  end
32
54
 
@@ -79,7 +101,8 @@ module W3cApi
79
101
  fetch_resource(:group_resource, id: id, **options)
80
102
  end
81
103
 
82
- %w[specifications users charters chairs team_contacts participations].each do |resource|
104
+ %w[specifications users charters chairs team_contacts
105
+ participations].each do |resource|
83
106
  define_method("group_#{resource}") do |id, options = {}|
84
107
  fetch_resource(:"group_#{resource}_index", id: id, **options)
85
108
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,9 +10,10 @@ module W3cApi
10
10
  class Affiliation < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch affiliations'
14
- option :id, type: :numeric, desc: 'Affiliation ID'
15
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch affiliations"
14
+ option :id, type: :numeric, desc: "Affiliation ID"
15
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
16
+ desc: "Output format"
16
17
  def fetch
17
18
  client = W3cApi::Client.new
18
19
 
@@ -26,18 +27,20 @@ module W3cApi
26
27
  output_results(affiliations, options[:format])
27
28
  end
28
29
 
29
- desc 'participants', 'Fetch participants of an affiliation'
30
- option :id, type: :numeric, required: true, desc: 'Affiliation ID'
31
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
30
+ desc "participants", "Fetch participants of an affiliation"
31
+ option :id, type: :numeric, required: true, desc: "Affiliation ID"
32
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
33
+ desc: "Output format"
32
34
  def participants
33
35
  client = W3cApi::Client.new
34
36
  participants = client.affiliation_participants(options[:id])
35
37
  output_results(participants, options[:format])
36
38
  end
37
39
 
38
- desc 'participations', 'Fetch participations of an affiliation'
39
- option :id, type: :numeric, required: true, desc: 'Affiliation ID'
40
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
40
+ desc "participations", "Fetch participations of an affiliation"
41
+ option :id, type: :numeric, required: true, desc: "Affiliation ID"
42
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
43
+ desc: "Output format"
41
44
  def participations
42
45
  client = W3cApi::Client.new
43
46
  participations = client.affiliation_participations(options[:id])
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,9 +10,10 @@ module W3cApi
10
10
  class Ecosystem < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch ecosystems'
14
- option :shortname, type: :string, desc: 'Ecosystem shortname'
15
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch ecosystems"
14
+ option :shortname, type: :string, desc: "Ecosystem shortname"
15
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
16
+ desc: "Output format"
16
17
  def fetch
17
18
  client = W3cApi::Client.new
18
19
 
@@ -26,27 +27,33 @@ module W3cApi
26
27
  output_results(ecosystems, options[:format])
27
28
  end
28
29
 
29
- desc 'groups', 'Fetch groups in an ecosystem'
30
- option :shortname, type: :string, required: true, desc: 'Ecosystem shortname'
31
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
30
+ desc "groups", "Fetch groups in an ecosystem"
31
+ option :shortname, type: :string, required: true,
32
+ desc: "Ecosystem shortname"
33
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
34
+ desc: "Output format"
32
35
  def groups
33
36
  client = W3cApi::Client.new
34
37
  groups = client.ecosystem_groups(options[:shortname])
35
38
  output_results(groups, options[:format])
36
39
  end
37
40
 
38
- desc 'evangelists', 'Fetch evangelists of an ecosystem'
39
- option :shortname, type: :string, required: true, desc: 'Ecosystem shortname'
40
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
41
+ desc "evangelists", "Fetch evangelists of an ecosystem"
42
+ option :shortname, type: :string, required: true,
43
+ desc: "Ecosystem shortname"
44
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
45
+ desc: "Output format"
41
46
  def evangelists
42
47
  client = W3cApi::Client.new
43
48
  evangelists = client.ecosystem_evangelists(options[:shortname])
44
49
  output_results(evangelists, options[:format])
45
50
  end
46
51
 
47
- desc 'member-organizations', 'Fetch member organizations of an ecosystem'
48
- option :shortname, type: :string, required: true, desc: 'Ecosystem shortname'
49
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
52
+ desc "member-organizations", "Fetch member organizations of an ecosystem"
53
+ option :shortname, type: :string, required: true,
54
+ desc: "Ecosystem shortname"
55
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
56
+ desc: "Output format"
50
57
  def member_organizations
51
58
  client = W3cApi::Client.new
52
59
  organizations = client.ecosystem_member_organizations(options[:shortname])
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,10 +10,11 @@ module W3cApi
10
10
  class Group < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch groups'
14
- option :id, type: :string, desc: 'Group ID'
15
- option :type, type: :string, desc: 'Group type'
16
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch groups"
14
+ option :id, type: :string, desc: "Group ID"
15
+ option :type, type: :string, desc: "Group type"
16
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
17
+ desc: "Output format"
17
18
  def fetch
18
19
  client = W3cApi::Client.new
19
20
 
@@ -29,54 +30,60 @@ module W3cApi
29
30
  output_results(groups, options[:format])
30
31
  end
31
32
 
32
- desc 'users', 'Fetch users in a group'
33
- option :id, type: :numeric, required: true, desc: 'Group ID'
34
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
33
+ desc "users", "Fetch users in a group"
34
+ option :id, type: :numeric, required: true, desc: "Group ID"
35
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
36
+ desc: "Output format"
35
37
  def users
36
38
  client = W3cApi::Client.new
37
39
  users = client.group_users(options[:id])
38
40
  output_results(users, options[:format])
39
41
  end
40
42
 
41
- desc 'specifications', 'Fetch specifications produced by a group'
42
- option :id, type: :numeric, required: true, desc: 'Group ID'
43
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
43
+ desc "specifications", "Fetch specifications produced by a group"
44
+ option :id, type: :numeric, required: true, desc: "Group ID"
45
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
46
+ desc: "Output format"
44
47
  def specifications
45
48
  client = W3cApi::Client.new
46
49
  specifications = client.group_specifications(options[:id])
47
50
  output_results(specifications, options[:format])
48
51
  end
49
52
 
50
- desc 'charters', 'Fetch charters of a group'
51
- option :id, type: :numeric, required: true, desc: 'Group ID'
52
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
53
+ desc "charters", "Fetch charters of a group"
54
+ option :id, type: :numeric, required: true, desc: "Group ID"
55
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
56
+ desc: "Output format"
53
57
  def charters
54
58
  client = W3cApi::Client.new
55
59
  charters = client.group_charters(options[:id])
56
60
  output_results(charters, options[:format])
57
61
  end
58
62
 
59
- desc 'chairs', 'Fetch chairs of a group'
60
- option :id, type: :numeric, required: true, desc: 'Group ID'
61
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
63
+ desc "chairs", "Fetch chairs of a group"
64
+ option :id, type: :numeric, required: true, desc: "Group ID"
65
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
66
+ desc: "Output format"
62
67
  def chairs
63
68
  client = W3cApi::Client.new
64
69
  chairs = client.group_chairs(options[:id])
65
70
  output_results(chairs, options[:format])
66
71
  end
67
72
 
68
- desc 'team-contacts', 'Fetch team contacts of a group'
69
- option :id, type: :numeric, required: true, desc: 'Group ID'
70
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
73
+ desc "team-contacts", "Fetch team contacts of a group"
74
+ option :id, type: :numeric, required: true, desc: "Group ID"
75
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
76
+ desc: "Output format"
71
77
  def team_contacts
72
78
  client = W3cApi::Client.new
73
79
  team_contacts = client.group_team_contacts(options[:id])
74
80
  output_results(team_contacts, options[:format])
75
81
  end
76
82
 
77
- desc 'participations', 'Fetch participations in a group'
78
- option :id, type: :numeric, required: true, desc: 'Group ID'
79
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
83
+ desc "participations", "Fetch participations in a group"
84
+ option :id, type: :numeric, required: true, desc: "Group ID"
85
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
86
+ desc: "Output format"
80
87
  def participations
81
88
  client = W3cApi::Client.new
82
89
  participations = client.group_participations(options[:id])
@@ -6,7 +6,7 @@ module W3cApi
6
6
  # Format and output results based on the specified format
7
7
  def output_results(results, format)
8
8
  case format
9
- when 'yaml'
9
+ when "yaml"
10
10
  puts results.to_yaml
11
11
  else
12
12
  # Default to JSON if format is not recognized
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,18 +10,20 @@ module W3cApi
10
10
  class Participation < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch', 'Fetch a participation by ID'
14
- option :id, type: :numeric, required: true, desc: 'Participation ID'
15
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch", "Fetch a participation by ID"
14
+ option :id, type: :numeric, required: true, desc: "Participation ID"
15
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
16
+ desc: "Output format"
16
17
  def fetch
17
18
  client = W3cApi::Client.new
18
19
  participation = client.participation(options[:id])
19
20
  output_results(participation, options[:format])
20
21
  end
21
22
 
22
- desc 'participants', 'Fetch participants in a participation'
23
- option :id, type: :numeric, required: true, desc: 'Participation ID'
24
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
23
+ desc "participants", "Fetch participants in a participation"
24
+ option :id, type: :numeric, required: true, desc: "Participation ID"
25
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
26
+ desc: "Output format"
25
27
  def participants
26
28
  client = W3cApi::Client.new
27
29
  participants = client.participation_participants(options[:id])
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,9 +10,10 @@ module W3cApi
10
10
  class Series < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch specification series'
14
- option :shortname, type: :string, desc: 'Series shortname'
15
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch specification series"
14
+ option :shortname, type: :string, desc: "Series shortname"
15
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
16
+ desc: "Output format"
16
17
  def fetch
17
18
  client = W3cApi::Client.new
18
19
 
@@ -27,9 +28,10 @@ module W3cApi
27
28
  output_results(series, options[:format])
28
29
  end
29
30
 
30
- desc 'specifications', 'Fetch specifications in a series'
31
- option :shortname, type: :string, required: true, desc: 'Series shortname'
32
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
31
+ desc "specifications", "Fetch specifications in a series"
32
+ option :shortname, type: :string, required: true, desc: "Series shortname"
33
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
34
+ desc: "Output format"
33
35
  def specifications
34
36
  client = W3cApi::Client.new
35
37
  specifications = client.series_specifications(options[:shortname])
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,50 +10,39 @@ module W3cApi
10
10
  class Specification < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch specifications'
14
- option :shortname, type: :string, desc: 'Filter by shortname'
15
- option :version, type: :string, desc: 'Specific version of the specification'
16
- option :status, type: :string, desc: 'Filter by status'
17
- option :resolve, type: :array, desc: 'Links to resolve (e.g. version-history, latest-version, series)'
18
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch specifications"
14
+ option :shortname, type: :string, desc: "Filter by shortname"
15
+ option :version, type: :string,
16
+ desc: "Specific version of the specification"
17
+ option :status, type: :string, desc: "Filter by status"
18
+ option :resolve, type: :array,
19
+ desc: "Links to resolve (e.g. version-history, latest-version, series)"
20
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
21
+ desc: "Output format"
19
22
  def fetch
20
23
  client = W3cApi::Client.new
21
-
22
- specifications = if options[:shortname] && options[:version]
23
- # Single specification version
24
- client.specification_version(options[:shortname], options[:version])
25
- elsif options[:shortname]
26
- # Single specification
27
- client.specification(options[:shortname])
28
- elsif options[:status]
29
- # Specifications by status
30
- client.specifications_by_status(options[:status])
31
- else
32
- # All specifications
33
- client.specifications
34
- end
35
-
36
- # # Resolve links if specified
37
- # if options[:resolve] && specifications.respond_to?(:realize_links)
38
- # specifications.realize_links(options[:resolve], client)
39
- # end
40
-
24
+ specifications = fetch_specifications(client)
41
25
  output_results(specifications, options[:format])
42
26
  end
43
27
 
44
- desc 'versions', 'Fetch versions of a specification'
45
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
46
- option :resolve, type: :array, desc: 'Links to resolve on each version'
47
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
28
+ desc "versions", "Fetch versions of a specification"
29
+ option :shortname, type: :string, required: true,
30
+ desc: "Specification shortname"
31
+ option :resolve, type: :array, desc: "Links to resolve on each version"
32
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
33
+ desc: "Output format"
48
34
  def versions
49
35
  client = W3cApi::Client.new
50
36
  versions = client.specification_versions(options[:shortname])
51
37
  output_results(versions, options[:format])
52
38
  end
53
39
 
54
- desc 'supersedes', 'Fetch specifications that this specification supersedes'
55
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
56
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
40
+ desc "supersedes",
41
+ "Fetch specifications that this specification supersedes"
42
+ option :shortname, type: :string, required: true,
43
+ desc: "Specification shortname"
44
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
45
+ desc: "Output format"
57
46
  def supersedes
58
47
  # We need to add client.specification_supersedes method in the client
59
48
  client = W3cApi::Client.new
@@ -61,9 +50,12 @@ module W3cApi
61
50
  output_results(specifications, options[:format])
62
51
  end
63
52
 
64
- desc 'superseded-by', 'Fetch specifications that supersede this specification'
65
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
66
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
53
+ desc "superseded-by",
54
+ "Fetch specifications that supersede this specification"
55
+ option :shortname, type: :string, required: true,
56
+ desc: "Specification shortname"
57
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
58
+ desc: "Output format"
67
59
  def superseded_by
68
60
  # We need to add client.specification_superseded_by method in the client
69
61
  client = W3cApi::Client.new
@@ -71,23 +63,45 @@ module W3cApi
71
63
  output_results(specifications, options[:format])
72
64
  end
73
65
 
74
- desc 'editors', 'Fetch editors of a specification'
75
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
76
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
66
+ desc "editors", "Fetch editors of a specification"
67
+ option :shortname, type: :string, required: true,
68
+ desc: "Specification shortname"
69
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
70
+ desc: "Output format"
77
71
  def editors
78
72
  client = W3cApi::Client.new
79
73
  editors = client.specification_editors(options[:shortname])
80
74
  output_results(editors, options[:format])
81
75
  end
82
76
 
83
- desc 'deliverers', 'Fetch deliverers (working groups) of a specification'
84
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
85
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
77
+ desc "deliverers", "Fetch deliverers (working groups) of a specification"
78
+ option :shortname, type: :string, required: true,
79
+ desc: "Specification shortname"
80
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
81
+ desc: "Output format"
86
82
  def deliverers
87
83
  client = W3cApi::Client.new
88
84
  deliverers = client.specification_deliverers(options[:shortname])
89
85
  output_results(deliverers, options[:format])
90
86
  end
87
+
88
+ private
89
+
90
+ def fetch_specifications(client)
91
+ if options[:shortname] && options[:version]
92
+ # Single specification version
93
+ client.specification_version(options[:shortname], options[:version])
94
+ elsif options[:shortname]
95
+ # Single specification
96
+ client.specification(options[:shortname])
97
+ elsif options[:status]
98
+ # Specifications by status
99
+ client.specifications_by_status(options[:status])
100
+ else
101
+ # All specifications
102
+ client.specifications
103
+ end
104
+ end
91
105
  end
92
106
  end
93
107
  end
@@ -1,33 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
5
 
6
6
  module W3cApi
7
7
  module Commands
8
8
  class SpecificationVersion < Thor
9
9
  include OutputFormatter
10
10
 
11
- desc 'editors', 'Fetch editors of a specification version'
12
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
13
- option :version, type: :string, required: true, desc: 'Specification version'
14
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
11
+ desc "editors", "Fetch editors of a specification version"
12
+ option :shortname, type: :string, required: true,
13
+ desc: "Specification shortname"
14
+ option :version, type: :string, required: true,
15
+ desc: "Specification version"
16
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
17
+ desc: "Output format"
15
18
  def editors
16
19
  client = W3cApi::Client.new
17
- result = client.specification_version_editors(options[:shortname], options[:version])
20
+ result = client.specification_version_editors(options[:shortname],
21
+ options[:version])
18
22
  output_results(result, options[:format])
19
23
  rescue StandardError => e
20
24
  puts "Error: #{e.message}"
21
25
  exit 1
22
26
  end
23
27
 
24
- desc 'deliverers', 'Fetch deliverers (working groups) of a specification version'
25
- option :shortname, type: :string, required: true, desc: 'Specification shortname'
26
- option :version, type: :string, required: true, desc: 'Specification version'
27
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
28
+ desc "deliverers",
29
+ "Fetch deliverers (working groups) of a specification version"
30
+ option :shortname, type: :string, required: true,
31
+ desc: "Specification shortname"
32
+ option :version, type: :string, required: true,
33
+ desc: "Specification version"
34
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
35
+ desc: "Output format"
28
36
  def deliverers
29
37
  client = W3cApi::Client.new
30
- result = client.specification_version_deliverers(options[:shortname], options[:version])
38
+ result = client.specification_version_deliverers(options[:shortname],
39
+ options[:version])
31
40
  output_results(result, options[:format])
32
41
  rescue StandardError => e
33
42
  puts "Error: #{e.message}"
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'output_formatter'
5
- require_relative '../client'
3
+ require "thor"
4
+ require_relative "output_formatter"
5
+ require_relative "../client"
6
6
 
7
7
  module W3cApi
8
8
  module Commands
@@ -10,9 +10,10 @@ module W3cApi
10
10
  class Translation < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch a translation by ID'
14
- option :id, type: :string, desc: 'Translation ID'
15
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch a translation by ID"
14
+ option :id, type: :string, desc: "Translation ID"
15
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
16
+ desc: "Output format"
16
17
  def fetch
17
18
  client = W3cApi::Client.new
18
19