journal-cli 1.0.28 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 125cde5de56092483eb664d0b34ee250fdd8d0f47681f2bcd9e47866b9493cf1
4
- data.tar.gz: 99eb86fa5648dbca59ca0337e30324e6fbbab01ff4daeeca5e4421647e273fc6
3
+ metadata.gz: e8f83764338d653909b55685394ab55398913f1dfdf5a529bfe2d7e94857c586
4
+ data.tar.gz: c068e0799c4438f45aad8ac2e265d42324da686712a85c1709cd491ea1ca476f
5
5
  SHA512:
6
- metadata.gz: c61d83d83236c28af72ada995ed0a06d579f9e1d7b8c9c6d6a694ffc6dadcf19c64f1eabd4ac3073adee75224ff4020980d5b9c1064801297dd6183673858b74
7
- data.tar.gz: 816870f6d23c9648c699c8cdc02c802182486044798a3c1ad36981ccfee4c18d266ca29571ab625679bb1d3f737fc8f17d163f84a5e15c1d3142267192367e79
6
+ metadata.gz: 8f35ef77c9762043790ee535e28a0892f78681f5895bd0db6cdb476e13524a35ccf0d80d31dff201a7307d630fc6f59729c9ba7b83698b7bbb428669cceafb96
7
+ data.tar.gz: 28fbd4e7ec6ac0ee506a8bed4413985a9424d6327025b571843bc0d28d17a17747808d33baa7d31d39d3e1e8b941c32a9dcf9883e5c5659af996261e7dc7f514
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
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
+
1
9
  ### 1.0.28
2
10
 
3
11
  2023-09-30 11:01
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- journal-cli (1.0.28)
4
+ journal-cli (1.0.29)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
7
  tty-which (~> 0.5, >= 0.5.0)
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Journal
4
- VERSION = '1.0.28'
4
+ VERSION = '1.0.29'
5
5
  end
@@ -4,7 +4,7 @@ module Journal
4
4
  class Weather
5
5
  attr_reader :data
6
6
 
7
- def initialize(api, zip)
7
+ def initialize(api, zip, temp_in)
8
8
  Journal.date.localtime
9
9
  if Journal.date.strftime('%Y-%m-%d') == Time.now.strftime('%Y-%m-%d')
10
10
  res = `curl -SsL 'http://api.weatherapi.com/v1/forecast.json?key=#{api}&q=#{zip}&aqi=no'`
@@ -18,15 +18,17 @@ module Journal
18
18
 
19
19
  raise StandardError, 'mising forecast' unless data['forecast']
20
20
 
21
+ temp_key = temp_in =~ /^c/ ? 'temp_c' : 'temp_f'
22
+
21
23
  if Journal.date.strftime('%Y-%m-%d') == Time.now.strftime('%Y-%m-%d')
22
24
  raise StandardError, 'missing conditions' unless data['current']
23
25
 
24
- curr_temp = data['current']['temp_f']
26
+ curr_temp = data['current'][temp_key]
25
27
  curr_condition = data['current']['condition']['text']
26
28
  else
27
29
  time = Journal.date.strftime('%Y-%m-%d %H:00')
28
30
  hour = data['forecast']['forecastday'][0]['hour'].filter { |h| h['time'].to_s =~ /#{time}/ }.first
29
- curr_temp = hour['temp_f']
31
+ curr_temp = hour[temp_key]
30
32
  curr_condition = hour['condition']['text']
31
33
  end
32
34
 
@@ -35,19 +37,19 @@ module Journal
35
37
  moon_phase = forecast['astro']['moon_phase']
36
38
 
37
39
  day = forecast['date']
38
- high = forecast['day']['maxtemp_f']
39
- 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']
40
42
  condition = forecast['day']['condition']['text']
41
43
 
42
44
  hours = forecast['hour']
43
45
  temps = [
44
- { temp: hours[8]['temp_f'], condition: hours[8]['condition']['text'] },
45
- { temp: hours[10]['temp_f'], condition: hours[10]['condition']['text'] },
46
- { temp: hours[12]['temp_f'], condition: hours[12]['condition']['text'] },
47
- { temp: hours[14]['temp_f'], condition: hours[14]['condition']['text'] },
48
- { temp: hours[16]['temp_f'], condition: hours[16]['condition']['text'] },
49
- { temp: hours[18]['temp_f'], condition: hours[18]['condition']['text'] },
50
- { temp: hours[19]['temp_f'], condition: hours[20]['condition']['text'] }
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'] }
51
53
  ]
52
54
 
53
55
  @data = {
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.28
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-09-30 00:00:00.000000000 Z
11
+ date: 2023-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-which