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



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
38
39
# File 'lib/daigaku/terminal/setup.rb', line 12

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}", 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.downcase == 'yes'

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

  prepare_directories(@daigaku_path)
end

#listObject



42
43
44
# File 'lib/daigaku/terminal/setup.rb', line 42

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

#setObject



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

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 %x{ 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