Class: Daigaku::Terminal::Setup

Inherits:
Thor
  • Object
show all
Includes:
Output
Defined in:
lib/daigaku/terminal/setup.rb

Instance Method Summary collapse

Instance Method Details

#initObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/daigaku/terminal/setup.rb', line 10

def init
  empty_line
  say 'Please type the base path in which you want to save your daigaku'
  say 'files. The "courses" folder and "solutions" folder will be created'
  say 'automatically.'

  loop do
    path = get 'path:'

    begin
      @daigaku_path = File.expand_path(path.to_s, Dir.pwd)
    rescue
      say_warning "#{path} is no valid path name. Try another!"
      next
    end

    say_warning 'Do you want to use the following path as your daigaku base path?'
    say "\"#{@daigaku_path}\""

    confirmation = get '(yes|no)'
    break if confirmation.casecmp('yes').zero?

    empty_line
    say 'No Problem. Just type another one!'
  end

  prepare_directories(@daigaku_path)
end

#listObject



40
41
42
# File 'lib/daigaku/terminal/setup.rb', line 40

def list
  say_info "Your current daigaku setup is:\n\n#{Daigaku.config.summary}"
end

#setObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/daigaku/terminal/setup.rb', line 57

def set
  courses_path = options[:paths] || options[:courses_path]
  solutions_path = options[:paths] || options[:solutions_path]

  if courses_path.nil? && solutions_path.nil?
    say_warning 'Please specify options when using this command!'
    say `daigaku setup help set`
    return
  end

  update_config(:courses_path, courses_path) if courses_path
  update_config(:solutions_path, solutions_path) if solutions_path

  Daigaku.config.save
  list
end