fixme 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f17c8f6e1e7bf078eb5aecf0ff123ff697518798
4
- data.tar.gz: 9d4e88a2b29c7be13ab6744dc3a90cfa1a71f251
3
+ metadata.gz: 7e1ab3e11f1dd62c6d26791d1278dc0f1b0da2b4
4
+ data.tar.gz: 6b702750cb9cf2598a711e0d99be151d56c1bde5
5
5
  SHA512:
6
- metadata.gz: 22bed2eda72ded7cda30319e24aa4e80f1cb76583c65ed456871fd71b4a0e9470bec39c3a1f5846655c4803a28ac91e21956bf48d1435c29d035e215389c7431
7
- data.tar.gz: d664dc80938522c5d978b30bccbf34b0e2e01f0f7dbb147deced872daf2e5a4fd3b9f7b8b7ef914f7f6354fbd3e88a221d057b8e339c2790e256ebcb374cc45f
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 |message|
42
- YourOwnCodeOrSomeLibrary.email_developers(message)
43
- YourOwnCodeOrSomeLibrary.notify_chat(message)
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
- If you want the parsed date and the message separately, do:
43
+ There's also `details.date`, `details.message` and `details.backtrace`.
48
44
 
49
- ```
50
- Fixme.explode_with do |_, date, message|
51
- YourOwnCodeOrSomeLibrary.log(date, message)
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
- class UnfixedError < StandardError; end
5
+ UnfixedError = Class.new(StandardError)
6
+ Details = Struct.new(:full_message, :backtrace, :date, :message)
6
7
 
7
- DEFAULT_EXPLODER = proc { |message| raise(UnfixedError, message) }
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
- @explode_with.call(full_message, date, message)
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
- RUN_ONLY_IN_FRAMEWORK_ENVS = [ "", "test", "development" ]
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 RUN_ONLY_IN_FRAMEWORK_ENVS.include?(framework_env.to_s)
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
@@ -1,3 +1,3 @@
1
1
  module Fixme
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.0"
3
3
  end
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
- context "configuring an alternative to raising" do
102
- it "lets you provide a block" do
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
- FIXME "2013-12-31: Do not explode."
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
- it "lets the block take a subset of parameters" do
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
- FIXME "2013-12-31: Do not explode."
126
-
127
- expect(log.last).to eq "Fix by 2013-12-31: Do not explode."
128
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh