w3c_api 0.1.0 → 0.1.2

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +40 -0
  4. data/LICENSE.md +1 -1
  5. data/README.adoc +1032 -439
  6. data/Rakefile +7 -3
  7. data/lib/w3c_api/cli.rb +20 -20
  8. data/lib/w3c_api/client.rb +57 -237
  9. data/lib/w3c_api/commands/affiliation.rb +33 -33
  10. data/lib/w3c_api/commands/ecosystem.rb +47 -47
  11. data/lib/w3c_api/commands/group.rb +68 -68
  12. data/lib/w3c_api/commands/output_formatter.rb +11 -11
  13. data/lib/w3c_api/commands/participation.rb +20 -22
  14. data/lib/w3c_api/commands/series.rb +26 -26
  15. data/lib/w3c_api/commands/specification.rb +77 -52
  16. data/lib/w3c_api/commands/translation.rb +18 -18
  17. data/lib/w3c_api/commands/user.rb +60 -60
  18. data/lib/w3c_api/hal.rb +294 -0
  19. data/lib/w3c_api/models/account.rb +46 -0
  20. data/lib/w3c_api/models/affiliation.rb +54 -65
  21. data/lib/w3c_api/models/affiliation_index.rb +11 -0
  22. data/lib/w3c_api/models/call_for_translation.rb +15 -39
  23. data/lib/w3c_api/models/chair_index.rb +11 -0
  24. data/lib/w3c_api/models/charter.rb +48 -89
  25. data/lib/w3c_api/models/charter_index.rb +11 -0
  26. data/lib/w3c_api/models/connected_account.rb +21 -30
  27. data/lib/w3c_api/models/ecosystem.rb +20 -42
  28. data/lib/w3c_api/models/{ecosystems.rb → ecosystem_index.rb} +4 -10
  29. data/lib/w3c_api/models/evangelist_index.rb +11 -0
  30. data/lib/w3c_api/models/extension.rb +5 -7
  31. data/lib/w3c_api/models/group.rb +63 -142
  32. data/lib/w3c_api/models/group_index.rb +12 -0
  33. data/lib/w3c_api/models/group_link_set.rb +24 -0
  34. data/lib/w3c_api/models/join_emails.rb +5 -7
  35. data/lib/w3c_api/models/participant_index.rb +11 -0
  36. data/lib/w3c_api/models/participation.rb +31 -90
  37. data/lib/w3c_api/models/participation_index.rb +11 -0
  38. data/lib/w3c_api/models/photo.rb +28 -0
  39. data/lib/w3c_api/models/serie.rb +21 -51
  40. data/lib/w3c_api/models/{series.rb → serie_index.rb} +22 -13
  41. data/lib/w3c_api/models/spec_version.rb +69 -83
  42. data/lib/w3c_api/models/spec_version_index.rb +14 -0
  43. data/lib/w3c_api/models/spec_version_ref.rb +11 -13
  44. data/lib/w3c_api/models/specification.rb +54 -66
  45. data/lib/w3c_api/models/specification_index.rb +12 -0
  46. data/lib/w3c_api/models/team_contact_index.rb +11 -0
  47. data/lib/w3c_api/models/testimonial.rb +19 -0
  48. data/lib/w3c_api/models/translation.rb +33 -72
  49. data/lib/w3c_api/models/{translations.rb → translation_index.rb} +5 -11
  50. data/lib/w3c_api/models/user.rb +95 -165
  51. data/lib/w3c_api/models/user_index.rb +11 -0
  52. data/lib/w3c_api/models.rb +36 -12
  53. data/lib/w3c_api/version.rb +1 -1
  54. data/lib/w3c_api.rb +3 -2
  55. metadata +38 -19
  56. data/lib/w3c_api/models/affiliations.rb +0 -33
  57. data/lib/w3c_api/models/base.rb +0 -39
  58. data/lib/w3c_api/models/call_for_translation_ref.rb +0 -15
  59. data/lib/w3c_api/models/charters.rb +0 -17
  60. data/lib/w3c_api/models/collection_base.rb +0 -79
  61. data/lib/w3c_api/models/delegate_enumerable.rb +0 -54
  62. data/lib/w3c_api/models/groups.rb +0 -38
  63. data/lib/w3c_api/models/link.rb +0 -17
  64. data/lib/w3c_api/models/participations.rb +0 -17
  65. data/lib/w3c_api/models/series_collection.rb +0 -17
  66. data/lib/w3c_api/models/spec_versions.rb +0 -17
  67. data/lib/w3c_api/models/specifications.rb +0 -17
  68. data/lib/w3c_api/models/users.rb +0 -44
