github_deprecations 0.0.2 → 0.0.3

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.0.3
2
+
3
+ * improve error messages
4
+ * fail gracefully when redis unavailable
5
+
1
6
  ## 0.0.2
2
7
 
3
8
  * errors in configuration will warn, but not raise errors
@@ -11,7 +11,7 @@ module GithubDeprecations
11
11
  blk.call(config) if blk
12
12
  config
13
13
  rescue ArgumentError => e
14
- $stderr.puts "Missing config parameters for GithubDeprecations"
14
+ $stderr.puts "WARNING: Missing config parameters for GithubDeprecations"
15
15
  Noop.new
16
16
  end
17
17
  module_function :configure
@@ -35,13 +35,21 @@ module GithubDeprecations
35
35
  # For each deprecation, enqueue a background job
36
36
  # to create or update an issue.
37
37
  def register!
38
+ @original_behavior = ActiveSupport::Deprecation.behavior
38
39
  ActiveSupport::Deprecation.behavior = :notify
39
40
  @subscriber = ActiveSupport::Notifications.subscribe(@subscribe) do |*args|
40
- Resque.enqueue Worker, self, args
41
+ begin
42
+ Resque.enqueue Worker, self, args
43
+ rescue Errno::ECONNREFUSED => e
44
+ # unable to connect to redis, revert to default behavior
45
+ $stderr.puts "WARNING: Unable to connect to redis for GithubDeprecations"
46
+ reset!
47
+ end
41
48
  end
42
49
  end
43
50
 
44
51
  def reset!
52
+ ActiveSupport::Deprecation.behavior = @original_behavior if @original_behavior
45
53
  ActiveSupport::Notifications.unsubscribe(@subscriber) if @subscriber
46
54
  end
47
55
  end
@@ -1,3 +1,3 @@
1
1
  module GithubDeprecations
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -15,11 +15,26 @@ class GithubDeprecationsTest < Test::Unit::TestCase
15
15
  output = capture_stderr do
16
16
  GithubDeprecations.configure
17
17
  end
18
- assert_equal output, "Missing config parameters for GithubDeprecations\n"
18
+ assert_equal output, "WARNING: Missing config parameters for GithubDeprecations\n"
19
19
  end
20
20
 
21
21
  def test_configure_fails_noop
22
22
  # shouldn't raise no method error
23
- GithubDeprecations.configure.register!
23
+ capture_stderr do
24
+ GithubDeprecations.configure.register!
25
+ end
26
+ end
27
+
28
+ def test_redis_unavailable_resets
29
+ Resque.expects(:enqueue).raises(Errno::ECONNREFUSED)
30
+ output = capture_stderr do
31
+ GithubDeprecations.configure({
32
+ :login => 'some_login',
33
+ :oauth_token => 'some_token',
34
+ :repo => 'some/repo'
35
+ }).register!
36
+ ActiveSupport::Deprecation.warn "Roh oh"
37
+ end
38
+ assert_equal output, "WARNING: Unable to connect to redis for GithubDeprecations\n"
24
39
  end
25
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_deprecations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport