Module: Journal
- Defined in:
- lib/journal-cli.rb,
lib/journal-cli/data.rb,
lib/journal-cli/checkin.rb,
lib/journal-cli/section.rb,
lib/journal-cli/version.rb,
lib/journal-cli/weather.rb,
lib/journal-cli/question.rb,
lib/journal-cli/sections.rb
Overview
Main Journal module
Defined Under Namespace
Classes: Checkin, Data, Question, Section, Sections, Weather
Constant Summary collapse
- VERSION =
'1.0.36'
Class Attribute Summary collapse
-
.date ⇒ Object
Returns the value of attribute date.
Class Method Summary collapse
Class Attribute Details
.date ⇒ Object
Returns the value of attribute date.
25 26 27 |
# File 'lib/journal-cli.rb', line 25 def date @date end |
Class Method Details
.config ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/journal-cli.rb', line 37 def config unless @config config = File.("~/.config/journal/journals.yaml") unless File.exist?(config) default_config = { "weather_api" => "XXXXXXXXXXXXXXXXXx", "zip" => "XXXXX", "entries_folder" => "~/.local/share/journal/", "journals" => { "demo" => { "dayone" => false, "markdown" => "single", "title" => "5-minute checkin", "entries_folder" => "~/.local/share/journal/", "sections" => [ {"title" => "Quick checkin", "key" => "checkin", "questions" => [ {"prompt" => "What's happening?", "key" => "journal", "type" => "multiline"} ]} ] } } } File.open(config, "w") { |f| f.puts(YAML.dump(default_config)) } puts "New configuration written to #{config}, please edit." Process.exit 0 end @config = YAML.load(IO.read(config)) if @config["journals"].key?("demo") Journal.notify("{br}Demo journal detected, please edit the configuration file at {bw}#{config}", exit_code: 1) end end @config end |
.notify(string, debug: false, exit_code: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/journal-cli.rb', line 27 def notify(string, debug: false, exit_code: nil) if debug warn "{dw}#{string}{x}".x else warn "#{string}{x}".x end Process.exit exit_code unless exit_code.nil? end |