tcelfer 1.0.2 → 1.0.3

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: 293d220299f895bdbab44a5e02b2980f5b87efd959e5435e0e98d4c5cbb5c4e9
4
- data.tar.gz: 708e69da53a4f9e785722bf3dc008e7f3d85ab6db1a38a651ac12e1d77ade616
3
+ metadata.gz: 8227fc882ed45d5d8471ef2c479120893fd53addfbdac84cb7f68781ca4dc3e5
4
+ data.tar.gz: c5e5d6904a03490282022102c99a26783cbcf2b66d5697f821114d09a5b7da54
5
5
  SHA512:
6
- metadata.gz: 7a176142693c530bc287bc001485e32b05d9c0abc5f4fb8e8aa1925306afb7fc7ae54834ece9807c179d27787960e645ed36db29c5a3b8a92cf87318236eb01c
7
- data.tar.gz: 2f8f8201c3ad3fde69578c030f820eb6b16dbbc757afa8cc1bd40acc2fdd5f145560e3e215fcc9c12b78248be678bd2a4b44816fd1c6e378ced49453b8c5b61a
6
+ metadata.gz: fc0eae553e24db09b9f4d5e00fee1005e8dc0b0904d59c92aa1a396591f47df176187b5767b662136356309cc0176062a48eb788a7f25c4b80a494eb98424e2a
7
+ data.tar.gz: e451730865cd0ce1177aa89308d1347317917c4120b13b92d76772489e593d95fe266acbef82c0a43974c82757f97cc0a74e80d1895e5d25c226b2565bcaa0ec
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.3] - 2019-05-21
8
+ ### Added
9
+ - `--yesterday` flag for `tcelfer day`
10
+ - `tcelfer ytd`
11
+ - show all months up through the current one
12
+ - Enable JSON serializer plugin for sequel Day model
13
+
7
14
  ## [1.0.2] - 2019-01-18
8
15
  ### Added
9
16
  - Some action screenshots
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tcelfer (1.0.2)
4
+ tcelfer (1.0.3)
5
5
  anyway_config (~> 1.4)
6
- paint (~> 2.0)
7
- sequel (~> 5.15)
8
- sqlite3 (~> 1.3)
6
+ paint (~> 2.1)
7
+ sequel (~> 5.20)
8
+ sqlite3 (~> 1.4)
9
9
  terminal-table (~> 1.8)
10
10
  thor (~> 0.20)
11
11
  tty-prompt (~> 0.18)
@@ -13,58 +13,56 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- anyway_config (1.4.2)
16
+ anyway_config (1.4.4)
17
17
  ast (2.4.0)
18
18
  coderay (1.1.2)
19
19
  diff-lcs (1.3)
20
- dotenv (2.6.0)
20
+ dotenv (2.7.2)
21
21
  equatable (0.5.0)
22
22
  jaro_winkler (1.5.2)
23
23
  method_source (0.9.2)
24
24
  necromancer (0.4.0)
25
- paint (2.0.3)
26
- parallel (1.12.1)
27
- parser (2.5.3.0)
25
+ paint (2.1.0)
26
+ parallel (1.17.0)
27
+ parser (2.6.3.0)
28
28
  ast (~> 2.4.0)
29
29
  pastel (0.7.2)
30
30
  equatable (~> 0.5.0)
31
31
  tty-color (~> 0.4.0)
32
- powerpack (0.1.2)
33
32
  pry (0.12.2)
34
33
  coderay (~> 1.1.0)
35
34
  method_source (~> 0.9.0)
36
35
  rainbow (3.0.0)
37
- rake (10.5.0)
36
+ rake (12.3.2)
38
37
  rspec (3.8.0)
39
38
  rspec-core (~> 3.8.0)
40
39
  rspec-expectations (~> 3.8.0)
41
40
  rspec-mocks (~> 3.8.0)
42
41
  rspec-core (3.8.0)
43
42
  rspec-support (~> 3.8.0)
44
- rspec-expectations (3.8.2)
43
+ rspec-expectations (3.8.3)
45
44
  diff-lcs (>= 1.2.0, < 2.0)
46
45
  rspec-support (~> 3.8.0)
47
46
  rspec-mocks (3.8.0)
48
47
  diff-lcs (>= 1.2.0, < 2.0)
49
48
  rspec-support (~> 3.8.0)
50
49
  rspec-support (3.8.0)
51
- rubocop (0.62.0)
50
+ rubocop (0.70.0)
52
51
  jaro_winkler (~> 1.5.1)
