flail 0.1.1 → 0.1.2

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flail (0.0.7)
4
+ flail (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -3,6 +3,14 @@ require 'json'
3
3
 
4
4
  class Flail
5
5
  class Exception
6
+ def self.notify(exception, request_data = {})
7
+ env = {'flail.request' => {'user_agent' => 'internal'}}
8
+
9
+ fe = Flail::Exception.new(env, exception)
10
+ fe.request_data = fe.request_data.merge(request_data)
11
+ fe.handle!
12
+ end
13
+
6
14
  def initialize(env, exception, local = false)
7
15
  @exception = exception
8
16
  @env = env
@@ -32,6 +40,10 @@ class Flail
32
40
  end
33
41
  end
34
42
 
43
+ def request_data=(value)
44
+ @request_data = value
45
+ end
46
+
35
47
  def clean_unserializable_data(data, stack = [])
36
48
  return "[possible infinite recursion halted]" if stack.any? {|item| item == data.object_id}
37
49
 
@@ -110,7 +122,7 @@ class Flail
110
122
  def ignore?
111
123
  # Ignore requests with user agent string matching
112
124
  # this regxp as they are surely made by bots
113
- user_agents = request.respond_to?(:user_agent) ? request.user_agent : @env['HTTP_USER_AGENT']
125
+ user_agents = request.respond_to?(:user_agent) ? request.user_agent : @env['HTTP_USER_AGENT'].to_s
114
126
  if user_agents =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg|Yandex|Jyxobot|Huaweisymantecspider|ApptusBot)\b/i
115
127
  return true
116
128
  end
data/lib/flail/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Flail
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -24,4 +24,8 @@ describe Flail::Exception do
24
24
  end
25
25
  end
26
26
  end
27
+
28
+ it "should be able to accept and generic error with no request attached" do
29
+ lambda { Flail::Exception.notify(Exception.new) }.should_not raise_error
30
+ end
27
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-09-04 00:00:00.000000000 Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack