journal-cli 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 454b74fd0d807973fec7c1c0de222b4a725e7df98d32abb3c112a4cd5d8fe05b
4
- data.tar.gz: 160ce5a1e637c218fcae0a6b295b31af629654fe3ab66f3ad589ff04117e3055
3
+ metadata.gz: 7b3fcf300bf3f002d81aacd0bd78709bdb874a93168602658dce0de8d1cee285
4
+ data.tar.gz: 2a11aec3c0e3cd415905fd1c792d3e8117d110f5560b2e1491364712409fc2f4
5
5
  SHA512:
6
- metadata.gz: 9c8253e5a0e4127e13d1b697e6340fae5a24f9289043de349f6b5b4994a792d0a88d390b5d6f0856efa0c5e097c5d6573b97ccccb771d0c999ee029d9eb089e2
7
- data.tar.gz: 897061977f2b3de27fa5e9f8db934a9e21de963edbf37677e50c1463b59d85cd31f2b65cc334bdcc338659078c423b50e56aeaed97680938c3b0132591c81b8e
6
+ metadata.gz: 46a7d1397dc22078541d608dd0ba2147487bc9159cde1c051a0a8c09c24acb3890948ff1e1ae9dd8daa569e5ea5e0f600768302f67caffe193712aede07706e4
7
+ data.tar.gz: 53535dcc8d0c59cf64252d7725a1775cf6a29d64d89b22bd0838917dd8c08e3f5b817bfba72e6167ae55e7e2affe6764a38a44b5f5572e89ddaa1c0a8c585d1e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 1.0.13
2
+
3
+ 2023-09-07 06:57
4
+
5
+ #### NEW
6
+
7
+ - Allow entries_folder setting for top level and individual journals to put JSON and Markdown files anywhere the user wants
8
+
9
+ #### IMPROVED
10
+
11
+ - If a custom folder doesn't exist, create it automatically
12
+ - Updated documentatioh
13
+
1
14
  ### 1.0.12
2
15
 
3
16
  2023-09-06 16:43
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- journal-cli (1.0.12)
4
+ journal-cli (1.0.13)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -38,6 +38,8 @@ $ mkdir -p ~/.config/journal
38
38
  $ touch ~/.config/journal/journals.yaml
39
39
  ```
40
40
 
41
+ A skeleton file will be written the first time Journal is run if the config file doesn't exist.
42
+
41
43
  This file contains a YAML definition of your journal. Each journal gets a top-level key, which is what you'll specify it with on the command line. It gets a few settings, and then you define sections containing questions.
42
44
 
43
45
  ### Weather
@@ -49,6 +51,9 @@ You can include weather data automatically by setting a question type to 'weathe
49
51
  Edit the file at `~/.config/journal/journals.yaml` following this structure:
50
52
 
51
53
  ```yaml
54
+ # Where to save all journal entries (unless this key is defined inside the journal).
55
+ # The journal key will be appended to this to keep each journal separate
56
+ entries_folder: ~/.local/share/journal/
52
57
  journals:
53
58
  daily: # journal key, will be used on the command line as `journal daily`
54
59
  dayone: true # Enable or disable Day One integration
@@ -66,6 +71,8 @@ journals:
66
71
 
67
72
  Keys must be alphanumeric characters and `_` (underscore) only. Titles and questions can be anything, but if they contain a colon (:), you'll need to quote the string.
68
73
 
74
+ The `entries_folder` key can be set to save JSON and Markdown files to a custom, non-default location. The default is `~/.local/share/journal`. This key can also be used within a journal definition to offer custom save locations on a per-journal basis.
75
+
69
76
  A more complex configuration file can contain multiple journals with multiple questions defined:
70
77
 