53
52
  parallel (~> 1.10)
54
- parser (>= 2.5, != 2.5.1.1)
55
- powerpack (~> 0.1)
53
+ parser (>= 2.6)
56
54
  rainbow (>= 2.2.2, < 4.0)
57
55
  ruby-progressbar (~> 1.7)
58
- unicode-display_width (~> 1.4.0)
56
+ unicode-display_width (>= 1.4.0, < 1.7)
59
57
  ruby-progressbar (1.10.0)
60
- sequel (5.16.0)
61
- sqlite3 (1.3.13)
58
+ sequel (5.20.0)
59
+ sqlite3 (1.4.1)
62
60
  terminal-table (1.8.0)
63
61
  unicode-display_width (~> 1.1, >= 1.1.1)
64
62
  thor (0.20.3)
65
- timers (4.2.0)
63
+ timers (4.3.0)
66
64
  tty-color (0.4.3)
67
- tty-cursor (0.6.0)
65
+ tty-cursor (0.6.1)
68
66
  tty-prompt (0.18.1)
69
67
  necromancer (~> 0.4.0)
70
68
  pastel (~> 0.7.0)
@@ -76,7 +74,7 @@ GEM
76
74
  tty-screen (~> 0.6.4)
77
75
  wisper (~> 2.0.0)
78
76
  tty-screen (0.6.5)
79
- unicode-display_width (1.4.1)
77
+ unicode-display_width (1.6.0)
80
78
  wisper (2.0.0)
81
79
 
82
80
  PLATFORMS
@@ -84,11 +82,11 @@ PLATFORMS
84
82
 
85
83
  DEPENDENCIES
86
84
  bundler (~> 2.0)
87
- dotenv (~> 2.5)
85
+ dotenv (~> 2.7)
88
86
  pry (~> 0.12)
89
- rake (~> 10.0)
87
+ rake (~> 12.0)
90
88
  rspec (~> 3.0)
91
- rubocop (~> 0.50)
89
+ rubocop (~> 0.70)
92
90
  tcelfer!
93
91
 
94
92
  BUNDLED WITH
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
data/exe/tcelfer CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
4
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
5
5
  #
6
6
  # This program is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU General Public License as published by
data/lib/tcelfer.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
data/lib/tcelfer/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -40,6 +40,8 @@ module Tcelfer
40
40
 
41
41
  # Set up debug things I guess? This could be messy
42
42
  class_option(:verbose, aliases: %w[-v], type: :boolean, default: false)
43
+ # Legends are useful for more than one command
44
+ class_option(:legend, aliases: %w[-k -l], type: :boolean, default: false)
43
45
 
44
46
  desc 'version', 'Prints the current version'
45
47
  def version
@@ -47,36 +49,57 @@ module Tcelfer
47
49
  end
48
50
 
49
51
  method_option(:date, aliases: %w[-d], desc: 'Any format valid for ruby Date e.g. 2019-10-31', required: false)
52
+ method_option(:yesterday, aliases: %w[-p], desc: 'Record yesterday, ignored if `-d` is present', required: false)
50
53
  desc 'day', 'record info for a day'
51
54
  def day
52
55
  Tcelfer.config.debug = options[:verbose]
53
56
  store = Tcelfer::Storage.new
54
57
  tc_day = rec_day! store
55
58
  @prompt.say("Recorded [#{tc_day.date}]: #{Paint[tc_day.rating, :bold]}")
56
- rescue Tcelfer::Error => err
57
- @prompt.error("[#{err.class}]", err)
59
+ rescue Tcelfer::Error => e
60
+ @prompt.error("[#{e.class}]", e)
58
61
  end
59
62
 
60
63
  method_option(:month, aliases: %w[-m], type: :numeric)
61
- method_option(:legend, aliases: %w[-k -l], type: :boolean, default: false)
62
64
  method_option(:year, aliases: %w[-y], type: :numeric, default: Date.today.year)
63
65
  desc 'report', 'generate a report'
64
66
  def report
65
67
  Tcelfer.config.debug = options[:verbose]
66
68
  rep = Report.new
67
69
  @prompt.say(gen_report(rep, options['month'], options['year'], options['legend']))
