w3c_api 0.1.4 → 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 +20 -38
  4. data/README.adoc +51 -0
  5. data/Rakefile +3 -3
  6. data/demo/rate_limiting_demo.rb +135 -0
  7. data/demo/test_embed_functionality.rb +31 -30
  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 +8 -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 +7 -7
  24. data/lib/w3c_api/hal.rb +168 -133
  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 -8
  62. metadata +8 -5
@@ -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
 
@@ -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,63 +10,75 @@ module W3cApi
10
10
  class User < Thor
11
11
  include OutputFormatter
12
12
 
13
- desc 'fetch [OPTIONS]', 'Fetch a user by ID'
14
- option :id, type: :string, required: true, desc: 'User ID (required)'
15
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
13
+ desc "fetch [OPTIONS]", "Fetch a user by ID"
14
+ option :id, type: :string, required: true, desc: "User ID (required)"
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
  user = client.user(options[:id])
19
20
  output_results(user, options[:format])
20
21
  end
21
22
 
22
- desc 'groups', 'Fetch groups a user is a member of'
23
- option :id, type: :string, required: true, desc: 'User ID'
24
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
23
+ desc "groups", "Fetch groups a user is a member of"
24
+ option :id, type: :string, required: true, desc: "User ID"
25
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
26
+ desc: "Output format"
25
27
  def groups
26
28
  client = W3cApi::Client.new
27
29
  groups = client.user_groups(options[:id])
28
30
  output_results(groups, options[:format])
29
31
  end
30
32
 
31
- desc 'specifications', 'Fetch specifications a user has contributed to'
32
- option :id, type: :string, required: true, desc: 'User ID (string or numeric)'
33
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
33
+ desc "specifications", "Fetch specifications a user has contributed to"
34
+ option :id, type: :string, required: true,
35
+ desc: "User ID (string or numeric)"
36
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
37
+ desc: "Output format"
34
38
  def specifications
35
39
  client = W3cApi::Client.new
36
40
  specifications = client.user_specifications(options[:id])
37
41
  output_results(specifications, options[:format])
38
42
  end
39
43
 
40
- desc 'affiliations', 'Fetch affiliations of a user'
41
- option :id, type: :string, required: true, desc: 'User ID (string or numeric)'
42
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
44
+ desc "affiliations", "Fetch affiliations of a user"
45
+ option :id, type: :string, required: true,
46
+ desc: "User ID (string or numeric)"
47
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
48
+ desc: "Output format"
43
49
  def affiliations
44
50
  client = W3cApi::Client.new
45
51
  affiliations = client.user_affiliations(options[:id])
46
52
  output_results(affiliations, options[:format])
47
53
  end
48
54
 
49
- desc 'participations', 'Fetch participations of a user'
50
- option :id, type: :string, required: true, desc: 'User ID (string or numeric)'
51
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
55
+ desc "participations", "Fetch participations of a user"
56
+ option :id, type: :string, required: true,
57
+ desc: "User ID (string or numeric)"
58
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
59
+ desc: "Output format"
52
60
  def participations
53
61
  client = W3cApi::Client.new
54
62
  participations = client.user_participations(options[:id])
55
63
  output_results(participations, options[:format])
56
64
  end
57
65
 
58
- desc 'chair-of-groups', 'Fetch groups a user chairs'
59
- option :id, type: :string, required: true, desc: 'User ID (string or numeric)'
60
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
66
+ desc "chair-of-groups", "Fetch groups a user chairs"
67
+ option :id, type: :string, required: true,
68
+ desc: "User ID (string or numeric)"
69
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
70
+ desc: "Output format"
61
71
  def chair_of_groups
62
72
  client = W3cApi::Client.new
63
73
  groups = client.user_chair_of_groups(options[:id])
64
74
  output_results(groups, options[:format])
65
75
  end
66
76
 
67
- desc 'team-contact-of-groups', 'Fetch groups a user is a team contact of'
68
- option :id, type: :string, required: true, desc: 'User ID (string or numeric)'
69
- option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
77
+ desc "team-contact-of-groups", "Fetch groups a user is a team contact of"
78
+ option :id, type: :string, required: true,
79
+ desc: "User ID (string or numeric)"
80
+ option :format, type: :string, default: "yaml", enum: %w[json yaml],
81
+ desc: "Output format"
70
82
  def team_contact_of_groups
71
83
  client = W3cApi::Client.new
72
84
  groups = client.user_team_contact_of_groups(options[:id])
data/lib/w3c_api/embed.rb CHANGED
@@ -17,9 +17,9 @@ module W3cApi
17
17
  # Get human-readable descriptions of embed-supported endpoints
18
18
  def endpoint_descriptions
19
19
  {
20
- specification_index: 'Specifications index with embedded specification details',
21
- group_index: 'Groups index with embedded group details',
22
- serie_index: 'Series index with embedded series details'
20
+ specification_index: "Specifications index with embedded specification details",
21
+ group_index: "Groups index with embedded group details",
22
+ serie_index: "Series index with embedded series details",
23
23
  }
24
24
  end
25
25
 
@@ -29,10 +29,10 @@ module W3cApi
29
29
  supported_endpoints: supported_endpoints,
30
30
  descriptions: endpoint_descriptions,
31
31
  usage_example: {
32
- discovery: 'W3cApi::Client.embed_supported_endpoints',
33
- usage: 'W3cApi::Client.new.specifications(embed: true, items: 2)',
34
- automatic_realization: 'spec_link.realize # Uses embedded content automatically'
35
- }
32
+ discovery: "W3cApi::Client.embed_supported_endpoints",
33
+ usage: "W3cApi::Client.new.specifications(embed: true, items: 2)",
34
+ automatic_realization: "spec_link.realize # Uses embedded content automatically",
35
+ },
36
36
  }
37
37
  end
38
38
  end