tcelfer 1.0.1 → 1.1.0

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: 1dbdbd3521fdede4906fa9d29f1404232ee0e8ed1209fd22e4516e4b6a1e9cae
4
- data.tar.gz: 02f3a40249b1ac13fe3e614819b552255c0d622d05e5fd73dc7464952b464358
3
+ metadata.gz: c1d0ed26a5e8ba09e9d46b56ac3e8de2d6fed32b841ecc2f1d626fef4022442a
4
+ data.tar.gz: 40158175a1053e9bc020ecd7e54309c1a66f21642a1210859a7daef82dee7eda
5
5
  SHA512:
6
- metadata.gz: 2913057c0013914391a57474ed3ed5826f18e0880dd3349e054d1a571980c00b44bd97af24bb4a11eff50c4aa15671b9195a7d60b4a3fcc520d41ffe410d6c81
7
- data.tar.gz: ebbd589c6519393f4484be906ad8b2ddff124fdd0ef235c5f33f6dad618b2ee8bfc4e660bad3686338f355df5025c018628e8b1c7e792fb21acfcbe49cc9dc04
6
+ metadata.gz: d7186510d0d4de360c56d07c46ac6866717f2a46333412f5d8afc0b413adf3dfadc68e7321116d2de91129dc25c91f308175a1249b29f6d087086f72ab4714af
7
+ data.tar.gz: 91c98e0d0f6cdabc58ad71706503a8baffd967c2f9f8de4a019eb34d887cdc77791126731ecbf142458ecfd8e64db6cd8ff5bcc5b33755317e069028639726fb
data/CHANGELOG.md CHANGED
@@ -4,6 +4,49 @@ 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.1.0] - 2021-03-14
8
+ ### Changed
9
+ - Set minimum ruby version to 2.7
10
+ - Set `required_ruby_version` to not include 3.0.0 yet
11
+ - Updated various gem dependencies
12
+ - sequel, paint
13
+ - Updated dev gem deps
14
+ - Moved ci/cd from travis to gitlab
15
+ - rubocop updates
16
+ - rubocop rake and rspec
17
+
18
+ ## [1.0.6] - 2019-09-07
19
+ ### Added
20
+ - Allow publishing to beta GitHub Registry
21
+ ### Changed
22
+ - Updated Ruby teeny versions
23
+
24
+ ## [1.0.5] - 2019-08-12
25
+ ### Fixed
26
+ - errant Dockerfile was being included, no more.
27
+
28
+ ## [1.0.4] - 2019-08-12
29
+ ### Changed
30
+ - new subcommands under `tcelfer db` to replace the `bin/db_init` functionality
31
+ - initdb|migrate: run all or some DB migrations (up or down)
32
+ - path: shows the path of the database (could be made into `tcelfer env` instead maybe?
33
+ - new config option, `:migrations_path`, defaults to `<tcelfer_gem_root>/db/migrations`
34
+ - updated Ruby versions for Travis CI
35
+ - updated several gem dependencies
36
+
37
+ ## [1.0.3] - 2019-05-21
38
+ ### Added
39
+ - `--yesterday` flag for `tcelfer day`
40
+ - `tcelfer ytd`
41
+ - show all months up through the current one
42
+ - Enable JSON serializer plugin for sequel Day model
43
+
44
+ ## [1.0.2] - 2019-01-18
45
+ ### Added
46
+ - Some action screenshots
47
+ ### Fixed
48
+ - Correctly handle the --verbose flag now
49
+
7
50
  ## [1.0.1] - 2019-01-18
8
51
  ### Fixed
9
52
  - Flags for debug and specifying dates for `tcelfer day` collided
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,95 +1,102 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tcelfer (1.0.1)
4
+ tcelfer (1.1.0)
5
5
  anyway_config (~> 1.4)
6
- paint (~> 2.0)
7
- sequel (~> 5.15)
8
- sqlite3 (~> 1.3)
6
+ paint (~> 2.2)
7
+ sequel (~> 5.41)
8
+ sqlite3 (~> 1.4)
9
9
  terminal-table (~> 1.8)
10
10
  thor (~> 0.20)
11
- tty-prompt (~> 0.18)
11
+ tty-prompt (~> 0.19)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- anyway_config (1.4.2)
17
- ast (2.4.0)
18
- coderay (1.1.2)
19
- diff-lcs (1.3)
20
- dotenv (2.6.0)
21
- equatable (0.5.0)
22
- jaro_winkler (1.5.2)
23
- method_source (0.9.2)
24
- necromancer (0.4.0)
25
- paint (2.0.3)
26
- parallel (1.12.1)
27
- parser (2.5.3.0)
28
- ast (~> 2.4.0)
29
- pastel (0.7.2)
30
- equatable (~> 0.5.0)
31
- tty-color (~> 0.4.0)
32
- powerpack (0.1.2)
33
- pry (0.12.2)
34
- coderay (~> 1.1.0)
35
- method_source (~> 0.9.0)
16
+ anyway_config (1.4.4)
17
+ ast (2.4.2)
18
+ coderay (1.1.3)
19
+ diff-lcs (1.4.4)
20
+ dotenv (2.7.6)
21
+ method_source (1.0.0)
22
+ paint (2.2.1)
23
+ parallel (1.20.1)
24
+ parser (3.0.0.0)
25
+ ast (~> 2.4.1)
26
+ pastel (0.8.0)
27
+ tty-color (~> 0.5)
28
+ pry (0.14.0)
29
+ coderay (~> 1.1)
30
+ method_source (~> 1.0)
36
31
  rainbow (3.0.0)
37
- rake (10.5.0)
38
- rspec (3.8.0)
39
- rspec-core (~> 3.8.0)
40
- rspec-expectations (~> 3.8.0)
41
- rspec-mocks (~> 3.8.0)
42
- rspec-core (3.8.0)
43
- rspec-support (~> 3.8.0)
44
- rspec-expectations (3.8.2)
32
+ rake (13.0.3)
33
+ regexp_parser (2.1.1)
34
+ rexml (3.2.4)
35
+ rspec (3.10.0)
36
+ rspec-core (~> 3.10.0)
37
+ rspec-expectations (~> 3.10.0)
38
+ rspec-mocks (~> 3.10.0)
39
+ rspec-core (3.10.1)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-expectations (3.10.1)
45
42
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.8.0)
47
- rspec-mocks (3.8.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-mocks (3.10.2)
48
45
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-support (3.8.0)
51
- rubocop (0.62.0)
52
- jaro_winkler (~> 1.5.1)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-support (3.10.2)
48
+ rubocop (1.11.0)
53
49
  parallel (~> 1.10)
54
- parser (>= 2.5, != 2.5.1.1)
55
- powerpack (~> 0.1)
50
+ parser (>= 3.0.0.0)
56
51
  rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 1.8, < 3.0)
