fixme 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/lib/fixme.rb +14 -5
- data/lib/fixme/version.rb +1 -1
- data/spec/fixme_spec.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96b8966891c13c24139acc8161981a32ba5d706e
|
4
|
+
data.tar.gz: 259f2d4b7a5ced3f535d23bbc0a3069b7b562375
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6be5a85894fefba3f8128d92ad678751b8a202b1e6e78fe4a6ed4d3b2c503f21b94189d6817972ef5bd9a8ae2e4c5d0e60f87ed381bd08f8954bf5b4cae3d359
|
7
|
+
data.tar.gz: e0f9fcadba73e6d037fff17a227d9fca21a76c5f2b06ec429fde7ba80a30381bddca3614a2c85a4315896fa34d4fc0652509439e256e2ae1fbbb2ff1019a711b
|
data/README.md
CHANGED
@@ -40,7 +40,19 @@ Fixme.explode_with do |details|
|
|
40
40
|
end
|
41
41
|
```
|
42
42
|
|
43
|
-
There's also `details.date`, `details.message` and `details.backtrace`.
|
43
|
+
There's also `details.date`, `details.due_days_ago`, `details.message` and `details.backtrace`.
|
44
|
+
|
45
|
+
You can call `Fixme.raise_from(details)` to get the default behavior, if you want that under certain conditions:
|
46
|
+
|
47
|
+
```
|
48
|
+
Fixme.explode_with do |details|
|
49
|
+
if details.due_days_ago > 5
|
50
|
+
Fixme.raise_from(details)
|
51
|
+
else
|
52
|
+
YourOwnCodeOrSomeLibrary.notify_chat(details.full_message)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
44
56
|
|
45
57
|
### Selectively disable
|
46
58
|
|
data/lib/fixme.rb
CHANGED
@@ -3,14 +3,15 @@ require "date"
|
|
3
3
|
|
4
4
|
module Fixme
|
5
5
|
UnfixedError = Class.new(StandardError)
|
6
|
-
Details = Struct.new(:full_message, :backtrace, :date, :message)
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
Details = Struct.new(:full_message, :backtrace, :date, :message) do
|
8
|
+
def due_days_ago
|
9
|
+
Date.today - date
|
10
|
+
end
|
12
11
|
end
|
13
12
|
|
13
|
+
DEFAULT_EXPLODER = ->(details) { raise(UnfixedError, details.full_message, details.backtrace) }
|
14
|
+
|
14
15
|
def self.explode_with(&block)
|
15
16
|
@explode_with = block
|
16
17
|
end
|
@@ -21,6 +22,14 @@ module Fixme
|
|
21
22
|
@explode_with.call Details.new(full_message, backtrace, date, message)
|
22
23
|
end
|
23
24
|
|
25
|
+
def self.raise_from(details)
|
26
|
+
DEFAULT_EXPLODER.call(details)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.reset_configuration
|
30
|
+
explode_with(&DEFAULT_EXPLODER)
|
31
|
+
end
|
32
|
+
|
24
33
|
reset_configuration
|
25
34
|
end
|
26
35
|
|
data/lib/fixme/version.rb
CHANGED
data/spec/fixme_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Fixme, "#FIXME" do
|
|
26
26
|
}.not_to raise_error
|
27
27
|
end
|
28
28
|
|
29
|
-
it "truncates the backtrace to exclude itself" do
|
29
|
+
it "truncates the backtrace to exclude the library itself" do
|
30
30
|
begin
|
31
31
|
FIXME "2013-12-31: Remove this stuff."
|
32
32
|
rescue => e
|
@@ -119,6 +119,19 @@ describe Fixme, "#FIXME" do
|
|
119
119
|
expect(log.date).to eq Date.new(2013, 12, 31)
|
120
120
|
expect(log.message).to eq "Do not explode."
|
121
121
|
expect(log.backtrace.first).to include "fixme_spec.rb:"
|
122
|
+
|
123
|
+
expect(log.due_days_ago).to eq(Date.today - log.date)
|
124
|
+
expect(log.due_days_ago).to be > 0
|
125
|
+
end
|
126
|
+
|
127
|
+
it "lets you use Fixme.raise_from in configuration" do
|
128
|
+
Fixme.explode_with do |details|
|
129
|
+
Fixme.raise_from(details)
|
130
|
+
end
|
131
|
+
|
132
|
+
expect {
|
133
|
+
FIXME "2013-12-31: Do not explode."
|
134
|
+
}.to raise_error(Fixme::UnfixedError, "Fix by 2013-12-31: Do not explode.")
|
122
135
|
end
|
123
136
|
|
124
137
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|