data/Rakefile CHANGED
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- task default: :spec
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/lib/w3c_api/cli.rb CHANGED
@@ -11,31 +11,31 @@ require_relative 'commands/affiliation'
11
11
  require_relative 'commands/participation'
12
12
 
13
13
  module W3cApi
14
- # Main CLI class that registers all subcommands
15
- class Cli < Thor
16
- # Register subcommands
17
- desc 'specification SUBCOMMAND ...ARGS', 'Work with W3C specifications'
18
- subcommand 'specification', Commands::Specification
14
+ # Main CLI class that registers all subcommands
15
+ class Cli < Thor
16
+ # Register subcommands
17
+ desc 'specification SUBCOMMAND ...ARGS', 'Work with W3C specifications'
18
+ subcommand 'specification', Commands::Specification
19
19
 
20
- desc 'group SUBCOMMAND ...ARGS', 'Work with W3C groups'
21
- subcommand 'group', Commands::Group
20
+ desc 'group SUBCOMMAND ...ARGS', 'Work with W3C groups'
21
+ subcommand 'group', Commands::Group
22
22
 
23
- desc 'user SUBCOMMAND ...ARGS', 'Work with W3C users'
24
- subcommand 'user', Commands::User
23
+ desc 'user SUBCOMMAND ...ARGS', 'Work with W3C users'
24
+ subcommand 'user', Commands::User
25
25
 
26
- desc 'translation SUBCOMMAND ...ARGS', 'Work with W3C translations'
27
- subcommand 'translation', Commands::Translation
26
+ desc 'translation SUBCOMMAND ...ARGS', 'Work with W3C translations'
27
+ subcommand 'translation', Commands::Translation
28
28
 
29
- desc 'ecosystem SUBCOMMAND ...ARGS', 'Work with W3C ecosystems'
30
- subcommand 'ecosystem', Commands::Ecosystem
29
+ desc 'ecosystem SUBCOMMAND ...ARGS', 'Work with W3C ecosystems'
30
+ subcommand 'ecosystem', Commands::Ecosystem
31
31
 
32
- desc 'series SUBCOMMAND ...ARGS', 'Work with W3C specification series'
33
- subcommand 'series', Commands::Series
32
+ desc 'series SUBCOMMAND ...ARGS', 'Work with W3C specification series'
33
+ subcommand 'series', Commands::Series
34
34
 
35
- desc 'affiliation SUBCOMMAND ...ARGS', 'Work with W3C affiliations'
36
- subcommand 'affiliation', Commands::Affiliation
35
+ desc 'affiliation SUBCOMMAND ...ARGS', 'Work with W3C affiliations'
36
+ subcommand 'affiliation', Commands::Affiliation
37
37
 
38
- desc 'participation SUBCOMMAND ...ARGS', 'Work with W3C participations'
39
- subcommand 'participation', Commands::Participation
40
- end
38
+ desc 'participation SUBCOMMAND ...ARGS', 'Work with W3C participations'
39
+ subcommand 'participation', Commands::Participation
40
+ end
41
41
  end
@@ -1,320 +1,140 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday'
4
- require 'faraday/follow_redirects'
5
3
  require 'json'
4
+ require 'rainbow'
5
+ require 'pp'
6
+ require_relative 'hal'
6
7
 
7
8
  module W3cApi
8
- class Error < StandardError; end
9
- class NotFoundError < Error; end
10
- class UnauthorizedError < Error; end
11
- class BadRequestError < Error; end
12
- class ServerError < Error; end
13
-
14
9
  class Client
15
- API_ENDPOINT = 'https://api.w3.org'
16
-
17
- attr_reader :last_response
18
-
19
- def initialize(options = {})
20
- @api_endpoint = options[:api_endpoint] || API_ENDPOINT
21
- @connection = create_connection
22
- @params_default = { page: 1, items: 3000 }
23
- @debug = !ENV['DEBUG_API'].nil?
24
- end
25
-
26
10
  # Specification methods
27
-
28
- def specifications(options = {})
29
- response = get('specifications', options.merge(@params_default))
30
- Models::Specifications.from_response(response['_links']['specifications'])
11
+ def specifications(options = nil)
12
+ fetch_resource(:specification_index, **(options || {}))
31
13
  end
32
14
 
