class Til::Initializer
Public Instance Methods
create_notes_directory()
click to toggle source
# File lib/til/services/initializer.rb, line 22 def create_notes_directory d = Settings.load.directory FileUtils.mkdir_p(File.expand_path(d)) end
create_settings_file(settings_file_path=File.expand_path("~/.til.config"))
click to toggle source
# File lib/til/services/initializer.rb, line 8 def create_settings_file(settings_file_path=File.expand_path("~/.til.config")) begin notes_directory = ask("What directory do you want your TIL notes to live in? (If you have no preference, press return to default to `~/til`.)\n>") github_repo = ask("Do you have a GitHub repo for your TIL notes? Paste the URL here if so; otherwise, press return.\n>") File.open(settings_file_path, "w") do |f| f.write(settings_hash(notes_directory, github_repo).to_json) end rescue Interrupt puts "Aborted!" abort end end
settings_hash(notes_directory, github_repo)
click to toggle source
# File lib/til/services/initializer.rb, line 27 def settings_hash(notes_directory, github_repo) notes_directory = "~/til" if notes_directory.empty? settings_hash = { "directory" => notes_directory, } if !github_repo.empty? settings_hash["github_repo"] = github_repo.scan(/[^\/]*\/[^\/]*$/).first end settings_hash end