71
78
  ```yaml
@@ -73,6 +80,7 @@ zip: 55987 # Your zip code for weather integration
73
80
  weather_api: XXXXXXXXXXXX # Your weatherapi.com API key
74
81
  journals: # required key
75
82
  mood: # name of the journal
83
+ entries_folder: ~/Desktop/Journal/mood # Where to save this specific journal's entries
76
84
  journal: Mood Journal # Optional, Day One journal to add to
77
85
  tags: [checkin] # Optional, array of tags to add to Day One entries
78
86
  markdown: individual # Can be daily or individual, any other value will create a single file
@@ -124,7 +132,9 @@ Once your configuration file is set up, you can just run `journal JOURNAL_KEY` t
124
132
 
125
133
  If a second argument contains a natural language date, the journal entry will be set to that date instead of the current time. For example, `journal mood "yesterday 5pm"` will create a new entry (in the journal configured for `mood`) for yesterday at 5pm.
126
134
 
127
- Answers will always be written to `~/.local/share/journal/[KEY].json` (where [KEY] is the journal key, one data file for each journal). If you've specified `daily` or `individual` Markdown formats, entries will be written to Markdown files in `~/.local/share/journal/entries/[KEY]`, either in a `%Y-%m-%d.md` file (daily), or in timestamped individual files. If `digest` is specified for the `markdown` key, a single file will be created at `~/.local/share/journal/[KEY].md`.
135
+ Answers will always be written to `~/.local/share/journal/[KEY]/[KEY].json` (where [KEY] is the journal key, one data file for each journal). If you've specified a top-level custom path with `entries_folder` in the config, entries will be written to `[top level folder]/[KEY]/entries`. If you've specified a custom path using `entries_folder` in the journal, entries will be written to `[custom folder]/entries`.
136
+
137
+ If you've specified `daily` or `individual` Markdown formats, entries will be written to Markdown files in `~/.local/share/journal/[KEY]/entries`, either in a `[KEY]-%Y-%m-%d.md` file (daily), or in timestamped individual files. If `digest` is specified for the `markdown` key, a single file will be created at `~/.local/share/journal/[KEY]/entries/[KEY].md` (or a folder defined by `entries_folder`).
128
138
 
129
139
  At present there's no tool for querying the dataset created. You just need to parse the JSON and use your language of choice to extract the data. Numeric entries are stored as numbers, and every entry is timestamped, so you should be able to do some advanced analysis once you have enough data.
130
140
 
@@ -66,7 +66,14 @@ module Journal
66
66
  end
67
67
 
68
68
  def save_single_markdown
69
- dir = File.expand_path('~/.local/share/journal/entries/')
69
+ dir = if @journal.key?('entries_folder')
70
+ File.join(File.expand_path(@journal['entries_folder']), 'entries')
71
+ elsif Journal.config.key?('entries_folder')
72
+ File.join(File.expand_path(Journal.config['entries_folder']), @key, 'entries')
73
+ else
74
+ File.expand_path('~/.local/share/journal', @key, 'entries')
75
+ end
76
+
70
77
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
71
78
  filename = "#{@key}.md"
72
79
  @date.localtime
@@ -81,10 +88,17 @@ module Journal
81
88
  end
82
89
 
83
90
  def save_daily_markdown
84
- dir = File.expand_path("~/.local/share/journal/entries/#{@key}")
91
+ dir = if @journal.key?('entries_folder')
92
+ File.join(File.expand_path(@journal['entries_folder']), 'entries')
93
+ elsif Journal.config.key?('entries_folder')
94
+ File.join(File.expand_path(Journal.config['entries_folder']), @key, 'entries')
95
+ else
96
+ File.join(File.expand_path('~/.local/share/journal/entries'), @key, 'entries')
97
+ end
98
+
85
99
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
86
100
  @date.localtime
87
- filename = "#{@date.strftime('%Y-%m-%d')}.md"
101
+ filename = "#{@key}_#{@date.strftime('%Y-%m-%d')}.md"
88
102
  target = File.join(dir, filename)
89
103
  if File.exist? target
90
104
  File.open(target, 'a') { |f| f.puts to_markdown(yaml: false, title: true, date: false, time: true) }
@@ -95,7 +109,15 @@ module Journal
95
109
  end
96
110
 
97
111
  def save_individual_markdown
98
- dir = File.expand_path("~/.local/share/journal/entries/#{@key}")
112
+ dir = if @journal.key?('entries_folder')
113
+ File.join(File.expand_path(@journal['entries_folder']), 'entries')
114
+ elsif Journal.config.key?('entries_folder')
115
+ File.join(File.expand_path(Journal.config['entries_folder']), @key,
116
+ 'entries')
117
+ else
118
+ File.join(File.expand_path('~/.local/share/journal'), @key, 'entries')
119
+ end
120
+
99
121
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
100
122
  @date.localtime
101
123
  filename = @date.strftime('%Y-%m-%d_%H:%M.md')
@@ -171,7 +193,15 @@ module Journal
171
193
 
172
194
  def save_data
173
195
  @date.localtime
174
- db = File.expand_path("~/.local/share/journal/#{@key}.json")
196
+ dir = if @journal.key?('entries_folder')
197
+ File.expand_path(@journal['entries_folder'])
198
+ elsif Journal.config.key?('entries_folder')
199
+ File.expand_path(Journal.config['entries_folder'])
200
+ else
201
+ File.expand_path("~/.local/share/journal")
202
+ end
203
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
204
+ db = File.join(dir, "#{@key}.json")
175
205
  data = if File.exist?(db)
176
206
  JSON.parse(IO.read(db))
177
207
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Journal
4
- VERSION = '1.0.12'
4
+ VERSION = '1.0.13'
5
5
  end
data/lib/journal-cli.rb CHANGED
@@ -25,11 +25,13 @@ module Journal
25
25
  default_config = {
26
26
  'weather_api' => 'XXXXXXXXXXXXXXXXXx',
27
27
  'zip' => 'XXXXX',
28
+ 'entries_folder' => '~/.local/share/journal/',
28
29
  'journals' => {
29
30
  'demo' => {
30
31
  'dayone' => false,
31
32
  'markdown' => 'single',
32
33
  'title' => '5-minute checkin',
34
+ 'entries_folder' => '~/.local/share/journal/',
33
35
  'sections' => [
34
36
  { 'title' => 'Quick checkin',
35
37
  'key' => 'checkin',
data/src/_README.md CHANGED
@@ -42,6 +42,8 @@ $ mkdir -p ~/.config/journal
42
42
  $ touch ~/.config/journal/journals.yaml
43
43
  ```
