Class: Til::Initializer

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions, Thor::Base
Defined in:
lib/til/initializer.rb

Instance Method Summary collapse

Instance Method Details

#create_notes_directoryObject



22
23
24
25
# File 'lib/til/initializer.rb', line 22

def create_notes_directory
  d = Settings.load.directory
  FileUtils.mkdir_p(File.expand_path(d))
end

#create_settings_fileObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/til/initializer.rb', line 8

def create_settings_file
  notes_directory = ask("What directory do you want your TIL notes to live in? (If you have no preference, `~/til` is a good option.)\n>")
  github_repo = ask("Do you have a GitHub repo for your TIL notes? If so, enter it in the form `kevinlitchfield/til`.\n>")

  settings_hash = {
    "directory" => notes_directory,
    "github_repo" => github_repo
  }
  puts "Creating a settings file at `#{Settings.settings_file_path}`."
  File.open(Settings.settings_file_path, "w") do |f|
    f.write(settings_hash.to_json)
  end
end