journal-cli 1.0.27 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/journal-cli/array.rb +11 -0
- data/lib/journal-cli/checkin.rb +22 -12
- data/lib/journal-cli/question.rb +1 -1
- data/lib/journal-cli/version.rb +1 -1
- data/lib/journal-cli/weather.rb +44 -20
- data/src/_README.md +5 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8f83764338d653909b55685394ab55398913f1dfdf5a529bfe2d7e94857c586
|
4
|
+
data.tar.gz: c068e0799c4438f45aad8ac2e265d42324da686712a85c1709cd491ea1ca476f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f35ef77c9762043790ee535e28a0892f78681f5895bd0db6cdb476e13524a35ccf0d80d31dff201a7307d630fc6f59729c9ba7b83698b7bbb428669cceafb96
|
7
|
+
data.tar.gz: 28fbd4e7ec6ac0ee506a8bed4413985a9424d6327025b571843bc0d28d17a17747808d33baa7d31d39d3e1e8b941c32a9dcf9883e5c5659af996261e7dc7f514
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
### 1.0.29
|
2
|
+
|
3
|
+
2023-10-01 15:24
|
4
|
+
|
5
|
+
#### IMPROVED
|
6
|
+
|
7
|
+
- Config option `temp_in` can be set to `c` or `f` to control what scale temps are recorded in
|
8
|
+
|
9
|
+
### 1.0.28
|
10
|
+
|
11
|
+
2023-09-30 11:01
|
12
|
+
|
13
|
+
#### IMPROVED
|
14
|
+
|
15
|
+
- If creating an entry for a past date, get the historical weather for that date
|
16
|
+
- Add weather.moon type for getting moon phase, and include moon_phase in general weather data
|
17
|
+
|
1
18
|
### 1.0.27
|
2
19
|
|
3
20
|
2023-09-23 08:03
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,8 @@ If a question type is set to `weather.forecast`, only the predicted condition, h
|
|
56
56
|
|
57
57
|
If the question type is `weather.current`, only the current condition and temperature will be recorded to the JSON, and a string containing "[TEMP] and [CONDITION]" (e.g. "64 and Sunny") will be recorded to Markdown/Day One for the question.
|
58
58
|
|
59
|
+
If the question type is `weather.moon`, only the moon phase will be output. Moon phase is also included in `weather.forecast` JSON and Markdown output.
|
60
|
+
|
59
61
|
### Journal Configuration
|
60
62
|
|
61
63
|
Edit the file at `~/.config/journal/journals.yaml` following this structure:
|
@@ -148,8 +150,9 @@ A question `type` can be one of:
|
|
148
150
|
- `text` or `string` will request a single-line string, submitted on return
|
149
151
|
- `multiline` for multiline strings (opens a readline editor, use ctrl-d to save)
|
150
152
|
- `weather` will just insert current weather data with no prompt
|
151
|
-
* `weather.forecast` will insert just the forecast
|
152
|
-
* `weather.current` will insert just the current temperature and condition
|
153
|
+
* `weather.forecast` will insert just the forecast (using weather history for backdated entries)
|
154
|
+
* `weather.current` will insert just the current temperature and condition (using weather history for backdated entries)
|
155
|
+
* `weather.moon` will insert the current moon phase for the entry date
|
153
156
|
- `number` or `float` will request numeric input, stored as a float (decimal)
|
154
157
|
- `integer` will convert numeric input to the nearest integer
|
155
158
|
- `date` will request a natural language date which will be parsed into a date object
|
data/lib/journal-cli/checkin.rb
CHANGED
@@ -136,11 +136,13 @@ module Journal
|
|
136
136
|
return if data.nil? || !data.key?(key) || data[key].nil?
|
137
137
|
|
138
138
|
case type
|
139
|
-
when /^(weather|forecast)/
|
139
|
+
when /^(weather|forecast|moon)/
|
140
140
|
header prompt
|
141
141
|
@output << case type
|
142
142
|
when /current$/
|
143
143
|
data[key].current
|
144
|
+
when /moon$/
|
145
|
+
"Moon phase: #{data[key].moon}"
|
144
146
|
else
|
145
147
|
data[key].to_markdown
|
146
148
|
end
|
@@ -174,6 +176,8 @@ module Journal
|
|
174
176
|
v.current
|
175
177
|
when /forecast$/
|
176
178
|
data[k] = v.forecast
|
179
|
+
when /moon(_?phase)?$/
|
180
|
+
data[k] = v.moon
|
177
181
|
else
|
178
182
|
data[k] = v.to_s
|
179
183
|
end
|
@@ -258,17 +262,23 @@ module Journal
|
|
258
262
|
v.each do |key, value|
|
259
263
|
result = case value.class.to_s
|
260
264
|
when /Weather/
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
265
|
+
case key
|
266
|
+
when /current$/
|
267
|
+
{
|
268
|
+
'temp' => value.data[:temp],
|
269
|
+
'condition' => value.data[:current_condition]
|
270
|
+
}
|
271
|
+
when /moon(_?phase)?$/
|
272
|
+
{
|
273
|
+
'phase' => value.data[:moon_phase]
|
274
|
+
}
|
275
|
+
else
|
276
|
+
{
|
277
|
+
'high' => value.data[:high],
|
278
|
+
'low' => value.data[:low],
|
279
|
+
'condition' => value.data[:condition],
|
280
|
+
'moon_phase' => value.data[:moon_phase]
|
281
|
+
}
|
272
282
|
end
|
273
283
|
else
|
274
284
|
value
|
data/lib/journal-cli/question.rb
CHANGED
@@ -41,7 +41,7 @@ module Journal
|
|
41
41
|
when /^(text|string|line)/i
|
42
42
|
read_line
|
43
43
|
when /^(weather|forecast)/i
|
44
|
-
Weather.new(Journal.config['weather_api'], Journal.config['zip'])
|
44
|
+
Weather.new(Journal.config['weather_api'], Journal.config['zip'], Journal.config['temp_in'])
|
45
45
|
when /^multi/i
|
46
46
|
read_lines
|
47
47
|
when /^(date|time)/i
|
data/lib/journal-cli/version.rb
CHANGED
data/lib/journal-cli/weather.rb
CHANGED
@@ -4,35 +4,52 @@ module Journal
|
|
4
4
|
class Weather
|
5
5
|
attr_reader :data
|
6
6
|
|
7
|
-
def initialize(api, zip)
|
8
|
-
|
7
|
+
def initialize(api, zip, temp_in)
|
8
|
+
Journal.date.localtime
|
9
|
+
if Journal.date.strftime('%Y-%m-%d') == Time.now.strftime('%Y-%m-%d')
|
10
|
+
res = `curl -SsL 'http://api.weatherapi.com/v1/forecast.json?key=#{api}&q=#{zip}&aqi=no'`
|
11
|
+
else
|
12
|
+
res = `curl -SsL 'http://api.weatherapi.com/v1/history.json?key=#{api}&q=#{zip}&aqi=no&dt=#{Journal.date.strftime('%Y-%m-%d')}'`
|
13
|
+
end
|
14
|
+
|
9
15
|
data = JSON.parse(res)
|
10
16
|
|
11
17
|
raise StandardError, 'invalid JSON response' if data.nil?
|
12
18
|
|
13
|
-
raise StandardError, '
|
19
|
+
raise StandardError, 'mising forecast' unless data['forecast']
|
20
|
+
|
21
|
+
temp_key = temp_in =~ /^c/ ? 'temp_c' : 'temp_f'
|
14
22
|
|
15
|
-
|
16
|
-
|
23
|
+
if Journal.date.strftime('%Y-%m-%d') == Time.now.strftime('%Y-%m-%d')
|
24
|
+
raise StandardError, 'missing conditions' unless data['current']
|
17
25
|
|
18
|
-
|
26
|
+
curr_temp = data['current'][temp_key]
|
27
|
+
curr_condition = data['current']['condition']['text']
|
28
|
+
else
|
29
|
+
time = Journal.date.strftime('%Y-%m-%d %H:00')
|
30
|
+
hour = data['forecast']['forecastday'][0]['hour'].filter { |h| h['time'].to_s =~ /#{time}/ }.first
|
31
|
+
curr_temp = hour[temp_key]
|
32
|
+
curr_condition = hour['condition']['text']
|
33
|
+
end
|
19
34
|
|
20
35
|
forecast = data['forecast']['forecastday'][0]
|
21
36
|
|
37
|
+
moon_phase = forecast['astro']['moon_phase']
|
38
|
+
|
22
39
|
day = forecast['date']
|
23
|
-
high = forecast['day']['maxtemp_f']
|
24
|
-
low = forecast['day']['mintemp_f']
|
40
|
+
high = temp_in =~ /^c/ ? forecast['day']['maxtemp_c'] : forecast['day']['maxtemp_f']
|
41
|
+
low = temp_in =~ /^c/ ? forecast['day']['mintemp_c'] : forecast['day']['mintemp_f']
|
25
42
|
condition = forecast['day']['condition']['text']
|
26
43
|
|
27
44
|
hours = forecast['hour']
|
28
45
|
temps = [
|
29
|
-
{ temp: hours[8][
|
30
|
-
{ temp: hours[10][
|
31
|
-
{ temp: hours[12][
|
32
|
-
{ temp: hours[14][
|
33
|
-
{ temp: hours[16][
|
34
|
-
{ temp: hours[18][
|
35
|
-
{ temp: hours[19][
|
46
|
+
{ temp: hours[8][temp_key], condition: hours[8]['condition']['text'] },
|
47
|
+
{ temp: hours[10][temp_key], condition: hours[10]['condition']['text'] },
|
48
|
+
{ temp: hours[12][temp_key], condition: hours[12]['condition']['text'] },
|
49
|
+
{ temp: hours[14][temp_key], condition: hours[14]['condition']['text'] },
|
50
|
+
{ temp: hours[16][temp_key], condition: hours[16]['condition']['text'] },
|
51
|
+
{ temp: hours[18][temp_key], condition: hours[18]['condition']['text'] },
|
52
|
+
{ temp: hours[19][temp_key], condition: hours[20]['condition']['text'] }
|
36
53
|
]
|
37
54
|
|
38
55
|
@data = {
|
@@ -42,18 +59,24 @@ module Journal
|
|
42
59
|
temp: curr_temp,
|
43
60
|
condition: condition,
|
44
61
|
current_condition: curr_condition,
|
45
|
-
temps: temps
|
62
|
+
temps: temps,
|
63
|
+
moon_phase: moon_phase
|
46
64
|
}
|
47
65
|
end
|
48
66
|
|
49
67
|
def to_data
|
50
68
|
{
|
51
|
-
high: high,
|
52
|
-
low: low,
|
53
|
-
condition:
|
69
|
+
high: @data[:high],
|
70
|
+
low: @data[:low],
|
71
|
+
condition: @data[:current_condition],
|
72
|
+
moon_phase: @data[:moon_phase]
|
54
73
|
}
|
55
74
|
end
|
56
75
|
|
76
|
+
def moon
|
77
|
+
@data[:moon_phase]
|
78
|
+
end
|
79
|
+
|
57
80
|
def current
|
58
81
|
"#{@data[:temp]} and #{@data[:current_condition]}"
|
59
82
|
end
|
@@ -70,7 +93,8 @@ module Journal
|
|
70
93
|
output = []
|
71
94
|
|
72
95
|
output << "Forecast for #{@data[:day]}: #{forecast} "
|
73
|
-
output << "Currently: #{current}"
|
96
|
+
output << "Currently: #{current} "
|
97
|
+
output << "Moon Phase: #{moon} "
|
74
98
|
output << ''
|
75
99
|
|
76
100
|
# Hours
|
data/src/_README.md
CHANGED
@@ -59,6 +59,8 @@ If a question type is set to `weather.forecast`, only the predicted condition, h
|
|
59
59
|
|
60
60
|
If the question type is `weather.current`, only the current condition and temperature will be recorded to the JSON, and a string containing "[TEMP] and [CONDITION]" (e.g. "64 and Sunny") will be recorded to Markdown/Day One for the question.
|
61
61
|
|
62
|
+
If the question type is `weather.moon`, only the moon phase will be output. Moon phase is also included in `weather.forecast` JSON and Markdown output.
|
63
|
+
|
62
64
|
### Journal Configuration
|
63
65
|
|
64
66
|
Edit the file at `~/.config/journal/journals.yaml` following this structure:
|
@@ -151,8 +153,9 @@ A question `type` can be one of:
|
|
151
153
|
- `text` or `string` will request a single-line string, submitted on return
|
152
154
|
- `multiline` for multiline strings (opens a readline editor, use ctrl-d to save)
|
153
155
|
- `weather` will just insert current weather data with no prompt
|
154
|
-
* `weather.forecast` will insert just the forecast
|
155
|
-
* `weather.current` will insert just the current temperature and condition
|
156
|
+
* `weather.forecast` will insert just the forecast (using weather history for backdated entries)
|
157
|
+
* `weather.current` will insert just the current temperature and condition (using weather history for backdated entries)
|
158
|
+
* `weather.moon` will insert the current moon phase for the entry date
|
156
159
|
- `number` or `float` will request numeric input, stored as a float (decimal)
|
157
160
|
- `integer` will convert numeric input to the nearest integer
|
158
161
|
- `date` will request a natural language date which will be parsed into a date object
|
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.
|
4
|
+
version: 1.0.29
|
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-
|
11
|
+
date: 2023-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-which
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- bin/journal
|
233
233
|
- journal-cli.gemspec
|
234
234
|
- lib/journal-cli.rb
|
235
|
+
- lib/journal-cli/array.rb
|
235
236
|
- lib/journal-cli/checkin.rb
|
236
237
|
- lib/journal-cli/color.rb
|
237
238
|
- lib/journal-cli/data.rb
|