33
15
  def specification(shortname, options = {})
34
- response = get("specifications/#{shortname}", options)
35
- Models::Specification.from_response(response)
16
+ fetch_resource(:specification_resource, shortname: shortname, **options)
36
17
  end
37
18
 
38
19
  def specification_versions(shortname, options = {})
39
- response = get("specifications/#{shortname}/versions", options)
40
- Models::SpecVersions.from_response(response['_links']['version-history'])
20
+ fetch_resource(:specification_resource_version_index,
21
+ shortname: shortname, **options)
41
22
  end
42
23
 
43
24
  def specification_version(shortname, version, options = {})
44
- response = get("specifications/#{shortname}/versions/#{version}", options)
45
- Models::SpecVersion.from_response(response)
25
+ fetch_resource(:specification_resource_version_resource,
26
+ shortname: shortname, version: version, **options)
46
27
  end
47
28
 
48
29
  def specifications_by_status(status, options = {})
49
- response = get("specifications-by-status/#{status}", options.merge(@params_default))
50
- Models::Specifications.from_response(response['_links']['specifications'])
51
- end
52
-
53
- def specification_supersedes(shortname, options = {})
54
- response = get("specifications/#{shortname}/supersedes", options)
55
- Models::Specifications.from_response(response['_links']['specifications'])
30
+ fetch_resource(:specification_by_status_index, status: status, **options)
56
31
  end
57
32
 
58
- def specification_superseded_by(shortname, options = {})
59
- response = get("specifications/#{shortname}/superseded", options)
60
- Models::Specifications.from_response(response['_links']['specifications'])
33
+ %w[supersedes superseded_by editors deliverers].each do |method_suffix|
34
+ define_method("specification_#{method_suffix}") do |shortname, options = {}|
35
+ fetch_resource(:"specification_#{method_suffix}_index",
36
+ shortname: shortname, **options)
37
+ end
61
38
  end
62
39
 
63
40
  # Series methods
64
-
65
41
  def series(options = {})
66
- response = get('specification-series', options.merge(@params_default))
67
- Models::Series.from_response(response['_links']['specification-series'])
42
+ fetch_resource(:serie_index, **options)
68
43
  end
69
44
 
70
45
  def series_by_shortname(shortname, options = {})
71
- response = get("specification-series/#{shortname}", options)
72
- Models::Serie.from_response(response)
46
+ fetch_resource(:serie_resource, shortname: shortname, **options)
73
47
  end
74
48
 
75
49
  def series_specifications(shortname, options = {})
76
- response = get("specification-series/#{shortname}/specifications", options.merge(@params_default))
77
- Models::Specifications.from_response(response['_links']['specifications'])
50
+ fetch_resource(:serie_specification_resource,
51
+ shortname: shortname, **options)
78
52
  end
79
53
 
80
54
  # Group methods
81
-
82
55
  def groups(options = {})
83
- response = get('groups', options)
84
- Models::Groups.from_response(response['_links']['groups'])
56
+ fetch_resource(:group_index, **options)
85
57
  end
86
58
 
87
59
  def group(id, options = {})
88
- response = get("groups/#{id}", options)
89
- Models::Group.from_response(response)
90
- end
91
-
92
- def group_specifications(id, options = {})
93
- response = get("groups/#{id}/specifications", options)
94
- Models::Specifications.from_response(response['_links']['specifications'])
95
- end
96
-
97
- def group_users(id, options = {})
98
- response = get("groups/#{id}/users", options)
99
- Models::Users.from_response(response['_links']['users'])
60
+ fetch_resource(:group_resource, id: id, **options)
100
61
  end
101
62
 
102
- def group_charters(id, options = {})
103
- response = get("groups/#{id}/charters", options)
104
- Models::Charters.from_response(response['_links']['charters'])
105
- end
106
-
107
- def group_chairs(id, options = {})
108
- response = get("groups/#{id}/chairs", options)
109
- Models::Users.from_response(response['_links']['chairs'])
110
- rescue NotFoundError
111
- # Return empty users collection when endpoint not found
112
- Models::Users.from_response([])
113
- end
114
-
115
- def group_team_contacts(id, options = {})
116
- response = get("groups/#{id}/teamcontacts", options)
117
- Models::Users.from_response(response['_links']['team-contacts'])
118
- rescue NotFoundError
119
- # Return empty users collection when endpoint not found
120
- Models::Users.from_response([])
121
- end
122
-
123
- def group_participations(id, options = {})
124
- response = get("groups/#{id}/participations", options)
125
- Models::Participations.from_response(response['_links']['participations'])
63
+ %w[specifications users charters chairs team_contacts participations].each do |resource|
64
+ define_method("group_#{resource}") do |id, options = {}|
65
+ fetch_resource(:"group_#{resource}_index", id: id, **options)
66
+ end
126
67
  end
