Class: W3cApi::Commands::Specification

Inherits:
Thor
  • Object
show all
Includes:
OutputFormatter
Defined in:
lib/w3c_api/commands/specification.rb

Overview

Thor CLI command for specification operations

Instance Method Summary collapse

Methods included from OutputFormatter

#output_results

Instance Method Details

#fetchObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/w3c_api/commands/specification.rb', line 18

def fetch
  client = W3cApi::Client.new

  specifications = if options[:shortname] && options[:version]
                     # Single specification version
                     client.specification_version(options[:shortname], options[:version])
                   elsif options[:shortname]
                     # Single specification
                     client.specification(options[:shortname])
                   elsif options[:status]
                     # Specifications by status
                     client.specifications_by_status(options[:status])
                   else
                     # All specifications
                     client.specifications
                   end

  output_results(specifications, options[:format])
end

#superseded_byObject



60
61
62
63
64
65
# File 'lib/w3c_api/commands/specification.rb', line 60

def superseded_by
  # We need to add client.specification_superseded_by method in the client
  client = W3cApi::Client.new
  specifications = client.specification_superseded_by(options[:shortname])
  output_results(specifications, options[:format])
end

#supersedesObject



50
51
52
53
54
55
# File 'lib/w3c_api/commands/specification.rb', line 50

def supersedes
  # We need to add client.specification_supersedes method in the client
  client = W3cApi::Client.new
  specifications = client.specification_supersedes(options[:shortname])
  output_results(specifications, options[:format])
end

#versionsObject



41
42
43
44
45
# File 'lib/w3c_api/commands/specification.rb', line 41

def versions
  client = W3cApi::Client.new
  versions = client.specification_versions(options[:shortname])
  output_results(versions, options[:format])
end