53
+ rexml
54
+ rubocop-ast (>= 1.2.0, < 2.0)
57
55
  ruby-progressbar (~> 1.7)
58
- unicode-display_width (~> 1.4.0)
59
- ruby-progressbar (1.10.0)
60
- sequel (5.16.0)
61
- sqlite3 (1.3.13)
56
+ unicode-display_width (>= 1.4.0, < 3.0)
57
+ rubocop-ast (1.4.1)
58
+ parser (>= 2.7.1.5)
59
+ rubocop-performance (1.10.1)
60
+ rubocop (>= 0.90.0, < 2.0)
61
+ rubocop-ast (>= 0.4.0)
62
+ rubocop-rake (0.5.1)
63
+ rubocop
64
+ rubocop-rspec (2.2.0)
65
+ rubocop (~> 1.0)
66
+ rubocop-ast (>= 1.1.0)
67
+ ruby-progressbar (1.11.0)
68
+ sequel (5.42.0)
69
+ sqlite3 (1.4.2)
62
70
  terminal-table (1.8.0)
63
71
  unicode-display_width (~> 1.1, >= 1.1.1)
64
72
  thor (0.20.3)
65
- timers (4.2.0)
66
- tty-color (0.4.3)
67
- tty-cursor (0.6.0)
68
- tty-prompt (0.18.1)
69
- necromancer (~> 0.4.0)
70
- pastel (~> 0.7.0)
71
- timers (~> 4.0)
72
- tty-cursor (~> 0.6.0)
73
- tty-reader (~> 0.5.0)
74
- tty-reader (0.5.0)
75
- tty-cursor (~> 0.6.0)
76
- tty-screen (~> 0.6.4)
77
- wisper (~> 2.0.0)
78
- tty-screen (0.6.5)
79
- unicode-display_width (1.4.1)
80
- wisper (2.0.0)
73
+ tty-color (0.6.0)
74
+ tty-cursor (0.7.1)
75
+ tty-prompt (0.23.0)
76
+ pastel (~> 0.8)
77
+ tty-reader (~> 0.8)
78
+ tty-reader (0.9.0)
79
+ tty-cursor (~> 0.7)
80
+ tty-screen (~> 0.8)
81
+ wisper (~> 2.0)
82
+ tty-screen (0.8.1)
83
+ unicode-display_width (1.7.0)
84
+ wisper (2.0.1)
81
85
 
82
86
  PLATFORMS
83
87
  ruby
84
88
 
85
89
  DEPENDENCIES
86
- bundler (~> 2.0)
87
- dotenv (~> 2.5)
88
- pry (~> 0.12)
89
- rake (~> 10.0)
90
- rspec (~> 3.0)
91
- rubocop (~> 0.50)
90
+ bundler (~> 2.1)
91
+ dotenv (~> 2.7)
92
+ pry (~> 0.13)
93
+ rake (~> 13.0)
94
+ rspec (~> 3.9)
95
+ rubocop (~> 1.11)
96
+ rubocop-performance (~> 1.8)
97
+ rubocop-rake (~> 0.5)
98
+ rubocop-rspec (~> 2.2)
92
99
  tcelfer!
93
100
 
94
101
  BUNDLED WITH
95
- 2.0.1
102
+ 2.1.4
data/README.md CHANGED
@@ -3,8 +3,10 @@
3
3
  ### [t]cel-fer:
4
4
  - A fun way to keep track of simple summaries of your months.
5
5
 
6
+ ![generated_report](/images/generated_report.png)
7
+
6
8
  ## Requirements
7
- * Ruby 2.5.0+ (Tested with 2.6.0 mostly)
9
+ * Ruby 2.3.0+ (Tested with 2.6.0 mostly)
8
10
  * Sqlite3
9
11
 
10
12
  ## Installation
@@ -26,13 +28,11 @@ $ gem install tcelfer
26
28
 
27
29
  ## Setup
28
30
  ```bash
29
- # Configure with one of the following:
30
- # Just change the db location
31
- export TCELFER_SQLITE_PATH=path/to/some_file.db
32
- # Or copy `config/tcelfer.example.yml` and use:
31
+ # Example configuration
33
32
  export TCELFER_CONF=~/.config/tcelfer/my_conf.yml
33
+ cp config/tcelfer.example.yml ${TCELFER_CONF}
34
34
  # Initialize the database
35
- $ bin/db_init
35
+ $ tcelfer db init
36
36
  ```
37
37
 
38
38
  ## Usage
@@ -46,6 +46,8 @@ $ tcelfer day [-d 2018-12-31]
46
46
  # Reflect on your month
47
47
  $ tcelfer report [-y|--year=)YEAR] -m|--month=MON [--legend]
