todo_or_die 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -1
- data/CHANGELOG.md +6 -4
- data/Gemfile.lock +1 -1
- data/lib/todo_or_die/version.rb +1 -1
- data/lib/todo_or_die.rb +25 -4
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0491e8c47bb1f59f0b38966bb65a8dbd6d31a18aa9044ca9445cce8962c55e62'
|
4
|
+
data.tar.gz: c82c1ce0e56afbfb197ff4d7a66d7187003ef085b58d7096c510696faca4dbc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18751ea8ecfeb4e50ddbdc42229b721957a86bd5d6535655264dec37a46f99f68596fd98be14eb2d585395956cf0b1c01712610750664fae8c8bfa910ac4e0b2
|
7
|
+
data.tar.gz: 6fdf682b441ce3edf280f1322cc4a88bf6af9c84057334eef449e894fcd41ff20a3a2164ccd80a13bbe0214787101c0ff38e24cff1f73ae2353853eaf1563c4c
|
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
CHANGED
@@ -4,21 +4,23 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [
|
7
|
+
## [0.1.0] - 2022-06-27
|
8
|
+
|
9
|
+
- Add `warn_by` option [#14](https://github.com/searls/todo_or_die/pull/14)
|
8
10
|
|
9
11
|
## [0.0.3] - 2019-11-26
|
10
12
|
### Added
|
11
|
-
- Boolean-returning conditionals or callables (Proc, Block, Lambda) can be passed to the
|
13
|
+
- Boolean-returning conditionals or callables (Proc, Block, Lambda) can be passed to the
|
12
14
|
new `if` argument. `if` can be used instead of or in conjunction with the `by` argument
|
13
15
|
to die on a specific date OR when a specific condition becomes true.
|
14
16
|
|
15
17
|
### Changed
|
16
|
-
- Date strings can now be parsed parsed internally without calling `Time` or `Date`
|
18
|
+
- Date strings can now be parsed parsed internally without calling `Time` or `Date`
|
17
19
|
classes explicitely.
|
18
20
|
|
19
21
|
## [0.0.2] - 2019-02-15
|
20
22
|
### Changed
|
21
|
-
- Exclude this gem's backtrace location from exceptions thrown to make it easier to find
|
23
|
+
- Exclude this gem's backtrace location from exceptions thrown to make it easier to find
|
22
24
|
TODOs.
|
23
25
|
|
24
26
|
## [0.0.1] - 2019-01-01
|
data/Gemfile.lock
CHANGED
data/lib/todo_or_die/version.rb
CHANGED
data/lib/todo_or_die.rb
CHANGED
@@ -19,6 +19,20 @@ module TodoOrDie
|
|
19
19
|
else
|
20
20
|
raise TodoOrDie::OverdueTodo, error_message, TodoOrDie.__clean_backtrace(caller)
|
21
21
|
end
|
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)
|
22
36
|
}
|
23
37
|
}.freeze
|
24
38
|
|
@@ -38,14 +52,21 @@ module TodoOrDie
|
|
38
52
|
end
|
39
53
|
|
40
54
|
# The main event
|
41
|
-
def TodoOrDie(message, by: by_omitted = true, if: if_omitted = true) # rubocop:disable Naming/MethodName
|
55
|
+
def TodoOrDie(message, by: by_omitted = true, if: if_omitted = true, warn_by: warn_by_omitted = true) # rubocop:disable Naming/MethodName
|
42
56
|
due_at = Time.parse(by.to_s) unless by_omitted
|
43
|
-
|
57
|
+
warn_at = Time.parse(warn_by.to_s) unless warn_by_omitted
|
44
58
|
condition = binding.local_variable_get(:if) unless if_omitted
|
45
|
-
condition_met = if_omitted || (condition.respond_to?(:call) ? condition.call : condition)
|
46
59
|
|
47
|
-
|
60
|
+
should_warn = !warn_by_omitted && Time.now > warn_at
|
61
|
+
is_due = by_omitted || Time.now > due_at
|
62
|
+
die_condition_met = if_omitted || (condition.respond_to?(:call) ? condition.call : condition)
|
63
|
+
should_die = is_due && die_condition_met
|
64
|
+
|
65
|
+
if should_die
|
48
66
|
die = TodoOrDie.config[:die]
|
49
67
|
die.call(*[message, due_at, condition].take(die.arity.abs))
|
68
|
+
elsif should_warn
|
69
|
+
warn = TodoOrDie.config[:warn]
|
70
|
+
warn.call(*[message, due_at, warn_at, condition].take(warn.arity.abs))
|
50
71
|
end
|
51
72
|
end
|
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.0
|
4
|
+
version: 0.1.0
|
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-06-27 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: []
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
homepage: https://github.com/searls/todo_or_die
|
105
105
|
licenses: []
|
106
106
|
metadata: {}
|
107
|
-
post_install_message:
|
107
|
+
post_install_message:
|
108
108
|
rdoc_options: []
|
109
109
|
require_paths:
|
110
110
|
- lib
|
@@ -119,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
-
signing_key:
|
122
|
+
rubygems_version: 3.3.7
|
123
|
+
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Write TODOs in code that ensure you actually do them
|
126
126
|
test_files: []
|