journal-cli 1.0.31 → 1.0.32

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: 68a0dd23d0f640b801ed95ed73796cff7e54445483b95354f3796e64506f2956
4
- data.tar.gz: b04e60b7a84fad7d12e674360b2019ff4688ff3b3946c55cf94029d6e770c080
3
+ metadata.gz: 1c2d45dac4f94f75b5c5cdebd74d5ec1cefa29af7fc56e09ef3682108bc30b62
4
+ data.tar.gz: ffcf5ca90e17ebd61b04ea5850bc6a55055af61c8611f7310d8b2abbc2606ed8
5
5
  SHA512:
6
- metadata.gz: 9c9fe623367f3d587ba54526faa9512e1ee22226b7075e270b84985321d8ecad7379da1b511516dd0fb6c1649fc73da1ae833297443607dbfa9e50d721608882
7
- data.tar.gz: 1e3521cd6b7aa7834afad83f61bb4df0756c105a2739d35f000bb9cba1eeb9ace56567e765857a180c36be4ce6ee8420d6b61cc397f899c777fe18e62d271888
6
+ metadata.gz: 3cdd789e27c5c0717bd64d131959a19e3b1a4ec3e89868f44605d75408ab0a92f5c5a77eca11d861c77d16aef1481d50c09aea4db4fefbe535eef86dda7823a3
7
+ data.tar.gz: '0063039da7e7a33283169dd1f18fa268859d8ce2f9250b9314341e114952c45ae3575472a5c82155115d7f9624322c6f7e739363d460f21e22c4cf23584fa16d'
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 1.0.32
2
+
3
+ 2024-04-20 13:43
4
+
5
+ #### IMPROVED
6
+
7
+ - Added note to README that zip codes with leading zero must be quoted
8
+
9
+ #### FIXED
10
+
11
+ - Spelling error in weather exception
12
+
1
13
  ### 1.0.31
2
14
 
3
15
  2023-12-14 09:12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- journal-cli (1.0.31)
4
+ journal-cli (1.0.32)
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
@@ -35,22 +35,6 @@ If you want to use Day One with Journal, you'll need to [install the Day One CLI
35
35
  $ sudo bash /Applications/Day\ One.app/Contents/Resources/install_cli.sh
