Class: Jambots::Controllers::InitController

Inherits:
Object
  • Object
show all
Defined in:
lib/jambots/controllers/init_controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ InitController

Returns a new instance of InitController.



4
5
6
# File 'lib/jambots/controllers/init_controller.rb', line 4

def initialize(options)
  @options = options
end

Instance Method Details

#init_jambots_pathObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jambots/controllers/init_controller.rb', line 8

def init_jambots_path
  path = if @options[:globally]
    File.expand_path("~/.jambots")
  elsif @options[:path]
    File.expand_path(@options[:path])
  else
    "./.jambots"
  end

  FileUtils.mkdir_p(path)
  puts "Jambots directory initialized at '#{path}'"

  # Create default bot
  Jambots::Controllers::NewController
    .new(path: path)
    .create_bot(Jambots::Controllers::ChatController::DEFAULT_BOT)
end