todo_or_die 0.0.3 → 0.1.1
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 +4 -4
- data/.circleci/config.yml +4 -1
- data/CHANGELOG.md +35 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +28 -21
- data/README.md +7 -5
- data/lib/todo_or_die/version.rb +1 -1
- data/lib/todo_or_die.rb +31 -5
- data/todo_or_die.gemspec +7 -7
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cc7971ad1d363af9350c7f9bdc7ae6884104ad1161b1a584de791eb1bccd2f6
|
4
|
+
data.tar.gz: 037644cf228dd8c3fae1f15fe568d11c50aebff47494a040ee6702198305464b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce9ed473d8727a3596380df75079d51e88c23328dc741bc700eaaafd167fcec00a5b510f84931134860a530bf7692ca6dff9f9e62d93eec3b8ad3b085b4428f
|
7
|
+
data.tar.gz: 70a8d8b3df3da35509932cb01ab3f2861b79e7e030602183e581d0a8ea83018dfeb675254618976788789f20aec052323a84b157f587a4a75e31c669bfbb1f4c
|
data/.circleci/config.yml
CHANGED
@@ -6,7 +6,9 @@ version: 2
|
|
6
6
|
jobs:
|
7
7
|
build:
|
8
8
|
docker:
|
9
|
-
- image: circleci/ruby:2.
|
9
|
+
- image: circleci/ruby:2.7-node-browsers
|
10
|
+
environment:
|
11
|
+
RUBYOPT: "-W:no-deprecated -W:no-experimental"
|
10
12
|
|
11
13
|
working_directory: ~/repo
|
12
14
|
|
@@ -16,6 +18,7 @@ jobs:
|
|
16
18
|
- run:
|
17
19
|
name: install dependencies
|
18
20
|
command: |
|
21
|
+
bundle update --bundler
|
19
22
|
bundle install --retry=3
|
20
23
|
|
21
24
|
- run:
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [0.1.1] - 2022-07-01
|
8
|
+
|
9
|
+
- Fix `warn_by` [#16](https://github.com/searls/todo_or_die/pull/16)
|
10
|
+
|
11
|
+
## [0.1.0] - 2022-06-27
|
12
|
+
|
13
|
+
- Add `warn_by` option [#14](https://github.com/searls/todo_or_die/pull/14)
|
14
|
+
|
15
|
+
## [0.0.3] - 2019-11-26
|
16
|
+
### Added
|
17
|
+
- Boolean-returning conditionals or callables (Proc, Block, Lambda) can be passed to the
|
18
|
+
new `if` argument. `if` can be used instead of or in conjunction with the `by` argument
|
19
|
+
to die on a specific date OR when a specific condition becomes true.
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
- Date strings can now be parsed parsed internally without calling `Time` or `Date`
|
23
|
+
classes explicitely.
|
24
|
+
|
25
|
+
## [0.0.2] - 2019-02-15
|
26
|
+
### Changed
|
27
|
+
- Exclude this gem's backtrace location from exceptions thrown to make it easier to find
|
28
|
+
TODOs.
|
29
|
+
|
30
|
+
## [0.0.1] - 2019-01-01
|
31
|
+
|
32
|
+
[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.3...HEAD
|
33
|
+
[0.0.3]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.2...v0.0.3
|
34
|
+
[0.0.2]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.1...v0.0.2
|
35
|
+
[0.0.1]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v0.0.1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,33 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
todo_or_die (0.
|
4
|
+
todo_or_die (0.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
rubocop (
|
19
|
-
jaro_winkler (~> 1.5.1)
|
9
|
+
ast (2.4.2)
|
10
|
+
minitest (5.16.1)
|
11
|
+
parallel (1.22.1)
|
12
|
+
parser (3.1.2.0)
|
13
|
+
ast (~> 2.4.1)
|
14
|
+
rainbow (3.1.1)
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.5.0)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rubocop (1.29.1)
|
20
19
|
parallel (~> 1.10)
|
21
|
-
parser (>=
|
22
|
-
powerpack (~> 0.1)
|
20
|
+
parser (>= 3.1.0.0)
|
23
21
|
rainbow (>= 2.2.2, < 4.0)
|
22
|
+
regexp_parser (>= 1.8, < 3.0)
|
23
|
+
rexml (>= 3.2.5, < 4.0)
|
24
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
24
25
|
ruby-progressbar (~> 1.7)
|
25
|
-
unicode-display_width (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
27
|
+
rubocop-ast (1.18.0)
|
28
|
+
parser (>= 3.1.1.0)
|
29
|
+
rubocop-performance (1.13.3)
|
30
|
+
rubocop (>= 1.7.0, < 2.0)
|
31
|
+
rubocop-ast (>= 0.4.0)
|
32
|
+
ruby-progressbar (1.11.0)
|
33
|
+
standard (1.12.1)
|
34
|
+
rubocop (= 1.29.1)
|
35
|
+
rubocop-performance (= 1.13.3)
|
36
|
+
timecop (0.9.5)
|
37
|
+
unicode-display_width (2.2.0)
|
31
38
|
|
32
39
|
PLATFORMS
|
33
40
|
ruby
|
@@ -41,4 +48,4 @@ DEPENDENCIES
|
|
41
48
|
todo_or_die!
|
42
49
|
|
43
50
|
BUNDLED WITH
|
44
|
-
1.
|
51
|
+
2.1.4
|
data/README.md
CHANGED
@@ -60,20 +60,22 @@ end
|
|
60
60
|
Nothing will happen at all until February 4th, at which point the gem will
|
61
61
|
raise an error whenever this class is loaded until someone deals with it.
|
62
62
|
|
63
|
-
You may also pass a condition, either as
|
63
|
+
You may also pass a condition, either as a callable (e.g. proc/lambda/method) or
|
64
|
+
a boolean test:
|
64
65
|
|
65
66
|
``` ruby
|
66
67
|
class User < ApplicationRecord
|
67
|
-
TodoOrDie(
|
68
|
-
"delete after 1 million users",
|
69
|
-
if: User.size > 1000000,
|
70
|
-
)
|
68
|
+
TodoOrDie("delete after someone wins", if: User.count > 1000000)
|
71
69
|
def is_one_millionth_user?
|
72
70
|
id == 1000000
|
73
71
|
end
|
74
72
|
end
|
75
73
|
```
|
76
74
|
|
75
|
+
You can also pass both `by` and `if` (where both must be met for an error to be
|
76
|
+
raised) or, I guess, neither (where an error will be raised as soon as
|
77
|
+
`TodoOrDie` is invoked).
|
78
|
+
|
77
79
|
### What kind of error?
|
78
80
|
|
79
81
|
It depends on whether you're using [Rails](https://rubyonrails.org) or not.
|
data/lib/todo_or_die/version.rb
CHANGED
data/lib/todo_or_die.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "time"
|
1
2
|
require "todo_or_die/version"
|
2
3
|
require "todo_or_die/overdue_error"
|
3
4
|
|
@@ -10,7 +11,7 @@ module TodoOrDie
|
|
10
11
|
(" came due on #{due_at.strftime("%Y-%m-%d")}" if due_at),
|
11
12
|
(" and" if due_at && condition),
|
12
13
|
(" has met the conditions to be acted upon" if condition),
|
13
|
-
". Do it!"
|
14
|
+
". Do it!"
|
14
15
|
].compact.join("")
|
15
16
|
|
16
17
|
if defined?(Rails) && Rails.env.production?
|
@@ -19,6 +20,20 @@ module TodoOrDie
|
|
19
20
|
raise TodoOrDie::OverdueTodo, error_message, TodoOrDie.__clean_backtrace(caller)
|
20
21
|
end
|
21
22
|
},
|
23
|
+
|
24
|
+
warn: lambda { |message, due_at, warn_at, condition|
|
25
|
+
error_message = [
|
26
|
+
"TODO: \"#{message}\"",
|
27
|
+
(" is due on #{due_at.strftime("%Y-%m-%d")}" if due_at),
|
28
|
+
(" and" if warn_at && condition),
|
29
|
+
(" has met the conditions to be acted upon" if condition),
|
30
|
+
". Don't forget!"
|
31
|
+
].compact.join("")
|
32
|
+
|
33
|
+
puts error_message
|
34
|
+
|
35
|
+
Rails.logger.warn(error_message) if defined?(Rails)
|
36
|
+
}
|
22
37
|
}.freeze
|
23
38
|
|
24
39
|
def self.config(options = {})
|
@@ -37,14 +52,25 @@ module TodoOrDie
|
|
37
52
|
end
|
38
53
|
|
39
54
|
# The main event
|
40
|
-
def TodoOrDie(message, by: by_omitted = true, if: if_omitted = true
|
55
|
+
def TodoOrDie(message, by: by_omitted = true, if: if_omitted = true, warn_by: warn_by_omitted = true)
|
41
56
|
due_at = Time.parse(by.to_s) unless by_omitted
|
42
|
-
|
57
|
+
warn_at = Time.parse(warn_by.to_s) unless warn_by_omitted
|
43
58
|
condition = binding.local_variable_get(:if) unless if_omitted
|
44
|
-
condition_met = if_omitted || (condition.respond_to?(:call) ? condition.call : condition)
|
45
59
|
|
46
|
-
|
60
|
+
is_past_due_date = by_omitted || Time.now > due_at
|
61
|
+
die_condition_met = if_omitted || (condition.respond_to?(:call) ? condition.call : condition)
|
62
|
+
no_conditions_given = by_omitted && if_omitted && warn_by_omitted
|
63
|
+
only_warn_condition_given = (if_omitted && by_omitted && !warn_by_omitted)
|
64
|
+
|
65
|
+
ready_to_die = is_past_due_date && die_condition_met && !only_warn_condition_given
|
66
|
+
should_die = no_conditions_given || ready_to_die
|
67
|
+
should_warn = !warn_by_omitted && Time.now > warn_at
|
68
|
+
|
69
|
+
if should_die
|
47
70
|
die = TodoOrDie.config[:die]
|
48
71
|
die.call(*[message, due_at, condition].take(die.arity.abs))
|
72
|
+
elsif should_warn
|
73
|
+
warn = TodoOrDie.config[:warn]
|
74
|
+
warn.call(*[message, due_at, warn_at, condition].take(warn.arity.abs))
|
49
75
|
end
|
50
76
|
end
|
data/todo_or_die.gemspec
CHANGED
@@ -3,15 +3,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require "todo_or_die"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "todo_or_die"
|
7
|
+
spec.version = TodoOrDie::VERSION
|
8
|
+
spec.authors = ["Justin Searls"]
|
9
|
+
spec.email = ["searls@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.homepage
|
11
|
+
spec.summary = "Write TODOs in code that ensure you actually do them"
|
12
|
+
spec.homepage = "https://github.com/searls/todo_or_die"
|
13
13
|
|
14
|
-
spec.files
|
14
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
15
15
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
end
|
17
17
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo_or_die
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- searls@gmail.com
|
86
86
|
executables: []
|
@@ -89,6 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".circleci/config.yml"
|
91
91
|
- ".gitignore"
|
92
|
+
- CHANGELOG.md
|
92
93
|
- Gemfile
|
93
94
|
- Gemfile.lock
|
94
95
|
- LICENSE.txt
|
@@ -103,7 +104,7 @@ files:
|
|
103
104
|
homepage: https://github.com/searls/todo_or_die
|
104
105
|
licenses: []
|
105
106
|
metadata: {}
|
106
|
-
post_install_message:
|
107
|
+
post_install_message:
|
107
108
|
rdoc_options: []
|
108
109
|
require_paths:
|
109
110
|
- lib
|
@@ -118,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
119
|
- !ruby/object:Gem::Version
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
122
|
-
signing_key:
|
122
|
+
rubygems_version: 3.3.6
|
123
|
+
signing_key:
|
123
124
|
specification_version: 4
|
124
125
|
summary: Write TODOs in code that ensure you actually do them
|
125
126
|
test_files: []
|