48
48
  ```
49
+ ![record_day](/images/record_day.png)
50
+ ![recorded_day](/images/recorded_day.png)
49
51
 
50
52
  ## Development
51
53
 
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
@@ -14,15 +14,21 @@
14
14
  #
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
18
  require 'bundler/gem_tasks'
18
19
  require 'rspec/core/rake_task'
19
20
  require 'rubocop/rake_task'
20
21
 
21
22
  RSpec::Core::RakeTask.new(:spec)
23
+
22
24
  RuboCop::RakeTask.new(:rubocop)
25
+ RuboCop::RakeTask.new(:rubocop_perf) do |task|
26
+ task.requires << 'rubocop-performance'
27
+ end
23
28
 
24
29
  task default: %i[spec rubocop]
25
30
 
31
+ desc 'remove files from tmp/'
26
32
  task :clean do
27
33
  FileUtils.rm_rf(Dir['tmp/*'], verbose: true)
28
34
  end
@@ -0,0 +1,5 @@
1
+ sqlite_path: dev.sqlite.db
2
+ # Can also be set with the cli (-v, --verbose)
3
+ debug: false
4
+ # If you want to edit past days, set to true.
5
+ update_existing: false
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ Sequel.migration do
18
+ up do
19
+ create_table? :days do
20
+ primary_key :id
21
+ Date :date, index: { unique: true }, null: false
22
+ String :rating, null: false
23
+ String :notes
24
+ end
25
+ end
26
+
27
+ down do
28
+ drop_table?(:days)
29
+ end
30
+ end
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
@@ -21,6 +21,7 @@ require 'tty-prompt'
21
21
 
22
22
  require 'tcelfer'
23
23
  require 'tcelfer/cli/report'
24
+ require 'tcelfer/cli/db_tasks'
24
25
 
25
26
  module Tcelfer
26
27
  module CLI
@@ -40,6 +41,8 @@ module Tcelfer
40
41
 
41
42
  # Set up debug things I guess? This could be messy
42
43
  class_option(:verbose, aliases: %w[-v], type: :boolean, default: false)
44
+ # Legends are useful for more than one command
45
+ class_option(:legend, aliases: %w[-k -l], type: :boolean, default: false)
43
46
 
44
47
  desc 'version', 'Prints the current version'
45
48
  def version
@@ -47,36 +50,60 @@ module Tcelfer
47
50
  end
48
51
 
49
52
  method_option(:date, aliases: %w[-d], desc: 'Any format valid for ruby Date e.g. 2019-10-31', required: false)
53
+ method_option(:yesterday, aliases: %w[-p], desc: 'Record yesterday, ignored if `-d` is present', required: false)
50
54
  desc 'day', 'record info for a day'
51
55
  def day
52
- Tcelfer.config.debug = options[:debug]
53
- store = Tcelfer::Storage.new
56
+ Tcelfer.config.debug = options[:verbose]
57
+ store = Tcelfer::Storage.new
54
58
  tc_day = rec_day! store
55
59
  @prompt.say("Recorded [#{tc_day.date}]: #{Paint[tc_day.rating, :bold]}")
56
- rescue Tcelfer::Error => err
57
- @prompt.error("[#{err.class}]", err)
60
+ rescue Tcelfer::Error => e
61
+ @prompt.error("[#{e.class}]", e)
58
62
  end
59
63
 
60
64
  method_option(:month, aliases: %w[-m], type: :numeric)
61
- method_option(:legend, aliases: %w[-k -l], type: :boolean, default: false)
62
65
  method_option(:year, aliases: %w[-y], type: :numeric, default: Date.today.year)
63
66
  desc 'report', 'generate a report'
64
67
  def report
65
- Tcelfer.config.debug = options[:debug]
68
+ Tcelfer.config.debug = options[:verbose]
66
69
  rep = Report.new
67
70
  @prompt.say(gen_report(rep, options['month'], options['year'], options['legend']))
68
- rescue Tcelfer::Error => err
69
- @prompt.error("[#{err.class}]", err)
71
+ rescue Tcelfer::Error => e
72
+ @prompt.error("[#{e.class}]", e)
70
73
  end
71
74
 
75
+ desc 'ytd', 'Report on the current calendar year'
76
+ def ytd
77
+ Tcelfer.config.debug = options[:verbose]
78
+ rep = Report.new
79
+ 1.upto(Date.today.mon) do |mon|
80
+ @prompt.say(rep.generate_month_report(mon))
81
+ end
82
+ @prompt.say(Report.legend)
83
+ rescue Tcelfer::Error => e
84
+ @prompt.error("[#{e.class}]", e)
85
+ end
86
+
87
+ desc 'db', 'Perform various DB related tasks'
88
+ subcommand 'db', DBTasks
89
+
72
90
  private
73
91
 
92
+ def pick_date!
93
+ if options.key?(:date)
94
+ options[:date]
95
+ elsif options.key?(:yesterday)
96
+ Date.today - 1
97
+ else
98
+ Date.today
99
+ end
100
+ end
101
+
74
102
  # Heavy lifting for `tcelfer day ...`
75
103
  # returns an instance of the Day model representing the users choices.
76
104
  # @return [Tcelfer::Models::Day]
77
105
  def rec_day!(store)
78
- user_date = options.key?('date') ? Date.parse(options['date']) : Date.today
79
-
106
+ user_date = pick_date!
80
107
  rate_prompt_settings = { required: true, filter: true, per_page: DAY_RATINGS.length }
81
108
  rating = @prompt.select('How was your day?', DAY_RATINGS, **rate_prompt_settings)
82
109
  notes = @prompt.ask('Any additional notes?')
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2019 Anthony Gargiulo <anthony@agargiulo.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ module Tcelfer
18
+ module CLI
19
+ # Subcommands for various database tasks
20
+ class DBTasks < Thor
21
+ def initialize(*_args)
22
+ # Quit on Ctrl-C please
23
+ @prompt = TTY::Prompt.new(interrupt: :exit)
24
+
25
+ super
26
+ end
27
+
28
+ # Useful return codes are nice, of course
29
+ def self.exit_on_failure?
30
+ true
31
+ end
32
+
33
+ # Used to force migrations, and other destructive actions
34
+ class_option(:force, aliases: %w[-f], type: :boolean, default: false)
35
+ # Set up debug things I guess? This could be messy
36
+ class_option(:verbose, aliases: %w[-v], type: :boolean, default: false)
37
+
38
+ desc 'initdb', 'Initialize the database'
39
+ def initdb
40
+ Tcelfer.config.debug = options[:verbose]
41
+ _db_exists! if File.exist?(Tcelfer.config.sqlite_path) && !options.force
42
+
43
+ _db_migrate!
44
+ rescue Tcelfer::Error => e
45
+ @prompt.error("[#{e.class}]", e)
46
+ end
47
+
48
+ desc 'migrate [--version|-M]', 'Initialize the database'
49
+ method_option(:version, aliases: %w[-M], type: :numeric, required: false)
50
+ def migrate
51
+ Tcelfer.config.debug = options[:verbose]
52
+ _db_migrate!(options.version)
53
+ rescue Tcelfer::Error => e
54
+ @prompt.error("[#{e.class}]", e)
55
+ end
56
+
57
+ desc 'path', 'print the current db path, useful for debugging'
58
+ def path
59
+ @prompt.say(Tcelfer.config.sqlite_path)
60
+ end
61
+
62
+ private
63
+
64
+ # Migrate the DB to a specific version, or latest if none specified
65
+ def _db_migrate!(version = nil)
66
+ require 'sequel/core'
67
+ Sequel.connect("sqlite://#{Tcelfer.config.sqlite_path}") do |db|
68
+ db.loggers << Logger.new($stderr) if Tcelfer.config.debug
69
+ Sequel.extension :migration
70
+ Sequel::Migrator.run(db, Tcelfer.config.migrations_path, target: version)
71
+ end
72
+ end
73
+
74
+ def _db_exists!
75
+ raise CliError, "Database file `#{Tcelfer.config.sqlite_path}' already exists."
76
+ end
77
+ end
78
+ end
79
+ end
@@ -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
@@ -22,14 +22,15 @@ module Tcelfer
22
22
  config_name :tcelfer