36
36
  ```
37
37
 
38
- ## Usage
39
-
40
- ```
41
- Usage: journal JOURNAL_KEY [NATURAL LANGUAGE DATE]
42
- -v, --version Display version
43
- -l, --list List available journals
44
- --[no-]color Colorize output
45
- -h, --help Display help
46
-
47
- Available journal types:
48
- - checkin
49
- - mood
50
- - daily
51
- - test
52
- ```
53
-
54
38
  ## Configuration
55
39
 
56
40
  A config must be created at `~/.config/journal/journals.yaml`:
@@ -68,9 +52,13 @@ This file contains a YAML definition of your journal. Each journal gets a top-le
68
52
 
69
53
  You can include weather data automatically by setting a question type to 'weather'. In order for this to work, you'll need to define `zip` and `weather_api` keys. `zip` is just your zip code, and `weather_api` is a key from WeatherAPI.com. Sign up [here](https://www.weatherapi.com/) for a free plan, and then visit the [profile page](https://www.weatherapi.com/my/) to see your API key at the top.
70
54
 
55
+ > Zip codes beginning with zero (0) must be quoted. Use:
56
+ >
57
+ > zip: '01001'
58
+
71
59
  You can optionally set the key `temp_in:` to `f` or `c` to control what scale is used for temperatures.
72
60
 
73
- If a question type is set to `weather.forecast`, only the predicted condition, high, and low will be included in the JSON data for the question. A full printout of hourly temps will be included in the Markdown/Day One output.
61
+ If a question type is set to `weather.forecast`, the moon phase and predicted condition, high, and low will be included in the JSON data for the question. A full printout of hourly temps will be included in the Markdown/Day One output.
74
62
 
75
63
  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.
76
64
 
data/Rakefile CHANGED
@@ -1,19 +1,19 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rdoc/task'
4
- require 'standard/rake'
5
- require 'yard'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rdoc/task"
4
+ require "standard/rake"
5
+ require "yard"
6
6
 
7
7
  Rake::RDocTask.new do |rd|
8
8
  rd.main = "README.rdoc"
9
9
  rd.rdoc_files.include("README.rdoc", "lib/**/*.rb", "bin/**/*")
10
- rd.title = 'Journal'
10
+ rd.title = "Journal"
11
11
  end
12
12
 
13
13
  YARD::Rake::YardocTask.new do |t|
14
- t.files = ['lib/journal-cli/*.rb']
15
- t.options = ['--markup-provider=redcarpet', '--markup=markdown', '--no-private', '-p', 'yard_templates']
16
- # t.stats_options = ['--list-undoc']
14
+ t.files = ["lib/journal-cli/*.rb"]
15
+ t.options = ["--markup-provider=redcarpet", "--markup=markdown", "--no-private", "-p", "yard_templates"]
16
+ # t.stats_options = ['--list-undoc']
17
17
  end
18
18
 
19
19
  RSpec::Core::RakeTask.new(:spec) do |t|
@@ -22,8 +22,8 @@ end
22
22
 
23
23
  task default: %i[test]
24
24
 
25
- desc 'Alias for build'
26
- task :package => :build
25
+ desc "Alias for build"
26
+ task package: :build
27
27
 
28
28
  task test: "spec"
29
29
  task lint: "standard"
@@ -38,10 +38,10 @@ task :console do
38
38
  IRB.start
39
39
  end
40
40
 
41
- desc 'Development version check'
41
+ desc "Development version check"
42
42
  task :ver do
43
43
  gver = `git ver`
44
- cver = IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
44
+ cver = IO.read(File.join(File.dirname(__FILE__), "CHANGELOG.md")).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
45
45
  res = `grep VERSION lib/journal-cli/version.rb`
46
46
  version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
47
47
  puts "git tag: #{gver}"
@@ -49,22 +49,22 @@ task :ver do
49
49
  puts "changelog: #{cver}"
50
50
  end
51
51
 
52
- desc 'Changelog version check'
52
+ desc "Changelog version check"
53
53
  task :cver do
54
- puts IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
54
+ puts IO.read(File.join(File.dirname(__FILE__), "CHANGELOG.md")).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
55
55
  end
56
56
 
57
- desc 'Bump incremental version number'
57
+ desc "Bump incremental version number"
58
58
  task :bump, :type do |_, args|
59
- args.with_defaults(type: 'inc')
60
- version_file = 'lib/journal-cli/version.rb'
59
+ args.with_defaults(type: "inc")
60
+ version_file = "lib/journal-cli/version.rb"
61
61
  content = IO.read(version_file)
62
62
  content.sub!(/VERSION = '(?<major>\d+)\.(?<minor>\d+)\.(?<inc>\d+)(?<pre>\S+)?'/) do
63
63
  m = Regexp.last_match
64
- major = m['major'].to_i
65
- minor = m['minor'].to_i
66
- inc = m['inc'].to_i
67
- pre = m['pre']
64
+ major = m["major"].to_i
65
+ minor = m["minor"].to_i
66
+ inc = m["inc"].to_i
67
+ pre = m["pre"]
68
68
 
69
69
  case args[:type]
70
70
  when /^maj/
@@ -81,5 +81,5 @@ task :bump, :type do |_, args|
81
81
  $stdout.puts "At version #{major}.#{minor}.#{inc}#{pre}"
82
82
  "VERSION = '#{major}.#{minor}.#{inc}#{pre}'"
83
83
  end
84
- File.open(version_file, 'w+') { |f| f.puts content }
84
+ File.open(version_file, "w+") { |f| f.puts content }
85
85
  end
data/journal-cli.gemspec CHANGED
@@ -20,24 +20,24 @@ Gem::Specification.new do |spec|
20
20
  spec.metadata["changelog_uri"] = "#{spec.metadata["source_code_uri"]}/blob/main/CHANGELOG.md"
21
21
  spec.metadata["github_repo"] = "git@github.com:ttscoff/journal-cli.git"
22
22
 
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  end
26
- spec.bindir = 'bin'
27
- spec.executables << 'journal'
26
+ spec.bindir = "bin"
27
+ spec.executables << "journal"
28
28
  spec.require_paths << "lib"
29
29
 
30
- spec.add_runtime_dependency('tty-which', '~> 0.5', '>= 0.5.0')
31
- spec.add_runtime_dependency('tty-reader', '~> 0.9', '>= 0.9.0')
30
+ spec.add_runtime_dependency("tty-which", "~> 0.5", ">= 0.5.0")
31
+ spec.add_runtime_dependency("tty-reader", "~> 0.9", ">= 0.9.0")
32
32
  spec.add_development_dependency "bundler", "~> 2.0"
33
33
  spec.add_development_dependency "gem-release", "~> 2.2"
34
34
  spec.add_development_dependency "parse_gemspec-cli", "~> 1.0"
35
35
  spec.add_development_dependency "rake", "~> 13.0"
36
- spec.add_development_dependency('yard', '~> 0.9', '>= 0.9.26')
36
+ spec.add_development_dependency("yard", "~> 0.9", ">= 0.9.26")
37
37
  spec.add_development_dependency "rspec", "~> 3.0"
38
38
  spec.add_development_dependency "simplecov", "~> 0.21"
39
39
  spec.add_development_dependency "simplecov-console", "~> 0.9"
40
40
  spec.add_development_dependency "standard", "~> 1.3"
41
41
 
42
- spec.add_runtime_dependency('chronic', '~> 0.10', '>= 0.10.2')
42
+ spec.add_runtime_dependency("chronic", "~> 0.10", ">= 0.10.2")
43
43
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  class ::Array
4
4
  def shortest
5
- inject { |memo, word| memo.length < word.length ? memo : word }
5
+ inject { |memo, word| (memo.length < word.length) ? memo : word }
6
6
  end
7
7
 
8
8
  def longest
9
- inject { |memo, word| memo.length > word.length ? memo : word }
9
+ inject { |memo, word| (memo.length > word.length) ? memo : word }
10
10
  end
11
11
  end
@@ -9,17 +9,17 @@ module Journal
9
9
  @date = Journal.date
10
10
  @date.localtime
11
11
 
12
- raise StandardError, "No journal with key #{@key} found" unless Journal.config['journals'].key? @key
12
+ raise StandardError, "No journal with key #{@key} found" unless Journal.config["journals"].key? @key
13
13
 
14
- @journal = Journal.config['journals'][@key]
15
- @sections = Sections.new(@journal['sections'])
14
+ @journal = Journal.config["journals"][@key]
15
+ @sections = Sections.new(@journal["sections"])
16
16
 
17
17
  @data = {}
18
- meridian = @date.hour < 13 ? 'AM' : 'PM'
19
- @title = @journal['title'].sub(/%M/, meridian)
18
+ meridian = (@date.hour < 13) ? "AM" : "PM"
19
+ @title = @journal["title"].sub(/%M/, meridian)
20
20
  end
21
21
 
22
- def title(string)
22
+ def add_title(string)
23
23
  @output << "\n## #{string}\n" unless string.nil?
24
24
  end
25
25
 
@@ -43,11 +43,11 @@ module Journal
43
43
  @sections.each { |key, section| @data[key] = section }
44
44
 
45
45
  save_data
46
- save_day_one_entry if @journal['dayone']
46
+ save_day_one_entry if @journal["dayone"]
47
47
 
48
- return unless @journal['markdown']
48
+ return unless @journal["markdown"]
49
49
 
50
- case @journal['markdown']
50
+ case @journal["markdown"]
51
51
  when /^da(y|ily)/
52
52
  save_daily_markdown
53
53
  when /^(ind|sep)/
@@ -58,35 +58,35 @@ module Journal
58
58
  end
59
59
 
60
60
  def save_day_one_entry
61
- unless TTY::Which.exist?('dayone2')
62
- Journal.notify('{br}Day One CLI not installed, no Day One entry created')
61
+ unless TTY::Which.exist?("dayone2")
62
+ Journal.notify("{br}Day One CLI not installed, no Day One entry created")
63
63
  return
64
64
  end
65
65
  @date.localtime
66
- cmd = ['dayone2']
67
- cmd << %(-j "#{@journal['journal']}") if @journal.key?('journal')
68
- cmd << %(-t #{@journal['tags'].join(' ')}) if @journal.key?('tags')
69
- cmd << %(-date "#{@date.strftime('%Y-%m-%d %I:%M %p')}")
70
- `echo #{Shellwords.escape(to_markdown(yaml: false, title: true))} | #{cmd.join(' ')} -- new`
71
- Journal.notify('{bg}Entered one entry into Day One')
66
+ cmd = ["dayone2"]
67
+ cmd << %(-j "#{@journal["journal"]}") if @journal.key?("journal")
68
+ cmd << %(-t #{@journal["tags"].join(" ")}) if @journal.key?("tags")
69
+ cmd << %(-date "#{@date.strftime("%Y-%m-%d %I:%M %p")}")
70
+ `echo #{Shellwords.escape(to_markdown(yaml: false, title: true))} | #{cmd.join(" ")} -- new`
71
+ Journal.notify("{bg}Entered one entry into Day One")
72
72
  end
73
73
 
74
74
  def save_single_markdown
75
- dir = if @journal.key?('entries_folder')
76
- File.join(File.expand_path(@journal['entries_folder']), 'entries')
77
- elsif Journal.config.key?('entries_folder')
78
- File.join(File.expand_path(Journal.config['entries_folder']), @key)
79
- else
80
- File.expand_path("~/.local/share/journal/#{@key}/entries")
81
- end
75
+ dir = if @journal.key?("entries_folder")
76
+ File.join(File.expand_path(@journal["entries_folder"]), "entries")
77
+ elsif Journal.config.key?("entries_folder")
78
+ File.join(File.expand_path(Journal.config["entries_folder"]), @key)
79
+ else
80
+ File.expand_path("~/.local/share/journal/#{@key}/entries")
81
+ end
82
82
 
83
83
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
84
84
  filename = "#{@key}.md"
85
85
  @date.localtime
86
86
  target = File.join(dir, filename)
87
- File.open(target, 'a') do |f|
87
+ File.open(target, "a") do |f|
88
88
  f.puts
89
- f.puts "## #{@title} #{@date.strftime('%x %X')}"
89
+ f.puts "## #{@title} #{@date.strftime("%x %X")}"
90
90
  f.puts
91
91
  f.puts to_markdown(yaml: false, title: false)
92
92
  end
@@ -94,41 +94,41 @@ module Journal
94
94
  end
95
95
 
96
96
  def save_daily_markdown
97
- dir = if @journal.key?('entries_folder')
98
- File.join(File.expand_path(@journal['entries_folder']), 'entries')
99
- elsif Journal.config.key?('entries_folder')
100
- File.join(File.expand_path(Journal.config['entries_folder']), @key)
101
- else
102
- File.join(File.expand_path("~/.local/share/journal/#{@key}/entries"))
103
- end
97
+ dir = if @journal.key?("entries_folder")
98
+ File.join(File.expand_path(@journal["entries_folder"]), "entries")
99
+ elsif Journal.config.key?("entries_folder")
100
+ File.join(File.expand_path(Journal.config["entries_folder"]), @key)
101
+ else
102
+ File.join(File.expand_path("~/.local/share/journal/#{@key}/entries"))
103
+ end
104
104
 
105
105
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
106
106
  @date.localtime
107
- filename = "#{@key}_#{@date.strftime('%Y-%m-%d')}.md"
107
+ filename = "#{@key}_#{@date.strftime("%Y-%m-%d")}.md"
108
108
  target = File.join(dir, filename)
109
109
  if File.exist? target
110
- File.open(target, 'a') { |f| f.puts to_markdown(yaml: false, title: true, date: false, time: true) }
110
+ File.open(target, "a") { |f| f.puts to_markdown(yaml: false, title: true, date: false, time: true) }
111
111
  else
112
- File.open(target, 'w') { |f| f.puts to_markdown(yaml: true, title: true, date: false, time: true) }
112
+ File.open(target, "w") { |f| f.puts to_markdown(yaml: true, title: true, date: false, time: true) }
113
113
  end
114
114
  Journal.notify "{bg}Saved daily Markdown to {bw}#{target}"
115
115
  end
116
116
 
117
117
  def save_individual_markdown
118
- dir = if @journal.key?('entries_folder')
119
- File.join(File.expand_path(@journal['entries_folder']), 'entries')
120
- elsif Journal.config.key?('entries_folder')
121
- File.join(File.expand_path(Journal.config['entries_folder']), @key,
122
- 'entries')
123
- else
124
- File.join(File.expand_path('~/.local/share/journal'), @key, 'entries')
125
- end
118
+ dir = if @journal.key?("entries_folder")
119
+ File.join(File.expand_path(@journal["entries_folder"]), "entries")
120
+ elsif Journal.config.key?("entries_folder")
121
+ File.join(File.expand_path(Journal.config["entries_folder"]), @key,
122
+ "entries")
123
+ else
124
+ File.join(File.expand_path("~/.local/share/journal"), @key, "entries")
125
+ end
126
126
 
127
127
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
128
128
  @date.localtime
129
- filename = @date.strftime('%Y-%m-%d_%H%M.md')
129
+ filename = @date.strftime("%Y-%m-%d_%H%M.md")
130
130
  target = File.join(dir, filename)
131
- File.open(target, 'w') { |f| f.puts to_markdown(yaml: true, title: true) }
131
+ File.open(target, "w") { |f| f.puts to_markdown(yaml: true, title: true) }
132
132
  puts "Saved new entry to #{target}"
133
133
  end
134
134
 
@@ -139,17 +139,17 @@ module Journal
139
139
  when /^(weather|forecast|moon)/
140
140
  header prompt
141
141
  @output << case type
142
- when /current$/
143
- data[key].current
144
- when /moon$/
145
- "Moon phase: #{data[key].moon}"
146
- else
147
- data[key].to_markdown
148
- end
142
+ when /current$/
143
+ data[key].current
144
+ when /moon$/
145
+ "Moon phase: #{data[key].moon}"
146
+ else
147
+ data[key].to_markdown
148
+ end
149
149
  when /^(int|num)/
150
150
  @output << "#{prompt}: #{data[key]} " unless data[key].nil?
151
151
  when /^date/
152
- @output << "#{prompt}: #{data[key].strftime('%Y-%m-%d %H:%M')}" unless data[key].nil?
152
+ @output << "#{prompt}: #{data[key].strftime("%Y-%m-%d %H:%M")}" unless data[key].nil?
153
153
  else
154
154
  unless data[key].strip.empty?
155
155
  header prompt
@@ -169,18 +169,18 @@ module Journal
169
169
  data[k] = weather_to_yaml(v)
170
170
  when /Date/
171
171
  v.localtime
172
- data[k] = v.strftime('%Y-%m-%d %H:%M')
172
+ data[k] = v.strftime("%Y-%m-%d %H:%M")
173
173
  when /Weather/
174
174
  data[k] = case k
175
- when /current$/
176
- v.current
177
- when /forecast$/
178
- data[k] = v.forecast
179
- when /moon(_?phase)?$/
180
- data[k] = v.moon
181
- else
182
- data[k] = v.to_s
183
- end
175
+ when /current$/
176
+ v.current
177
+ when /forecast$/
178
+ data[k] = v.forecast
179
+ when /moon(_?phase)?$/
180
+ data[k] = v.moon
181
+ else
182
+ data[k] = v.to_s
183
+ end
184
184
  else
185
185
  data[k] = v
186
186
  end
@@ -193,34 +193,33 @@ module Journal
193
193
 
194
194
  if yaml
195
195
  @date.localtime
196
- yaml_data = { 'title' => @title, 'date' => @date.strftime('%x %X')}
196
+ yaml_data = {"title" => @title, "date" => @date.strftime("%x %X")}
197
197
  @data.each do |key, data|
198
198
  yaml_data = yaml_data.merge(weather_to_yaml(data.answers))
199
199
  end
200
200
 
201
201
  @output << YAML.dump(yaml_data).strip
202
- @output << '---'
202
+ @output << "---"
203
203
  end
204
204
 
205
205
  if title
206
206
  if date || time
207
- fmt = ''
208
- fmt += '%x' if date
209
- fmt += '%X' if time
210
- title "#{@title} #{@date.strftime(fmt)}"
207
+ fmt = ""
208
+ fmt += "%x" if date
209
+ fmt += "%X" if time
210
+ add_title "#{@title} #{@date.strftime(fmt)}"
211
211
  else
212
- title @title
212
+ add_title @title
213
213
  end
214
214
  end
215
215
 
216
216
  @sections.each do |key, section|
217
- answers = section.answers
218
217
  section section.title
219
218
 
220
219
  section.questions.each do |question|
221
- if question.key =~ /\./
220
+ if /\./.match?(question.key)
222
221
  res = section.answers.dup
223
- keys = question.key.split(/\./)
222
+ keys = question.key.split(".")
224
223
  keys.each_with_index do |key, i|
225
224
  next if i == keys.count - 1
226
225
 
@@ -238,20 +237,20 @@ module Journal
238
237
 
239
238
  def save_data
240
239
  @date.localtime
241
- dir = if @journal.key?('entries_folder')
242
- File.expand_path(@journal['entries_folder'])
243
- elsif Journal.config.key?('entries_folder')
244
- File.expand_path(Journal.config['entries_folder'])
245
- else
246
- File.expand_path('~/.local/share/journal')
247
- end
240
+ dir = if @journal.key?("entries_folder")
241
+ File.expand_path(@journal["entries_folder"])
242
+ elsif Journal.config.key?("entries_folder")
243
+ File.expand_path(Journal.config["entries_folder"])
244
+ else
245
+ File.expand_path("~/.local/share/journal")
246
+ end
248
247
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
249
248
  db = File.join(dir, "#{@key}.json")
250
249
  data = if File.exist?(db)
251
- JSON.parse(IO.read(db))
252
- else
253
- []
254
- end
250
+ JSON.parse(IO.read(db))
251
+ else
252
+ []
253
+ end
255
254
  date = @date.utc
256
255
  output = {}
257
256
 
@@ -261,28 +260,28 @@ module Journal
261
260
  if v.is_a? Hash
262
261
  v.each do |key, value|
263
262
  result = case value.class.to_s
264
- when /Weather/
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
- }
282
- end
283
- else
284
- value
285
- end
263
+ when /Weather/
264
+ case key
265
+ when /current$/
266
+ {
267
+ "temp" => value.data[:temp],
268
+ "condition" => value.data[:current_condition]
269
+ }
270
+ when /moon(_?phase)?$/
271
+ {
272
+ "phase" => value.data[:moon_phase]
273
+ }
274
+ else
275
+ {
276
+ "high" => value.data[:high],
277
+ "low" => value.data[:low],
278
+ "condition" => value.data[:condition],
279
+ "moon_phase" => value.data[:moon_phase]
280
+ }
281
+ end
282
+ else
283
+ value
284
+ end
286
285
  if jk == k
287
286
  output[jk][key] = result
288
287
  else
@@ -297,17 +296,17 @@ module Journal
297
296
  end
298
297
  end
299
298
  end
300
- data << { 'date' => date, 'data' => output }
299
+ data << {"date" => date, "data" => output}
301
300
  data.map! do |d|
302
301
  {
303
- 'date' => d['date'].is_a?(String) ? Time.parse(d['date']) : d['date'],
304
- 'data' => d['data']
302
+ "date" => d["date"].is_a?(String) ? Time.parse(d["date"]) : d["date"],
303
+ "data" => d["data"]
305
304
  }
306
305
  end
307
306
 
308
- data.sort_by! { |e| e['date'] }
307
+ data.sort_by! { |e| e["date"] }
309
308
 
310
- File.open(db, 'w') { |f| f.puts JSON.pretty_generate(data) }
309
+ File.open(db, "w") { |f| f.puts JSON.pretty_generate(data) }
311
310
  Journal.notify "{bg}Saved {bw}#{db}"
312
311
  end
313
312
  end