fixme 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/fixme.rb +33 -9
- data/lib/fixme/version.rb +1 -1
- 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: c67ae50e3df9d60ec0fade7d7a0f5c1e36977e9f
|
4
|
+
data.tar.gz: dc1a8c384a67c488afd83c16bba99f497a7d9513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ab32146fc4177eab5ca1777116ef256e1574bcd512d45c3c548edc3ee7ec81d2bdcedb7bdd8e046a81e22265875a74ad0ff1754b95b834a104ef9c7498fea13
|
7
|
+
data.tar.gz: 6816245408219c824abdfcafc2b90310c31bc567ddb4c76ce3b1df192c56dd6d7cf2ca5d4c9333f0ff5e72da351b1d4ff6ed4d633e5c66b658b21c43f1a29ddb
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@ If `Rails.environment` (Ruby on Rails) or `ENV["RACK_ENV"]` (e.g. Sinatra) is pr
|
|
22
22
|
|
23
23
|
If you don't want your CI server to raise, make it set the environment variable `DO_NOT_RAISE_FIXMES`. I like having CI raise them, though.
|
24
24
|
|
25
|
+
For simplicity, the date comparison uses machine-local time (not e.g. the Rails configured time zone).
|
26
|
+
|
25
27
|
Protip: make sure it's clear from the exception or from a separate comment just what should be done – sometimes not even the person who wrote the quickfix will remember what you're meant to change.
|
26
28
|
|
27
29
|
This library is an extraction of a helper (originally called `wip_raise`) we tried and liked at [Barsoom](http://barsoom.se).
|
data/lib/fixme.rb
CHANGED
@@ -6,26 +6,50 @@ module Fixme
|
|
6
6
|
|
7
7
|
module Mixin
|
8
8
|
def FIXME(date_and_message)
|
9
|
-
|
9
|
+
# In a separate class to avoid mixing in privates.
|
10
|
+
# http://thepugautomatic.com/2014/02/private-api/
|
11
|
+
Runner.new(date_and_message).run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Runner
|
16
|
+
RUN_ONLY_IN_FRAMEWORK_ENVS = [ "", "test", "development" ]
|
10
17
|
|
11
|
-
|
12
|
-
|
18
|
+
def initialize(date_and_message)
|
19
|
+
@date_and_message = date_and_message
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
return if ENV["DO_NOT_RAISE_FIXMES"]
|
24
|
+
return unless RUN_ONLY_IN_FRAMEWORK_ENVS.include?(framework_env.to_s)
|
13
25
|
|
14
|
-
|
15
|
-
due_date = Date.parse(raw_date)
|
26
|
+
due_date, message = parse
|
16
27
|
|
17
|
-
|
28
|
+
disallow_timecop do
|
18
29
|
if Date.today >= due_date
|
19
30
|
raise UnfixedError, "Fix by #{due_date}: #{message}"
|
20
31
|
end
|
21
|
-
|
32
|
+
end
|
33
|
+
end
|
22
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
def framework_env
|
38
|
+
defined?(Rails) ? Rails.env : ENV["RACK_ENV"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def disallow_timecop(&block)
|
23
42
|
if defined?(Timecop)
|
24
|
-
Timecop.return(&
|
43
|
+
Timecop.return(&block)
|
25
44
|
else
|
26
|
-
|
45
|
+
block.call
|
27
46
|
end
|
28
47
|
end
|
48
|
+
|
49
|
+
def parse
|
50
|
+
raw_date, message = @date_and_message.split(": ", 2)
|
51
|
+
[ Date.parse(raw_date), message ]
|
52
|
+
end
|
29
53
|
end
|
30
54
|
end
|
31
55
|
|
data/lib/fixme/version.rb
CHANGED