23
23
  attr_config(
24
24
  :sqlite_path,
25
- debug: false,
26
- update_existing: false
25
+ debug: false,
26
+ update_existing: false,
27
+ migrations_path: File.expand_path('../../db/migrations', __dir__)
27
28
  )
28
29
 
29
30
  def validate!
30
- raise Tcelfer::StorageError, 'TCELFER_SQLITE_PATH not defined, cannot continue' if sqlite_path.nil?
31
+ return self if sqlite_path
31
32
 
32
- self
33
+ raise Tcelfer::StorageError, 'Please set `sqlite_path` to continue'
33
34
  end
34
35
  end
35
36
  end
@@ -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
@@ -33,4 +33,7 @@ module Tcelfer
33
33
 
34
34
  # Issues with reports
35
35
  class ReportError < Error; end
36
+
37
+ # Issues with the CLI
38
+ class CliError < Error; end
36
39
  end
@@ -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
@@ -59,7 +59,7 @@ module Tcelfer
59
59
  private
60
60
 
61
61
  def validate_db!(db)
62
- raise Tcelfer::StorageError, 'did you forget to run `bin/db_init`?' unless db.tables.include? :days
62
+ raise Tcelfer::StorageError, 'did you forget to run `tcelfer db initdb`?' unless db.tables.include? :days
63
63
  end
64
64
  end
65
65
  end
@@ -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.1'
18
+ VERSION = '1.1.0'
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
@@ -15,10 +15,11 @@
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
  RSpec.describe Tcelfer do
18
- context 'base info' do
19
- before(:all) do
18
+ context 'with base info' do
19
+ before do
20
20
  ENV['TCELFER_SQLITE_PATH'] = ''
21
21
  end
22
+
22
23
  it 'has a version number' do
23
24
  expect(Tcelfer::VERSION).not_to be nil
24
25
  end
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.1
4
+ version: 1.1.0
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-18 00:00:00.000000000 Z
11
+ date: 2021-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,84 +16,126 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dotenv
29
29
  requirement: !ruby/object:Gem::Requirement
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
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.12'
47
+ version: '0.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.12'
54
+ version: '0.13'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '13.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: '13.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '3.9'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '3.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.50'
89
+ version: '1.11'
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: '1.11'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-performance
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.5'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.2'
97
139
  - !ruby/object:Gem::Dependency
98
140
  name: anyway_config
99
141
  requirement: !ruby/object:Gem::Requirement
@@ -114,42 +156,42 @@ dependencies:
114
156
  requirements:
115
157
  - - "~>"
116
158
  - !ruby/object:Gem::Version
117
- version: '2.0'
159
+ version: '2.2'
118
160
  type: :runtime
119
161
  prerelease: false
120
162
  version_requirements: !ruby/object:Gem::Requirement
121
163
  requirements:
122
164
  - - "~>"
123
165
  - !ruby/object:Gem::Version
124
- version: '2.0'
166
+ version: '2.2'
125
167
  - !ruby/object:Gem::Dependency
126
168
  name: sequel
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - "~>"
130
172
  - !ruby/object:Gem::Version
131
- version: '5.15'
173
+ version: '5.41'
132
174
  type: :runtime
133
175
  prerelease: false
134
176
  version_requirements: !ruby/object:Gem::Requirement
135
177
  requirements:
136
178
  - - "~>"
137
179
  - !ruby/object:Gem::Version
138
- version: '5.15'
180
+ version: '5.41'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: sqlite3
141
183
  requirement: !ruby/object:Gem::Requirement
142
184
  requirements:
143
185
  - - "~>"
144
186
  - !ruby/object:Gem::Version
145
- version: '1.3'
187
+ version: '1.4'
146
188
  type: :runtime
147
189
  prerelease: false
148
190
  version_requirements: !ruby/object:Gem::Requirement
149
191
  requirements:
150
192
  - - "~>"
151
193
  - !ruby/object:Gem::Version
152
- version: '1.3'
194
+ version: '1.4'
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: terminal-table
155
197
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +226,14 @@ dependencies:
184
226
  requirements:
185
227
  - - "~>"
186
228
  - !ruby/object:Gem::Version
187
- version: '0.18'
229
+ version: '0.19'
188
230
  type: :runtime
189
231
  prerelease: false
190
232
  version_requirements: !ruby/object:Gem::Requirement
191
233
  requirements:
192
234
  - - "~>"
193
235
  - !ruby/object:Gem::Version
194
- version: '0.18'
236
+ version: '0.19'
195
237
  description: Reflect on your day, prompts with thor or webapp and stores to db
196
238
  email:
197
239
  - anthony@agargiulo.com
@@ -201,15 +243,17 @@ extensions: []
201
243
  extra_rdoc_files: []
202
244
  files:
203
245
  - CHANGELOG.md
204
- - Dockerfile
205
246
  - Gemfile
206
247
  - Gemfile.lock
207
248
  - LICENSE
208
249
  - README.md
209
250
  - Rakefile
251
+ - config/tcelfer.example.yml
252
+ - db/migrations/001_db_init.rb
210
253
  - exe/tcelfer
211
254
  - lib/tcelfer.rb
212
255
  - lib/tcelfer/cli.rb
256
+ - lib/tcelfer/cli/db_tasks.rb
213
257
  - lib/tcelfer/cli/report.rb
214
258
  - lib/tcelfer/config.rb
215
259
  - lib/tcelfer/errors.rb
@@ -218,13 +262,13 @@ files:
218
262
  - lib/tcelfer/version.rb
219
263
  - spec/spec_helper.rb
220
264
  - spec/tcelfer_spec.rb
221
- homepage: https://www.github.com/agargiulo/tcelfer
265
+ homepage: https://github.com/agargiulo/tcelfer
222
266
  licenses:
223
267
  - GPL-3.0-only
224
268
  metadata:
225
- allowed_push_host: https://rubygems.org
226
- homepage_uri: https://www.github.com/agargiulo/tcelfer
227
- source_code_uri: https://www.github.com/agargiulo/tcelfer
269
+ homepage_uri: https://github.com/agargiulo/tcelfer
270
+ source_code_uri: https://github.com/agargiulo/tcelfer
271
+ github_url: ssh://github.com/agargiulo/tcelfer
228
272
  post_install_message:
229
273
  rdoc_options: []
230
274
  require_paths:
@@ -233,14 +277,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
277
  requirements:
234
278
  - - ">="
235
279
  - !ruby/object:Gem::Version
236
- version: '0'
280
+ version: 2.7.0
281
+ - - "<"
282
+ - !ruby/object:Gem::Version
283
+ version: 3.0.0
237
284
  required_rubygems_version: !ruby/object:Gem::Requirement
238
285
  requirements:
239
286
  - - ">="
240
287
  - !ruby/object:Gem::Version
241
288
  version: '0'
242
289
  requirements: []
243
- rubygems_version: 3.0.1
290
+ rubygems_version: 3.1.4
244
291
  signing_key:
245
292
  specification_version: 4
246
293
  summary: Reflect on your day and keep track
data/Dockerfile DELETED
@@ -1,20 +0,0 @@
1
- FROM ruby:2.6.0-alpine3.8
2
- WORKDIR /app
3
- COPY ./ /app/
4
-
5
- RUN apk --no-cache add --virtual build-dependencies \
6
- ruby-dev build-base sqlite-dev \
7
- postgresql-dev cmake git && \
8
- apk --no-cache add sqlite-libs && \
9
- gem update --system 3.0.2 && \
10
- gem install bundler --no-document -v '~> 2.0' && \
11
- bundle install --jobs=5 --deployment && \
12
- bundle binstubs rack && \
13
- apk del build-dependencies
14
-
15
- RUN chown -R nobody:nogroup /app
16
- USER nobody
17
- ENV RACK_ENV production
18
- EXPOSE 9292
19
- ENTRYPOINT ["/app/bin/rackup"]
20
- #ENTRYPOINT ["/usr/local/bundle/bin/rackup"]