127
68
 
128
69
  # User methods
129
-
130
- def users(options = {})
131
- raise ArgumentError,
132
- 'The W3C API does not support fetching all users. You must provide a specific user ID with the user method.'
133
- end
134
-
135
- def user(id, options = {})
136
- response = get("users/#{id}", options)
137
- Models::User.from_response(response)
138
- end
139
-
140
- def user_specifications(id, options = {})
141
- response = get("users/#{id}/specifications", options)
142
- Models::Specifications.from_response(response['_links']['specifications'])
143
- rescue NotFoundError
144
- # Return empty specifications collection when endpoint not found
145
- Models::Specifications.from_response([])
146
- end
147
-
148
- def user_groups(id, options = {})
149
- response = get("users/#{id}/groups", options)
150
- Models::Groups.from_response(response['_links']['groups'])
151
- end
152
-
153
- def user_affiliations(id, options = {})
154
- response = get("users/#{id}/affiliations", options)
155
- Models::Affiliations.from_response(response['_links']['affiliations'])
156
- rescue NotFoundError
157
- # Return empty affiliations collection when endpoint not found
158
- Models::Affiliations.from_response([])
70
+ def user(hash, options = {})
71
+ fetch_resource(:user_resource, hash: hash, **options)
159
72
  end
160
73
 
161
- def user_participations(id, options = {})
162
- response = get("users/#{id}/participations", options)
163
- Models::Participations.from_response(response['_links']['participations'])
164
- rescue NotFoundError
165
- # Return empty participations collection when endpoint not found
166
- Models::Participations.from_response([])
167
- end
168
-
169
- def user_chair_of_groups(id, options = {})
170
- response = get("users/#{id}/chair-of-groups", options)
171
- Models::Groups.from_response(response['_links']['groups'])
172
- rescue NotFoundError
173
- # Return empty groups collection when endpoint not found
174
- Models::Groups.from_response([])
175
- end
176
-
177
- def user_team_contact_of_groups(id, options = {})
178
- response = get("users/#{id}/team-contact-of-groups", options)
179
- Models::Groups.from_response(response['_links']['groups'])
180
- rescue NotFoundError
181
- # Return empty groups collection when endpoint not found
182
- Models::Groups.from_response([])
74
+ %w[groups affiliations participations chair_of_groups
75
+ team_contact_of_groups specifications].each do |resource|
76
+ define_method("user_#{resource}") do |hash, options = {}|
77
+ fetch_resource(:"user_#{resource}_index", hash: hash, **options)
78
+ end
183
79
  end
184
80
 
185
81
  # Translation methods
186
-
187
82
  def translations(options = {})
188
- response = get('translations', options.merge(embed: true))
189
- Models::Translations.from_response(response['_links']['translations'])
83
+ fetch_resource(:translation_index, **options)
190
84
  end
191
85
 
192
86
  def translation(id, options = {})
193
- response = get("translations/#{id}", options)
194
- Models::Translation.from_response(response)
87
+ fetch_resource(:translation_resource, id: id, **options)
195
88
  end
196
89
 
197
90
  # Affiliation methods
198
-
199
91
  def affiliations(options = {})
200
- response = get('affiliations', options.merge(@params_default))
201
- Models::Affiliations.from_response(response['_links']['affiliations'])
92
+ fetch_resource(:affiliation_index, **options)
202
93
  end
203
94
 
204
95
  def affiliation(id, options = {})
205
- response = get("affiliations/#{id}", options)
206
- Models::Affiliation.from_response(response)
207
- end
208
-
209
- def affiliation_participants(id, options = {})
210
- response = get("affiliations/#{id}/participants", options)
211
- Models::Users.from_response(response['_links']['participants'])
96
+ fetch_resource(:affiliation_resource, id: id, **options)
212
97
  end
213
98
 
214
- def affiliation_participations(id, options = {})
215
- response = get("affiliations/#{id}/participations", options)
216
- Models::Participations.from_response(response['_links']['participations'])
99
+ %w[participants participations].each do |resource|
100
+ define_method("affiliation_#{resource}") do |id, options = {}|
101
+ fetch_resource(:"affiliation_#{resource}_index", id: id, **options)
102
+ end
217
103
  end
218
104
 
219
105
  # Ecosystem methods
220
-
221
106
  def ecosystems(options = {})
222
- response = get('ecosystems', options)
223
- Models::Ecosystems.from_response(response['_links']['ecosystems'])
224
- end
225
-
226
- def ecosystem(shortname, options = {})
227
- response = get("ecosystems/#{shortname}", options)
228
- Models::Ecosystem.from_response(response)
229
- end
230
-
231
- def ecosystem_groups(shortname, options = {})
232
- response = get("ecosystems/#{shortname}/groups", options)
233
- Models::Groups.from_response(response['_links']['groups'])
107
+ fetch_resource(:ecosystem_index, **options)
234
108
  end
235
109
 
236
- def ecosystem_evangelists(shortname, options = {})
237
- response = get("ecosystems/#{shortname}/evangelists", options)
238
- Models::Users.from_response(response['_links']['users'])
110
+ def ecosystem(id, options = {})
111
+ fetch_resource(:ecosystem_resource, id: id, **options)
239
112
  end
240
113
 
241
- def ecosystem_member_organizations(shortname, options = {})
242
- response = get("ecosystems/#{shortname}/member-organizations", options)
243
- Models::Affiliations.from_response(response['_links']['affiliations'])
114
+ %w[groups evangelists member_organizations].each do |resource|
115
+ define_method("ecosystem_#{resource}") do |shortname, options = {}|
116
+ fetch_resource(:"ecosystem_#{resource}_index",
117
+ shortname: shortname, **options)
118
+ end
244
119
  end
245
120
 
246
121
  # Participation methods
247
-
248
122
  def participation(id, options = {})
249
- response = get("participations/#{id}", options)
250
- Models::Participation.from_response(response)
123
+ fetch_resource(:participation_resource, id: id, **options)
251
124
  end
252
125
 
253
126
  def participation_participants(id, options = {})
254
- response = get("participations/#{id}/participants", options)
255
- Models::Users.from_response(response['_links']['users'])
256
- end
257
-
258
- # Make the get method public for testing
259
- def get(url, params = {})
260
- @last_response = @connection.get(url, params)
261
- handle_response(@last_response, url)
127
+ fetch_resource(:participation_participants_index, id: id, **options)
262
128
  end
263
129
 
264
130
  private
265
131
 
266
- def create_connection
267
- Faraday.new(url: @api_endpoint) do |conn|
268
- conn.use Faraday::FollowRedirects::Middleware
269
- conn.request :json
270
- conn.response :json, content_type: /\bjson$/
271
- conn.adapter Faraday.default_adapter
272
- end
273
- end
274
-
275
- def handle_response(response, url)
276
- debug_log(response, url) if @debug
277
-
278
- case response.status
279
- when 200..299
280
- response.body
281
- when 400
282
- raise W3cApi::BadRequestError, response_message(response)
283
- when 401
284
- raise W3cApi::UnauthorizedError, response_message(response)
285
- when 404
286
- raise W3cApi::NotFoundError, response_message(response)
287
- when 500..599
288
- raise W3cApi::ServerError, response_message(response)
132
+ def fetch_resource(resource_key, **params)
133
+ if params.any?
134
+ Hal.instance.register.fetch(resource_key, **params)
289
135
  else
290
- raise W3cApi::Error, response_message(response)
136
+ Hal.instance.register.fetch(resource_key)
291
137
  end
292
138
  end
293
-
294
- def debug_log(response, url)
295
- puts "\n===== DEBUG: W3C API REQUEST =====".blue if defined?(Rainbow)
296
- puts "\n===== DEBUG: W3C API REQUEST =====" unless defined?(Rainbow)
297
- puts "URL: #{url}"
298
- puts "Status: #{response.status}"
299
-
300
- # Format headers as JSON
301
- puts "\nHeaders:"
302
- headers_hash = response.headers.to_h
303
- puts JSON.pretty_generate(headers_hash)
304
-
305
- puts "\nResponse body:"
306
- if response.body.is_a?(Hash) || response.body.is_a?(Array)
307
- puts JSON.pretty_generate(response.body)
308
- else
309
- puts response.body.inspect
310
- end
311
- puts "===== END DEBUG OUTPUT =====\n"
312
- end
313
-
314
- def response_message(response)
315
- message = "Status: #{response.status}"
316
- message += ", Error: #{response.body['error']}" if response.body.is_a?(Hash) && response.body['error']
317
- message
318
- end
319
- end # End of Client class
320
- end # End of W3c module
139
+ end
140
+ end
@@ -5,44 +5,44 @@ require_relative 'output_formatter'
5
5
  require_relative '../client'
