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
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/w3c_api"
5
+
6
+ # Advanced example: Rate limiting stress test and performance analysis
7
+ puts "W3C API Rate Limiting - Advanced Stress Test Example"
8
+ puts "=" * 55
9
+
10
+ puts "\nThis example demonstrates advanced rate limiting scenarios:"
11
+ puts "• Rapid sequential requests"
12
+ puts "• Performance analysis across different endpoints"
13
+ puts "• Dynamic configuration changes"
14
+ puts "• Load testing patterns"
15
+
16
+ # Create a client instance
17
+ client = W3cApi::Client.new
18
+
19
+ # Configure aggressive rate limiting for testing
20
+ W3cApi::Hal.instance.configure_rate_limiting(
21
+ max_retries: 3,
22
+ base_delay: 0.1, # Very short delay for testing
23
+ max_delay: 5.0, # Lower max delay
24
+ backoff_factor: 2.0,
25
+ )
26
+
27
+ puts "\n🔧 Rate limiting configuration for stress testing:"
28
+ puts " - Max retries: 3"
29
+ puts " - Base delay: 0.1s (very aggressive)"
30
+ puts " - Max delay: 5.0s"
31
+ puts " - Backoff factor: 2.0"
32
+
33
+ # Test 1: Rapid sequential requests
34
+ puts "\n1. 🚀 Rapid Sequential Requests Test:"
35
+ puts " Making 10 rapid requests to analyze rate limiting behavior..."
36
+
37
+ start_time = Time.now
38
+ successful_requests = 0
39
+ failed_requests = 0
40
+ request_times = []
41
+
42
+ 10.times do |i|
43
+ print " Request #{i + 1}: "
44
+ request_start = Time.now
45
+
46
+ begin
47
+ specs = client.specifications(items: 1)
48
+ request_time = (Time.now - request_start).round(3)
49
+ request_times << request_time
50
+ puts "✓ Success (#{specs.links.specifications.length} items, #{request_time}s)"
51
+ successful_requests += 1
52
+ rescue StandardError => e
53
+ request_time = (Time.now - request_start).round(3)
54
+ request_times << request_time
55
+ puts "✗ Failed: #{e.message} (#{request_time}s)"
56
+ failed_requests += 1
57
+ end
58
+ end
59
+
60
+ end_time = Time.now
61
+ total_time = (end_time - start_time).round(2)
62
+
63
+ puts "\n 📊 Performance Analysis:"
64
+ puts " - Successful requests: #{successful_requests}"
65
+ puts " - Failed requests: #{failed_requests}"
66
+ puts " - Total time: #{total_time}s"
67
+ puts " - Average time per request: #{(total_time / 10).round(3)}s"
68
+ puts " - Fastest request: #{request_times.min}s"
69
+ puts " - Slowest request: #{request_times.max}s"
70
+
71
+ # Test 2: Cross-endpoint performance analysis
72
+ puts "\n2. 🎯 Cross-Endpoint Performance Analysis:"
73
+ endpoints = [
74
+ { name: "specifications", method: :specifications,
75
+ link_key: :specifications },
76
+ { name: "groups", method: :groups, link_key: :groups },
77
+ { name: "series", method: :series, link_key: :series },
78
+ { name: "ecosystems", method: :ecosystems, link_key: :ecosystems },
79
+ ]
80
+
81
+ endpoint_results = {}
82
+
83
+ endpoints.each do |endpoint|
84
+ print " Testing #{endpoint[:name].ljust(15)}: "
85
+ start = Time.now
86
+
87
+ begin
88
+ result = client.send(endpoint[:method], items: 2)
89
+ duration = (Time.now - start).round(3)
90
+ count = result.links.send(endpoint[:link_key]).length
91
+
92
+ endpoint_results[endpoint[:name]] = {
93
+ success: true,
94
+ duration: duration,
95
+ count: count,
96
+ }
97
+
98
+ puts "✓ Success (#{count} items, #{duration}s)"
99
+ rescue StandardError => e
100
+ duration = (Time.now - start).round(3)
101
+ endpoint_results[endpoint[:name]] = {
102
+ success: false,
103
+ duration: duration,
104
+ error: e.message,
105
+ }
106
+ puts "✗ Failed: #{e.message} (#{duration}s)"
107
+ end
108
+ end
109
+
110
+ puts "\n 📈 Endpoint Performance Summary:"
111
+ endpoint_results.each do |name, result|
112
+ if result[:success]
113
+ puts " - #{name.ljust(15)}: #{result[:duration]}s (#{result[:count]} items)"
114
+ else
115
+ puts " - #{name.ljust(15)}: #{result[:duration]}s (FAILED)"
116
+ end
117
+ end
118
+
119
+ # Test 3: Dynamic configuration testing
120
+ puts "\n3. ⚙️ Dynamic Configuration Testing:"
121
+
122
+ begin
123
+ puts " Testing with rate limiting enabled..."
124
+ start = Time.now
125
+ client.specifications(items: 1)
126
+ time1 = (Time.now - start).round(3)
127
+ puts " ✓ Request 1 (enabled): #{time1}s"
128
+
129
+ puts " 🔄 Disabling rate limiting..."
130
+ W3cApi::Hal.instance.disable_rate_limiting
131
+
132
+ start = Time.now
133
+ client.specifications(items: 1)
134
+ time2 = (Time.now - start).round(3)
135
+ puts " ✓ Request 2 (disabled): #{time2}s"
136
+
137
+ puts " 🔄 Re-enabling with different configuration..."
138
+ W3cApi::Hal.instance.enable_rate_limiting
139
+ W3cApi::Hal.instance.configure_rate_limiting(
140
+ max_retries: 5,
141
+ base_delay: 0.2,
142
+ max_delay: 10.0,
143
+ backoff_factor: 1.5,
144
+ )
145
+
146
+ start = Time.now
147
+ client.specifications(items: 1)
148
+ time3 = (Time.now - start).round(3)
149
+ puts " ✓ Request 3 (reconfigured): #{time3}s"
150
+
151
+ puts "\n ⏱️ Timing Comparison:"
152
+ puts " - Enabled (default): #{time1}s"
153
+ puts " - Disabled: #{time2}s"
154
+ puts " - Reconfigured: #{time3}s"
155
+ rescue StandardError => e
156
+ puts " ✗ Error: #{e.message}"
157
+ end
158
+
159
+ # Test 4: Bulk operation simulation
160
+ puts "\n4. 📦 Bulk Operation Simulation:"
161
+ puts " Simulating a bulk data collection scenario..."
162
+
163
+ bulk_start = Time.now
164
+ bulk_results = []
165
+
166
+ # Simulate collecting data from multiple endpoints
167
+ bulk_operations = [
168
+ { name: "Collect specifications", method: :specifications, items: 3 },
169
+ { name: "Collect groups", method: :groups, items: 2 },
170
+ { name: "Collect series", method: :series, items: 2 },
171
+ ]
172
+
173
+ bulk_operations.each_with_index do |operation, _index|
174
+ print " #{operation[:name]}: "
175
+ op_start = Time.now
176
+
177
+ begin
178
+ result = client.send(operation[:method], items: operation[:items])
179
+ duration = (Time.now - op_start).round(3)
180
+
181
+ case operation[:method]
182
+ when :specifications
183
+ count = result.links.specifications.length
184
+ when :groups
185
+ count = result.links.groups.length
186
+ when :series
187
+ count = result.links.series.length
188
+ end
189
+
190
+ bulk_results << { success: true, duration: duration, count: count }
191
+ puts "✓ #{count} items (#{duration}s)"
192
+
193
+ # Add a small delay between bulk operations
194
+ sleep(0.1)
195
+ rescue StandardError => e
196
+ duration = (Time.now - op_start).round(3)
197
+ bulk_results << { success: false, duration: duration }
198
+ puts "✗ Failed: #{e.message} (#{duration}s)"
199
+ end
200
+ end
201
+
202
+ bulk_total_time = (Time.now - bulk_start).round(2)
203
+ successful_ops = bulk_results.count { |r| r[:success] }
204
+ total_items = bulk_results.select { |r| r[:success] }.sum { |r| r[:count] || 0 }
205
+
206
+ puts "\n 📊 Bulk Operation Results:"
207
+ puts " - Total time: #{bulk_total_time}s"
208
+ puts " - Successful operations: #{successful_ops}/#{bulk_operations.length}"
209
+ puts " - Total items collected: #{total_items}"
210
+ puts " - Average time per operation: #{(bulk_total_time / bulk_operations.length).round(3)}s"
211
+
212
+ puts "\n#{'=' * 55}"
213
+ puts "🎉 Advanced Stress Test Completed!"
214
+
215
+ puts "\n📋 Test Summary:"
216
+ puts "• Sequential requests: #{successful_requests}/10 successful"
217
+ puts "• Endpoint tests: #{endpoint_results.count do |_, r|
218
+ r[:success]
219
+ end}/#{endpoints.length} successful"
220
+ puts "• Configuration changes: Applied successfully"
221
+ puts "• Bulk operations: #{successful_ops}/#{bulk_operations.length} successful"
222
+
223
+ puts "\n💡 Key Insights:"
224
+ puts "• Rate limiting maintains API stability under load"
225
+ puts "• Configuration changes take effect immediately"
226
+ puts "• Different endpoints may have varying response times"
227
+ puts "• Bulk operations benefit from rate limiting protection"
228
+
229
+ puts "\n🔍 In Production Scenarios:"
230
+ puts "• Rate limiting prevents API abuse and ensures fair usage"
231
+ puts "• Exponential backoff reduces server load during high traffic"
232
+ puts "• Retry-After headers are automatically respected"
233
+ puts "• 429 and 5xx errors are handled gracefully with retries"
234
+
235
+ puts "\n📚 Advanced Usage Tips:"
236
+ puts "• Monitor request patterns to optimize rate limiting settings"
237
+ puts "• Use bulk operations with manual delays for large datasets"
238
+ puts "• Adjust configuration based on API documentation"
239
+ puts "• Consider disabling rate limiting for controlled bulk operations"
data/exe/w3c_api CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'w3c_api'
4
+ require "w3c_api"
5
5
 
6
6
  W3cApi::Cli.start(ARGV)
data/lib/w3c_api/cli.rb CHANGED
@@ -1,45 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'commands/specification'
5
- require_relative 'commands/specification_version'
6
- require_relative 'commands/group'
7
- require_relative 'commands/user'
8
- require_relative 'commands/translation'
9
- require_relative 'commands/ecosystem'
10
- require_relative 'commands/series'
11
- require_relative 'commands/affiliation'
12
- require_relative 'commands/participation'
3
+ require "thor"
4
+ require_relative "commands/specification"
5
+ require_relative "commands/specification_version"
6
+ require_relative "commands/group"
7
+ require_relative "commands/user"
8
+ require_relative "commands/translation"
9
+ require_relative "commands/ecosystem"
10
+ require_relative "commands/series"
11
+ require_relative "commands/affiliation"
12
+ require_relative "commands/participation"
13
13
 
14
14
  module W3cApi
15
15
  # Main CLI class that registers all subcommands
16
16
  class Cli < Thor
17
17
  # Register subcommands
18
- desc 'specification SUBCOMMAND ...ARGS', 'Work with W3C specifications'
19
- subcommand 'specification', Commands::Specification
18
+ desc "specification SUBCOMMAND ...ARGS", "Work with W3C specifications"
19
+ subcommand "specification", Commands::Specification
20
20
 
21
- desc 'specification_version SUBCOMMAND ...ARGS', 'Work with W3C specification versions'
22
- subcommand 'specification_version', Commands::SpecificationVersion
21
+ desc "specification_version SUBCOMMAND ...ARGS",
22
+ "Work with W3C specification versions"
23
+ subcommand "specification_version", Commands::SpecificationVersion
23
24
 
24
- desc 'group SUBCOMMAND ...ARGS', 'Work with W3C groups'
25
- subcommand 'group', Commands::Group
25
+ desc "group SUBCOMMAND ...ARGS", "Work with W3C groups"
26
+ subcommand "group", Commands::Group
26
27
 
27
- desc 'user SUBCOMMAND ...ARGS', 'Work with W3C users'
28
- subcommand 'user', Commands::User
28
+ desc "user SUBCOMMAND ...ARGS", "Work with W3C users"
29
+ subcommand "user", Commands::User
29
30
 
30
- desc 'translation SUBCOMMAND ...ARGS', 'Work with W3C translations'
31
- subcommand 'translation', Commands::Translation
31
+ desc "translation SUBCOMMAND ...ARGS", "Work with W3C translations"
32
+ subcommand "translation", Commands::Translation
32
33
 
33
- desc 'ecosystem SUBCOMMAND ...ARGS', 'Work with W3C ecosystems'
34
- subcommand 'ecosystem', Commands::Ecosystem
34
+ desc "ecosystem SUBCOMMAND ...ARGS", "Work with W3C ecosystems"
35
+ subcommand "ecosystem", Commands::Ecosystem
35
36
 
36
- desc 'series SUBCOMMAND ...ARGS', 'Work with W3C specification series'
37
- subcommand 'series', Commands::Series
37
+ desc "series SUBCOMMAND ...ARGS", "Work with W3C specification series"
38
+ subcommand "series", Commands::Series
38
39
 
39
- desc 'affiliation SUBCOMMAND ...ARGS', 'Work with W3C affiliations'
40
- subcommand 'affiliation', Commands::Affiliation
40
+ desc "affiliation SUBCOMMAND ...ARGS", "Work with W3C affiliations"
41
+ subcommand "affiliation", Commands::Affiliation
41
42
 
42
- desc 'participation SUBCOMMAND ...ARGS', 'Work with W3C participations'
43
- subcommand 'participation', Commands::Participation
43
+ desc "participation SUBCOMMAND ...ARGS", "Work with W3C participations"
44
+ subcommand "participation", Commands::Participation
44
45
  end
45
46
  end
@@ -1,9 +1,9 @@
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
@@ -15,7 +15,7 @@ module W3cApi
15
15
  hal_instance.register.models.each do |endpoint_id, endpoint_config|
16
16
  # Check if this endpoint has embed parameter support
17
17
  has_embed = endpoint_config[:parameters].any? do |param|
18
- param.name == 'embed' && param.location == :query
18
+ param.name == "embed" && param.location == :query
19
19
  end
20
20
 
21
21
  endpoints_with_embed << endpoint_id if has_embed
@@ -48,7 +48,7 @@ module W3cApi
48
48
  :specification_resource_version_resource,
49
49
  shortname: shortname,
50
50
  version: version,
51
- **options
51
+ **options,
52
52
  )
53
53
  end
54
54
 
@@ -101,7 +101,8 @@ module W3cApi
101
101
  fetch_resource(:group_resource, id: id, **options)
102
102
  end
103
103
 
104
- %w[specifications users charters chairs team_contacts participations].each do |resource|
104
+ %w[specifications users charters chairs team_contacts
105
+ participations].each do |resource|
105
106
  define_method("group_#{resource}") do |id, options = {}|
106
107
  fetch_resource(:"group_#{resource}_index", id: id, **options)
107
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])