Class: Gem::Commands::LicenseCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::LicenseCommand
- Includes:
- License
- Defined in:
- lib/rubygems/commands/license_command.rb
Overview
license gem plugin
Instance Method Summary collapse
- #arguments ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ LicenseCommand
constructor
A new instance of LicenseCommand.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ LicenseCommand
Returns a new instance of LicenseCommand.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubygems/commands/license_command.rb', line 11 def initialize super('license', 'Download a license by SPDX id') add_option('-m', '--markdown', 'Download as LICENSE.md') do |_, | [:markdown] = true end add_option('-s', '--stdout', 'Write to STDOUT instead of LICENSE') do |_, | [:stdout] = true end add_option('-o', '--output=PATH', 'Specify an output path') do |value, | [:output_path] = value end add_option('-l', '--list', 'View all available licenses') do |_, | [:list] = true end add_option('-f', '--format', 'Attempt to fill in values like year, author, and program name') do |_, | [:format] = true end end |
Instance Method Details
#arguments ⇒ Object
53 54 55 |
# File 'lib/rubygems/commands/license_command.rb', line 53 def arguments 'SPDX_IDENTIFIER An identifier from SPDX\'s license list https://spdx.org/licenses/' end |
#description ⇒ Object
49 50 51 |
# File 'lib/rubygems/commands/license_command.rb', line 49 def description 'Fetch a LICENSE based on an SPDX identifier' end |
#execute ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubygems/commands/license_command.rb', line 35 def execute if [:list] list = fetch_license_list just_size = list.collect { |lsc| lsc['licenseId'].length }.max list.each do |license| say(license['licenseId'].ljust(just_size) + ' - ' + license['name']) end exit end id = [:args].first || abort("USAGE: #{usage}") download(id, ) end |
#usage ⇒ Object
57 58 59 |
# File 'lib/rubygems/commands/license_command.rb', line 57 def usage 'gem license SPDX_IDENTIFIER' end |