6
6
 
7
7
  module W3cApi
8
- module Commands
9
- # Thor CLI command for affiliation operations
10
- class Affiliation < Thor
11
- include OutputFormatter
8
+ module Commands
9
+ # Thor CLI command for affiliation operations
10
+ class Affiliation < Thor
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'
16
- def fetch
17
- client = W3cApi::Client.new
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'
16
+ def fetch
17
+ client = W3cApi::Client.new
18
18
 
19
- affiliations = if options[:id]
20
- # Single affiliation
21
- client.affiliation(options[:id])
22
- else
23
- client.affiliations
24
- end
19
+ affiliations = if options[:id]
20
+ # Single affiliation
21
+ client.affiliation(options[:id])
22
+ else
23
+ client.affiliations
24
+ end
25
25
 
26
- output_results(affiliations, options[:format])
27
- end
26
+ output_results(affiliations, options[:format])
27
+ end
28
28
 
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'
32
- def participants
33
- client = W3cApi::Client.new
34
- participants = client.affiliation_participants(options[:id])
35
- output_results(participants, options[:format])
36
- end
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'
32
+ def participants
33
+ client = W3cApi::Client.new
34
+ participants = client.affiliation_participants(options[:id])
35
+ output_results(participants, options[:format])
36
+ end
37
37
 
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'
41
- def participations
42
- client = W3cApi::Client.new
43
- participations = client.affiliation_participations(options[:id])
44
- output_results(participations, options[:format])
45
- end
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'
41
+ def participations
42
+ client = W3cApi::Client.new
43
+ participations = client.affiliation_participations(options[:id])
44
+ output_results(participations, options[:format])
46
45
  end
47
46
  end
47
+ end
48
48
  end
@@ -5,53 +5,53 @@ require_relative 'output_formatter'
5
5
  require_relative '../client'
6
6
 
7
7
  module W3cApi
8
- module Commands
9
- # Thor CLI command for ecosystem operations
10
- class Ecosystem < Thor
11
- include OutputFormatter
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'
16
- def fetch
17
- client = W3cApi::Client.new
18
-
19
- ecosystems = if options[:shortname]
20
- # Single ecosystem
21
- client.ecosystem(options[:shortname])
22
- else
23
- client.ecosystems
24
- end
25
-
26
- output_results(ecosystems, options[:format])
27
- end
28
-
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'
32
- def groups
33
- client = W3cApi::Client.new
34
- groups = client.ecosystem_groups(options[:shortname])
35
- output_results(groups, options[:format])
36
- end
37
-
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
- def evangelists
42
- client = W3cApi::Client.new
43
- evangelists = client.ecosystem_evangelists(options[:shortname])
44
- output_results(evangelists, options[:format])
45
- end
46
-
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'
50
- def member_organizations
51
- client = W3cApi::Client.new
52
- organizations = client.ecosystem_member_organizations(options[:shortname])
53
- output_results(organizations, options[:format])
54
- end
8
+ module Commands
9
+ # Thor CLI command for ecosystem operations
10
+ class Ecosystem < Thor
11
+ include OutputFormatter
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'
16
+ def fetch
17
+ client = W3cApi::Client.new
18
+
19
+ ecosystems = if options[:shortname]
20
+ # Single ecosystem
21
+ client.ecosystem(options[:shortname])
22
+ else
23
+ client.ecosystems
24
+ end
25
+
26
+ output_results(ecosystems, options[:format])
27
+ end
28
+
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'
32
+ def groups
33
+ client = W3cApi::Client.new
34
+ groups = client.ecosystem_groups(options[:shortname])
35
+ output_results(groups, options[:format])
36
+ end
37
+
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
+ def evangelists
42
+ client = W3cApi::Client.new
43
+ evangelists = client.ecosystem_evangelists(options[:shortname])
44
+ output_results(evangelists, options[:format])
45
+ end
46
+
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'
50
+ def member_organizations
51
+ client = W3cApi::Client.new
52
+ organizations = client.ecosystem_member_organizations(options[:shortname])
53
+ output_results(organizations, options[:format])
55
54
  end
56
55
  end
56
+ end
57
57
  end