Class: ChefLicensing::LicenseKeyFetcher::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-licensing/license_key_fetcher/prompt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Prompt

Returns a new instance of Prompt.



8
9
10
11
# File 'lib/chef-licensing/license_key_fetcher/prompt.rb', line 8

def initialize(config = {})
  @config = config
  initialize_tui_engine
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/chef-licensing/license_key_fetcher/prompt.rb', line 6

def config
  @config
end

#license_typeObject

Returns the value of attribute license_type.



6
7
8
# File 'lib/chef-licensing/license_key_fetcher/prompt.rb', line 6

def license_type
  @license_type
end

#tui_engineObject

Returns the value of attribute tui_engine.



6
7
8
# File 'lib/chef-licensing/license_key_fetcher/prompt.rb', line 6

def tui_engine
  @tui_engine
end

Instance Method Details

#append_info_to_tui_engine(extra_info_hash) ⇒ Object



27
28
29
# File 'lib/chef-licensing/license_key_fetcher/prompt.rb', line 27

def append_info_to_tui_engine(extra_info_hash)
  tui_engine.append_info_to_input(extra_info_hash)
end

#fetchObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/chef-licensing/license_key_fetcher/prompt.rb', line 13

def fetch
  # Here info is a hash of { interaction_id: response }
  info = tui_engine.run_interaction(config[:start_interaction])

  # The interaction_id ask_for_license_id holds the license key
  # TODO: Do we move this to tui_engine?
  if info[:fetch_license_id].nil?
    []
  else
    self.license_type = info[:license_type]
    [info[:fetch_license_id]]
  end
end