44
44
 
45
+ A skeleton file will be written the first time Journal is run if the config file doesn't exist.
46
+
45
47
  This file contains a YAML definition of your journal. Each journal gets a top-level key, which is what you'll specify it with on the command line. It gets a few settings, and then you define sections containing questions.
46
48
 
47
49
  ### Weather
@@ -53,6 +55,9 @@ You can include weather data automatically by setting a question type to 'weathe
53
55
  Edit the file at `~/.config/journal/journals.yaml` following this structure:
54
56
 
55
57
  ```yaml
58
+ # Where to save all journal entries (unless this key is defined inside the journal).
59
+ # The journal key will be appended to this to keep each journal separate
60
+ entries_folder: ~/.local/share/journal/
56
61
  journals:
57
62
  daily: # journal key, will be used on the command line as `journal daily`
58
63
  dayone: true # Enable or disable Day One integration
@@ -70,6 +75,8 @@ journals:
70
75
 
71
76
  Keys must be alphanumeric characters and `_` (underscore) only. Titles and questions can be anything, but if they contain a colon (:), you'll need to quote the string.
72
77
 
78
+ The `entries_folder` key can be set to save JSON and Markdown files to a custom, non-default location. The default is `~/.local/share/journal`. This key can also be used within a journal definition to offer custom save locations on a per-journal basis.
79
+
73
80
  A more complex configuration file can contain multiple journals with multiple questions defined:
74
81
 
75
82
  ```yaml
@@ -77,6 +84,7 @@ zip: 55987 # Your zip code for weather integration
77
84
  weather_api: XXXXXXXXXXXX # Your weatherapi.com API key
78
85
  journals: # required key
79
86
  mood: # name of the journal
87
+ entries_folder: ~/Desktop/Journal/mood # Where to save this specific journal's entries
80
88
  journal: Mood Journal # Optional, Day One journal to add to
81
89
  tags: [checkin] # Optional, array of tags to add to Day One entries
82
90
  markdown: individual # Can be daily or individual, any other value will create a single file
@@ -128,7 +136,9 @@ Once your configuration file is set up, you can just run `journal JOURNAL_KEY` t
128
136
 
129
137
  If a second argument contains a natural language date, the journal entry will be set to that date instead of the current time. For example, `journal mood "yesterday 5pm"` will create a new entry (in the journal configured for `mood`) for yesterday at 5pm.
130
138
 
131
- Answers will always be written to `~/.local/share/journal/[KEY].json` (where [KEY] is the journal key, one data file for each journal). If you've specified `daily` or `individual` Markdown formats, entries will be written to Markdown files in `~/.local/share/journal/entries/[KEY]`, either in a `%Y-%m-%d.md` file (daily), or in timestamped individual files. If `digest` is specified for the `markdown` key, a single file will be created at `~/.local/share/journal/[KEY].md`.
139
+ Answers will always be written to `~/.local/share/journal/[KEY]/[KEY].json` (where [KEY] is the journal key, one data file for each journal). If you've specified a top-level custom path with `entries_folder` in the config, entries will be written to `[top level folder]/[KEY]/entries`. If you've specified a custom path using `entries_folder` in the journal, entries will be written to `[custom folder]/entries`.
140
+
141
+ If you've specified `daily` or `individual` Markdown formats, entries will be written to Markdown files in `~/.local/share/journal/[KEY]/entries`, either in a `[KEY]-%Y-%m-%d.md` file (daily), or in timestamped individual files. If `digest` is specified for the `markdown` key, a single file will be created at `~/.local/share/journal/[KEY]/entries/[KEY].md` (or a folder defined by `entries_folder`).
132
142
 
133
143
  At present there's no tool for querying the dataset created. You just need to parse the JSON and use your language of choice to extract the data. Numeric entries are stored as numbers, and every entry is timestamped, so you should be able to do some advanced analysis once you have enough data.
134
144
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: journal-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler