tcelfer 1.0.3 → 1.0.5

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: 8227fc882ed45d5d8471ef2c479120893fd53addfbdac84cb7f68781ca4dc3e5
4
- data.tar.gz: c5e5d6904a03490282022102c99a26783cbcf2b66d5697f821114d09a5b7da54
3
+ metadata.gz: 9eeab0e7ca707b1816f953fd851b90fbeb038786ec0fe49f4a06c7a9808017e5
4
+ data.tar.gz: 423902dee4090877b3ab0d3eddde445e379a03361b2f2b1058142ce24d7199f7
5
5
  SHA512:
6
- metadata.gz: fc0eae553e24db09b9f4d5e00fee1005e8dc0b0904d59c92aa1a396591f47df176187b5767b662136356309cc0176062a48eb788a7f25c4b80a494eb98424e2a
7
- data.tar.gz: e451730865cd0ce1177aa89308d1347317917c4120b13b92d76772489e593d95fe266acbef82c0a43974c82757f97cc0a74e80d1895e5d25c226b2565bcaa0ec
6
+ metadata.gz: 1b690cbfd5708f311f5629b17be11dad638528376d9888c78cf0bb84e72e2b73c8737c83321e5fcf1e54ff50da04360dd188b35f0e1966f82d4a9cb7d172670d
7
+ data.tar.gz: 363a6b8a1017e73e5de5b77fcd684fa722b1fccf3bb503baa008a3ddc8c84a5eaae784f8d801bc038dc7b1afb9b7bb15fde6092bb0347cb80e22e986eca45b91
@@ -4,6 +4,19 @@ 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.5] - 2019-08-12
8
+ ### Fixed
9
+ - errant Dockerfile was being included, no more.
10
+
11
+ ## [1.0.4] - 2019-08-12
12
+ ### Changed
13
+ - new subcommands under `tcelfer db` to replace the `bin/db_init` functionality
14
+ - initdb|migrate: run all or some DB migrations (up or down)
15
+ - path: shows the path of the database (could be made into `tcelfer env` instead maybe?
16
+ - new config option, `:migrations_path`, defaults to `<tcelfer_gem_root>/db/migrations`
17
+ - updated Ruby versions for Travis CI
18
+ - updated several gem dependencies
19
+
7
20
  ## [1.0.3] - 2019-05-21
8
21
  ### Added
9
22
  - `--yesterday` flag for `tcelfer day`
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tcelfer (1.0.3)
4
+ tcelfer (1.0.5)
5
5
  anyway_config (~> 1.4)
6
6
  paint (~> 2.1)
7
- sequel (~> 5.20)
7
+ sequel (~> 5.23)
8
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/
@@ -17,63 +17,62 @@ GEM
17
17
  ast (2.4.0)
18
18
  coderay (1.1.2)
19
19
  diff-lcs (1.3)
20
- dotenv (2.7.2)
21
- equatable (0.5.0)
22
- jaro_winkler (1.5.2)
20
+ dotenv (2.7.5)
21
+ equatable (0.6.1)
22
+ jaro_winkler (1.5.3)
23
23
  method_source (0.9.2)
24
- necromancer (0.4.0)
24
+ necromancer (0.5.0)
25
25
  paint (2.1.0)
26
26
  parallel (1.17.0)
27
27
  parser (2.6.3.0)
28
28
  ast (~> 2.4.0)
29
- pastel (0.7.2)
30
- equatable (~> 0.5.0)
31
- tty-color (~> 0.4.0)
29
+ pastel (0.7.3)
30
+ equatable (~> 0.6)
31
+ tty-color (~> 0.5)
32
32
  pry (0.12.2)
33
33
  coderay (~> 1.1.0)
34
34
  method_source (~> 0.9.0)
35
35
  rainbow (3.0.0)
36
- rake (12.3.2)
36
+ rake (12.3.3)
37
37
  rspec (3.8.0)
38
38
  rspec-core (~> 3.8.0)
39
39
  rspec-expectations (~> 3.8.0)
40
40
  rspec-mocks (~> 3.8.0)
41
- rspec-core (3.8.0)
41
+ rspec-core (3.8.2)
42
42
  rspec-support (~> 3.8.0)
43
- rspec-expectations (3.8.3)
43
+ rspec-expectations (3.8.4)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
45
  rspec-support (~> 3.8.0)
46
- rspec-mocks (3.8.0)
46
+ rspec-mocks (3.8.1)
47
47
  diff-lcs (>= 1.2.0, < 2.0)
48
48
  rspec-support (~> 3.8.0)
49
- rspec-support (3.8.0)
50
- rubocop (0.70.0)
49
+ rspec-support (3.8.2)
50
+ rubocop (0.74.0)
51
51
  jaro_winkler (~> 1.5.1)
52
52
  parallel (~> 1.10)
53
53
  parser (>= 2.6)
54
54
  rainbow (>= 2.2.2, < 4.0)
55
55
  ruby-progressbar (~> 1.7)
56
56
  unicode-display_width (>= 1.4.0, < 1.7)
57
- ruby-progressbar (1.10.0)
58
- sequel (5.20.0)
57
+ rubocop-performance (1.4.1)
58
+ rubocop (>= 0.71.0)
59
+ ruby-progressbar (1.10.1)
60
+ sequel (5.23.0)
59
61
  sqlite3 (1.4.1)
60
62
  terminal-table (1.8.0)
61
63
  unicode-display_width (~> 1.1, >= 1.1.1)
62
64
  thor (0.20.3)
63
- timers (4.3.0)
64
- tty-color (0.4.3)
65
- tty-cursor (0.6.1)
66
- tty-prompt (0.18.1)
67
- necromancer (~> 0.4.0)
65
+ tty-color (0.5.0)
66
+ tty-cursor (0.7.0)
67
+ tty-prompt (0.19.0)
68
+ necromancer (~> 0.5.0)
68
69
  pastel (~> 0.7.0)
69
- timers (~> 4.0)
70
- tty-cursor (~> 0.6.0)
71
- tty-reader (~> 0.5.0)
72
- tty-reader (0.5.0)
73
- tty-cursor (~> 0.6.0)
74
- tty-screen (~> 0.6.4)
70
+ tty-reader (~> 0.6.0)
71
+ tty-reader (0.6.0)
72
+ tty-cursor (~> 0.7)
73
+ tty-screen (~> 0.7)
75
74
  wisper (~> 2.0.0)
76
- tty-screen (0.6.5)
75
+ tty-screen (0.7.0)
77
76
  unicode-display_width (1.6.0)
78
77
  wisper (2.0.0)
79
78
 
@@ -84,10 +83,11 @@ DEPENDENCIES
84
83
  bundler (~> 2.0)
85
84
  dotenv (~> 2.7)
86
85
  pry (~> 0.12)
87
- rake (~> 12.0)
88
- rspec (~> 3.0)
89
- rubocop (~> 0.70)
86
+ rake (~> 12.3)
87
+ rspec (~> 3.8)
88
+ rubocop (~> 0.74)
89
+ rubocop-performance (~> 1.4)
90
90
  tcelfer!
91
91
 
92
92
  BUNDLED WITH
93
- 2.0.1
93
+ 2.0.2
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  ![generated_report](/images/generated_report.png)
7
7
 
8
8
  ## Requirements
9
- * Ruby 2.5.0+ (Tested with 2.6.0 mostly)
9
+ * Ruby 2.3.0+ (Tested with 2.6.0 mostly)
10
10
  * Sqlite3
11
11
 
12
12
  ## Installation
@@ -28,13 +28,11 @@ $ gem install tcelfer
28
28
 
29
29
  ## Setup
30
30
  ```bash
31
- # Configure with one of the following:
32
- # Just change the db location
33
- export TCELFER_SQLITE_PATH=path/to/some_file.db
34
- # Or copy `config/tcelfer.example.yml` and use:
31
+ # Example configuration
35
32
  export TCELFER_CONF=~/.config/tcelfer/my_conf.yml
33
+ cp config/tcelfer.example.yml ${TCELFER_CONF}
36
34
  # Initialize the database
37
- $ bin/db_init
35
+ $ tcelfer db init
38
36
  ```
39
37
 
40
38
  ## Usage
data/Rakefile CHANGED
@@ -14,12 +14,17 @@
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
 
@@ -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
@@ -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
@@ -53,7 +54,7 @@ module Tcelfer
53
54
  desc 'day', 'record info for a day'
54
55
  def day
55
56
  Tcelfer.config.debug = options[:verbose]
56
- store = Tcelfer::Storage.new
57
+ store = Tcelfer::Storage.new
57
58
  tc_day = rec_day! store
58
59
  @prompt.say("Recorded [#{tc_day.date}]: #{Paint[tc_day.rating, :bold]}")
59
60
  rescue Tcelfer::Error => e
@@ -83,6 +84,9 @@ module Tcelfer
83
84
  @prompt.error("[#{e.class}]", e)
84
85
  end
85
86
 
87
+ desc 'db', 'Perform various DB related tasks'
88
+ subcommand 'db', DBTasks
89
+
86
90
  private
87
91
 
88
92
  def pick_date!
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.3'
18
+ VERSION = '1.0.5'
19
19
  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.3
4
+ version: 1.0.5
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-05-22 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,42 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '12.0'
61
+ version: '12.3'
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: '12.0'
68
+ version: '12.3'
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.8'
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.8'
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.70'
89
+ version: '0.74'
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.70'
96
+ version: '0.74'
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.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.4'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: anyway_config
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,14 @@ dependencies:
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '5.20'
145
+ version: '5.23'
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '5.20'
152
+ version: '5.23'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: sqlite3
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +198,14 @@ dependencies:
184
198
  requirements:
185
199
  - - "~>"
186
200
  - !ruby/object:Gem::Version
187
- version: '0.18'
201
+ version: '0.19'
188
202
  type: :runtime
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
206
  - - "~>"
193
207
  - !ruby/object:Gem::Version
194
- version: '0.18'
208
+ version: '0.19'
195
209
  description: Reflect on your day, prompts with thor or webapp and stores to db
196
210
  email:
197
211
  - anthony@agargiulo.com
@@ -201,15 +215,17 @@ extensions: []
201
215
  extra_rdoc_files: []
202
216
  files:
203
217
  - CHANGELOG.md
204
- - Dockerfile
205
218
  - Gemfile
206
219
  - Gemfile.lock
207
220
  - LICENSE
208
221
  - README.md
209
222
  - Rakefile
223
+ - config/tcelfer.example.yml
224
+ - db/migrations/001_db_init.rb
210
225
  - exe/tcelfer
211
226
  - lib/tcelfer.rb
212
227
  - lib/tcelfer/cli.rb
228
+ - lib/tcelfer/cli/db_tasks.rb
213
229
  - lib/tcelfer/cli/report.rb
214
230
  - lib/tcelfer/config.rb
215
231
  - lib/tcelfer/errors.rb
@@ -240,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
256
  - !ruby/object:Gem::Version
241
257
  version: '0'
242
258
  requirements: []
243
- rubygems_version: 3.0.3
259
+ rubygems_version: 3.0.4
244
260
  signing_key:
245
261
  specification_version: 4
246
262
  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"]