activetodo 0.0.4 → 0.0.5

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: 2b40f8e450fae6ca97b4f0503463356d3b6f3f2c
4
- data.tar.gz: 7a24f5c2d994679bf7f49407a312a1c8b0298fbc
3
+ metadata.gz: 01a11fd21b937537cbbe408befd6c119794aaba1
4
+ data.tar.gz: ad55f542e79054abf66b6fab387c370afe8bed13
5
5
  SHA512:
6
- metadata.gz: 559f222945e4ca8325331b7eca5bbf1b12893ffbc383493ad0d1e5f407f8bdc0053e29969c687a6e84edb15a44d64e6c6525f792d4ffa6b47829e3bd147118f3
7
- data.tar.gz: 9d005388d995474b866a917edaf358b22f27a28470a162ef5f4d44cd0d340cb58589483a556194daf7acabd06c8c31cde77272ebb6d0e84f9f4ad315c92685a9
6
+ metadata.gz: d47fcbf7aba8e4c42e5783184300d561a584058020ae3600a4ccfc92bf65a6574621271caf99b6ceb50419552aff88cff199adea809396d79ba2c0f746ea7199
7
+ data.tar.gz: 70faa9762a238baef6388004ddbc3907b68947d231ddc53851b57a8064c071cc358277cfc069a35bf9842d4d49d5ced4928ba83c4d9a19772d1d8e8ae8d2ee1b
data/.travis.yml CHANGED
@@ -3,5 +3,4 @@ rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
5
  - jruby-19mode
6
- - rbx-19mode
7
6
  script: bundle exec rspec spec
data/README.md CHANGED
@@ -32,6 +32,10 @@ FIXME 'Certificate will expire soon', deadline: '2014-01-01'
32
32
 
33
33
  # Raises error after 2014-02-28
34
34
  XXX 'Dirty hack, must refactor', deadline: '2014-02-28', warn_only: false
35
+
36
+ # In Rails, if you want it to log warnings in production, use `ignore_production` = false
37
+ # By default it will do nothing in production
38
+ TODO 'Remove unused class LegacyModel', deadline: '2015-01-04', ignore_production: false
35
39
  ```
36
40
 
37
41
  `TODO`, `FIXME` and `XXX` all have same interface: `TODO(<message>, [options_hash])`
@@ -48,6 +52,9 @@ with following lines:
48
52
  ActiveTodo.configure do |config|
49
53
  # Log deadline warnings in Production, raise errors in Development / Test
50
54
  config.warn_only = Rails.env.production?
55
+
56
+ # Allow logging in Rails.env.production (by default it will not do anything)
57
+ config.ignore_production = false
51
58
  end
52
59
  ```
53
60
 
@@ -56,6 +63,10 @@ You can still override the default configuration by passing `warn_only` option:
56
63
  TODO 'Remove this internal testing controller', deadline: '2013-05-01', warn_only: false
57
64
  ```
58
65
 
66
+ ActiveTodo will not do anything in production, unless you provide `ignore_production: false`
67
+ option in your `TODO` calls, or add `config.ignore_production = false` in `ActiveTodo.configure`
68
+ block.
69
+
59
70
  ## Contributing
60
71
 
61
72
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module ActiveTodo
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/activetodo.rb CHANGED
@@ -12,6 +12,15 @@ module ActiveTodo
12
12
  def warn_only=(condition)
13
13
  @@warn_only = condition
14
14
  end
15
+
16
+ def ignore_production?(options = {})
17
+ return options[:ignore_production] if options.keys.include?(:ignore_production)
18
+ @@ignore_production ||= true
19
+ end
20
+
21
+ def ignore_production=(condition)
22
+ @@ignore_production = condition
23
+ end
15
24
  end
16
25
  end
17
26
 
@@ -21,7 +30,10 @@ module ActiveTodo
21
30
 
22
31
  class PrivateMethods
23
32
  class << self
24
- def log_message(message)
33
+ def log_message(message, options)
34
+ if defined?(Rails) && Configuration.ignore_production?(options)
35
+ return if Rails.env.production?
36
+ end
25
37
  if defined?(Rails) && Rails.logger
26
38
  Rails.logger.warn(message)
27
39
  else
@@ -40,7 +52,7 @@ module ActiveTodo
40
52
  message = "Deadline reached for \"#{what}\" (#{options[:deadline]})"
41
53
 
42
54
  if Configuration.warn_only?(options)
43
- PrivateMethods.log_message(message)
55
+ PrivateMethods.log_message(message, options)
44
56
  else
45
57
  raise message
46
58
  end
@@ -76,13 +76,26 @@ describe ActiveTodo::KernelMethods do
76
76
  let(:rails) { double(:rails) }
77
77
  let(:logger) { double(:logger) }
78
78
 
79
- before do
80
- stub_const('Rails', rails)
81
- Rails.should_receive(:logger).twice.and_return(logger)
82
- logger.should_receive(:warn)
79
+ context 'not production' do
80
+ before do
81
+ stub_const('Rails', rails)
82
+ Rails.stub_chain(:env, :production?).and_return(false)
83
+ Rails.should_receive(:logger).twice.and_return(logger)
84
+ logger.should_receive(:warn)
85
+ end
86
+
87
+ specify { expect { subject }.not_to raise_error }
83
88
  end
84
89
 
85
- specify { expect { subject }.not_to raise_error }
90
+ context 'production' do
91
+ before do
92
+ stub_const('Rails', rails)
93
+ Rails.stub_chain(:env, :production?).and_return(true)
94
+ Rails.should_not_receive(:logger)
95
+ end
96
+
97
+ specify { expect { subject }.not_to raise_error }
98
+ end
86
99
  end
87
100
  end
88
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activetodo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Varaneckas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,3 +127,4 @@ summary: Forget 'TOD*' comments that are sitting in your code forever
127
127
  test_files:
128
128
  - spec/activetodo_spec.rb
129
129
  - spec/spec_helper.rb
130
+ has_rdoc: