Class: Decko::Generators::Deck::DeckGenerator::Interactive

Inherits:
Object
  • Object
show all
Defined in:
card/lib/generators/deck/deck_generator/interactive.rb

Overview

Guides through the decko deck installation with an interactive menu Offers the possibilitiy to - edit database config - edit application.rb - seed database - run server

Instance Method Summary collapse

Constructor Details

#initialize(destination_root, dev = false) ⇒ Interactive

Returns a new instance of Interactive.



12
13
14
15
# File 'card/lib/generators/deck/deck_generator/interactive.rb', line 12

def initialize destination_root, dev=false
  @dev = dev
  @destination_root = destination_root
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'card/lib/generators/deck/deck_generator/interactive.rb', line 17

def run
  require config_path("application") # need this for Rails.env
  @menu = ActiveSupport::OrderedHash.new
  add_config_options
  add_seed_options
  add_exit_option
  while (answer = ask(build_menu)) != "x"
    if @menu.key? answer
      @menu[answer][:code].call
    else
      puts "invalid choice"
    end
  end
end