68
- rescue Tcelfer::Error => err
69
- @prompt.error("[#{err.class}]", err)
70
+ rescue Tcelfer::Error => e
71
+ @prompt.error("[#{e.class}]", e)
72
+ end
73
+
74
+ desc 'ytd', 'Report on the current calendar year'
75
+ def ytd
76
+ Tcelfer.config.debug = options[:verbose]
77
+ rep = Report.new
78
+ 1.upto(Date.today.mon) do |mon|
79
+ @prompt.say(rep.generate_month_report(mon))
80
+ end
81
+ @prompt.say(Report.legend)
82
+ rescue Tcelfer::Error => e
83
+ @prompt.error("[#{e.class}]", e)
70
84
  end
71
85
 
72
86
  private
73
87
 
88
+ def pick_date!
89
+ if options.key?(:date)
90
+ options[:date]
91
+ elsif options.key?(:yesterday)
92
+ Date.today - 1
93
+ else
94
+ Date.today
95
+ end
96
+ end
97
+
74
98
  # Heavy lifting for `tcelfer day ...`
75
99
  # returns an instance of the Day model representing the users choices.
76
100
  # @return [Tcelfer::Models::Day]
77
101
  def rec_day!(store)
78
- user_date = options.key?('date') ? Date.parse(options['date']) : Date.today
79
-
102
+ user_date = pick_date!
80
103
  rate_prompt_settings = { required: true, filter: true, per_page: DAY_RATINGS.length }
81
104
  rating = @prompt.select('How was your day?', DAY_RATINGS, **rate_prompt_settings)
82
105
  notes = @prompt.ask('Any additional notes?')
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ module Tcelfer
31
31
  # @param [Integer] month
32
32
  # @param [Integer] year
33
33
  # @return [Terminal::Table]
34
- def generate_month_report(month, year)
34
+ def generate_month_report(month, year = Date.today.year)
35
35
  mon_by_wday = @store.by_month(month, year).group_by { |day| day.date.wday }
36
36
  if mon_by_wday.length < 7
37
37
  raise ReportError, "Unable to process #{Date::MONTHNAMES[month]}, please have at least 7 days of data first"
@@ -47,7 +47,7 @@ module Tcelfer
47
47
  # @param [Integer] year
48
48
  # @return [Terminal::Table]
49
49
  def month_with_legend(month, year)
50
- tab = generate_month_report month, year
50
+ tab = generate_month_report(month, year)
51
51
  Terminal::Table.new(rows: [[tab, Report.legend]]).tap do |combined|
52
52
  combined.style = { border_x: '', border_y: '', border_i: '', width: `tput cols`.to_i }
53
53
  combined.headings = ["== #{Date::MONTHNAMES[month]} - #{year} ==", '== Legend ==']
@@ -60,7 +60,7 @@ module Tcelfer
60
60
  leg = Tcelfer::RATING_TO_COLOR_MAP.map do |rating, color|
61
61
  [Paint[' ', :inverse, color], rating]
62
62
  end
63
- Terminal::Table.new(rows: leg, headings: %w[Rating Color].map { |head| Paint[head, :bold] })
63
+ Terminal::Table.new(rows: leg, headings: %w[Color Rating].map { |head| Paint[head, :bold] })
64
64
  end
65
65
 
66
66
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -15,11 +15,13 @@
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  require 'sequel'
18
+ require 'sequel/plugins/json_serializer'
18
19
 
19
20
  module Tcelfer
20
21
  module Models
21
22
  # Day model
22
23
  class Day < Sequel::Model(:days)
24
+ plugin :json_serializer
23
25
  # Pretty format for a Day model
24
26
  # 2019-01-17: Normal, Average Day
25
27
  # @return [String]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -15,5 +15,5 @@
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  module Tcelfer
18
- VERSION = '1.0.2'
18
+ VERSION = '1.0.3'
19
19
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
data/spec/tcelfer_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2018 Anthony Gargiulo <anthony@agargiulo.com>
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcelfer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Gargiulo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-20 00:00:00.000000000 Z
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
33
+ version: '2.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.5'
40
+ version: '2.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.50'
89
+ version: '0.70'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.50'
96
+ version: '0.70'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: anyway_config
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,42 +114,42 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.0'
117
+ version: '2.1'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.0'
124
+ version: '2.1'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: sequel
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '5.15'
131
+ version: '5.20'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '5.15'
138
+ version: '5.20'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: sqlite3
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.3'
145
+ version: '1.4'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.3'
152
+ version: '1.4'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: terminal-table
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  - !ruby/object:Gem::Version
241
241
  version: '0'
242
242
  requirements: []
243
- rubygems_version: 3.0.1
243
+ rubygems_version: 3.0.3
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: Reflect on your day and keep track