fixme 2.0.0 → 3.0.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 +4 -4
- data/README.md +8 -14
- data/lib/fixme.rb +7 -5
- data/lib/fixme/version.rb +1 -1
- data/spec/fixme_spec.rb +17 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e1ab3e11f1dd62c6d26791d1278dc0f1b0da2b4
|
4
|
+
data.tar.gz: 6b702750cb9cf2598a711e0d99be151d56c1bde5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b1038bbedf63b7c176638a1772f3574dc31408b885244432dd0b70f431ebcb18980f8b9e513f180005e39cf76cd0d14e3fbc22272dd0a084f71932062346116
|
7
|
+
data.tar.gz: 19e4702838cb5434f1dbd9c35854f4835e91354591821a5457fb610dc5e823272f6cd23c6a2d9139daba0b86b21a1d06042f7f12570b68e8fcc907e0fa1e9de1
|
data/README.md
CHANGED
@@ -26,10 +26,6 @@ Protip: make sure it's clear from the exception or from a separate comment just
|
|
26
26
|
|
27
27
|
If `Rails.env` (Ruby on Rails) or `ENV["RACK_ENV"]` (e.g. Sinatra) is present, it will only ever raise in the `"test"` and `"development"` environments. That is, the production app will never raise these exceptions.
|
28
28
|
|
29
|
-
### Selectively disable
|
30
|
-
|
31
|
-
If you e.g. don't want your CI server to raise, make it set the environment variable `DISABLE_FIXME_LIB`.
|
32
|
-
|
33
29
|
### Do something other than raise
|
34
30
|
|
35
31
|
When these exceptions trigger on your CI server they stop the line, blocking your delivery chain until they're addressed. This could be what you want, or it could be a little annoying.
|
@@ -37,20 +33,18 @@ When these exceptions trigger on your CI server they stop the line, blocking you
|
|
37
33
|
So you can configure the library to do something other than raise:
|
38
34
|
|
39
35
|
```
|
40
|
-
# In a Rails project, this might be in config/initializers/fixme.rb
|
41
|
-
Fixme.explode_with do |
|
42
|
-
YourOwnCodeOrSomeLibrary.email_developers(
|
43
|
-
YourOwnCodeOrSomeLibrary.notify_chat(
|
36
|
+
# In a Rails project, this might be in config/initializers/fixme.rb
|
37
|
+
Fixme.explode_with do |details|
|
38
|
+
YourOwnCodeOrSomeLibrary.email_developers(details.full_message)
|
39
|
+
YourOwnCodeOrSomeLibrary.notify_chat(details.full_message)
|
44
40
|
end
|
45
41
|
```
|
46
42
|
|
47
|
-
|
43
|
+
There's also `details.date`, `details.message` and `details.backtrace`.
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
```
|
45
|
+
### Selectively disable
|
46
|
+
|
47
|
+
If you e.g. don't want your CI server to raise, make it set the environment variable `DISABLE_FIXME_LIB`.
|
54
48
|
|
55
49
|
|
56
50
|
## Installation
|
data/lib/fixme.rb
CHANGED
@@ -2,9 +2,10 @@ require "fixme/version"
|
|
2
2
|
require "date"
|
3
3
|
|
4
4
|
module Fixme
|
5
|
-
|
5
|
+
UnfixedError = Class.new(StandardError)
|
6
|
+
Details = Struct.new(:full_message, :backtrace, :date, :message)
|
6
7
|
|
7
|
-
DEFAULT_EXPLODER = proc { |
|
8
|
+
DEFAULT_EXPLODER = proc { |details| raise(UnfixedError, details.full_message, details.backtrace) }
|
8
9
|
|
9
10
|
def self.reset_configuration
|
10
11
|
explode_with(&DEFAULT_EXPLODER)
|
@@ -16,7 +17,8 @@ module Fixme
|
|
16
17
|
|
17
18
|
def self.explode(date, message)
|
18
19
|
full_message = "Fix by #{date}: #{message}"
|
19
|
-
|
20
|
+
backtrace = caller.reverse.take_while { |line| !line.include?(__FILE__) }.reverse
|
21
|
+
@explode_with.call Details.new(full_message, backtrace, date, message)
|
20
22
|
end
|
21
23
|
|
22
24
|
reset_configuration
|
@@ -32,7 +34,7 @@ module Fixme
|
|
32
34
|
end
|
33
35
|
|
34
36
|
class Runner
|
35
|
-
|
37
|
+
RUN_ONLY_IN_THESE_FRAMEWORK_ENVS = [ "", "test", "development" ]
|
36
38
|
|
37
39
|
def initialize(date_and_message)
|
38
40
|
@date_and_message = date_and_message
|
@@ -40,7 +42,7 @@ module Fixme
|
|
40
42
|
|
41
43
|
def run
|
42
44
|
return if ENV["DISABLE_FIXME_LIB"]
|
43
|
-
return unless
|
45
|
+
return unless RUN_ONLY_IN_THESE_FRAMEWORK_ENVS.include?(framework_env.to_s)
|
44
46
|
|
45
47
|
due_date, message = parse
|
46
48
|
|
data/lib/fixme/version.rb
CHANGED
data/spec/fixme_spec.rb
CHANGED
@@ -26,6 +26,14 @@ describe Fixme, "#FIXME" do
|
|
26
26
|
}.not_to raise_error
|
27
27
|
end
|
28
28
|
|
29
|
+
it "truncates the backtrace to exclude itself" do
|
30
|
+
begin
|
31
|
+
FIXME "2013-12-31: Remove this stuff."
|
32
|
+
rescue => e
|
33
|
+
expect(e.backtrace.first).to include("fixme_spec.rb:")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
# Had a bug with ": " in the message.
|
30
38
|
it "parses the date and message flawlessly" do
|
31
39
|
expect {
|
@@ -98,34 +106,19 @@ describe Fixme, "#FIXME" do
|
|
98
106
|
expect_not_to_raise
|
99
107
|
end
|
100
108
|
|
101
|
-
|
102
|
-
|
103
|
-
log = []
|
104
|
-
|
105
|
-
Fixme.explode_with do |full_message, date, message|
|
106
|
-
log << [ full_message, date, message ]
|
107
|
-
end
|
109
|
+
it "lets you configure an alternative to raising" do
|
110
|
+
log = nil
|
108
111
|
|
109
|
-
|
110
|
-
|
111
|
-
expect(log.last).to eq [
|
112
|
-
"Fix by 2013-12-31: Do not explode.",
|
113
|
-
Date.new(2013, 12, 31),
|
114
|
-
"Do not explode.",
|
115
|
-
]
|
112
|
+
Fixme.explode_with do |details|
|
113
|
+
log = details
|
116
114
|
end
|
117
115
|
|
118
|
-
|
119
|
-
log = []
|
120
|
-
|
121
|
-
Fixme.explode_with do |full_message|
|
122
|
-
log << full_message
|
123
|
-
end
|
116
|
+
FIXME "2013-12-31: Do not explode."
|
124
117
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
118
|
+
expect(log.full_message).to eq "Fix by 2013-12-31: Do not explode."
|
119
|
+
expect(log.date).to eq Date.new(2013, 12, 31)
|
120
|
+
expect(log.message).to eq "Do not explode."
|
121
|
+
expect(log.backtrace.first).to include "fixme_spec.rb:"
|
129
122
|
end
|
130
123
|
|
131
124
|
private
|