Module: Retriever

Included in:
License
Defined in:
lib/get/subcommand/license/license_retriever.rb

Overview

The retrieving module for licenses. It can gather licenses online (from choosealicense.com/appendix/) or offline (from a predefined subset of licenses).

Constant Summary collapse

BASE_OFFLINE_LICENSE_PATH =
"#{File.dirname(File.expand_path(__FILE__))}/offline_licenses".freeze
BASE_ONLINE_LICENSE_URI =
'https://choosealicense.com'
@@cli =
HighLine.new

Instance Method Summary collapse

Instance Method Details

#ask_for_license(offline) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/get/subcommand/license/license_retriever.rb', line 30

def ask_for_license(offline)
  @@offline = offline
  list = if @@offline
           offline_license_list
         else
           online_license_list
         end

  @@cli.puts 'Choose which license you want to use:'
  choice = @@cli.choose do |menu|
    menu.flow = :column_down
    menu.prompt = ''
    list.each { |element| menu.choice(element) }
  end

  if @@offline
    offline_license_text(choice)
  else
    online_license_text(choice)
  end
end