glitchy_gem 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module GlitchyGem
2
2
  class Glitch
3
- attr_reader :exception
3
+ attr_reader :exception, :cgi_data
4
4
  def initialize(e, options = {})
5
5
  @rack_env = options[:rack_env] || {}
6
6
  @exception = e
@@ -10,6 +10,7 @@ module GlitchyGem
10
10
  controller = options[:controller] || params['controller']
11
11
  action = options[:action] || params['action']
12
12
  session = options[:session] || @rack_env['rack.session']
13
+ @cgi_data = options[:cgi_data] || @rack_env
13
14
 
14
15
  params = filter_params(params)
15
16
 
@@ -17,12 +18,20 @@ module GlitchyGem
17
18
  @http = Net::HTTP.new(@uri.host, @uri.port)
18
19
  @request = Net::HTTP::Post.new(@uri.request_uri)
19
20
  @request["Content-Type"] = "application/json"
20
- @request.body = { :glitch => e.to_hash.merge({ :url => url, :params => params, :controller => controller, :action => action, :session => session, :environment => GlitchyGem.environment }) }.to_json
21
+ @request.body = {
22
+ :glitch => e.to_hash.merge({
23
+ :url => url,
24
+ :params => params,
25
+ :controller => controller,
26
+ :action => action,
27
+ :session => session,
28
+ :environment => GlitchyGem.environment
29
+ })
30
+ }.to_json
21
31
  end
22
32
 
23
33
  def send
24
- return unless GlitchyGem.environments.include?(GlitchyGem.environment)
25
- return if GlitchyGem.ignore_exceptions.include?(self.exception.class.to_s)
34
+ return if ignore?
26
35
  begin
27
36
  @http.request(@request)
28
37
  rescue Errno::ECONNREFUSED => e
@@ -32,6 +41,11 @@ module GlitchyGem
32
41
 
33
42
  private
34
43
 
44
+ def ignore?
45
+ !GlitchyGem.environments.include?(GlitchyGem.environment) ||
46
+ GlitchyGem.filter_exceptions.any? {|filter| filter.call(self) }
47
+ end
48
+
35
49
  def filter_params(params)
36
50
  filter_fields = GlitchyGem.filter_params.map(&:upcase)
37
51
  filtered_params = {}
@@ -20,7 +20,8 @@ module GlitchyGem
20
20
  :session => session.to_hash,
21
21
  :controller => params[:controller],
22
22
  :action => params[:action],
23
- :url => "#{request.protocol}#{request.host}:#{request.port}#{request.request_uri}"
23
+ :url => "#{request.protocol}#{request.host}:#{request.port}#{request.request_uri}",
24
+ :cgi_data => request.env
24
25
  }
25
26
  end
26
27
 
@@ -1,3 +1,3 @@
1
1
  module GlitchyGem
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,130 @@
1
+ !RBIX
2
+ 6235178746665710376
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 28
13
+ 99
14
+ 7
15
+ 0
16
+ 65
17
+ 49
18
+ 1
19
+ 2
20
+ 13
21
+ 99
22
+ 12
23
+ 7
24
+ 2
25
+ 12
26
+ 7
27
+ 3
28
+ 12
29
+ 65
30
+ 12
31
+ 49
32
+ 4
33
+ 4
34
+ 15
35
+ 49
36
+ 2
37
+ 0
38
+ 15
39
+ 2
40
+ 11
41
+ I
42
+ 6
43
+ I
44
+ 0
45
+ I
46
+ 0
47
+ I
48
+ 0
49
+ n
50
+ p
51
+ 5
52
+ x
53
+ 10
54
+ GlitchyGem
55
+ x
56
+ 11
57
+ open_module
58
+ x
59
+ 15
60
+ __module_init__
61
+ M
62
+ 1
63
+ n
64
+ n
65
+ x
66
+ 10
67
+ GlitchyGem
68
+ i
69
+ 12
70
+ 5
71
+ 66
72
+ 65
73
+ 7
74
+ 0
75
+ 7
76
+ 1
77
+ 64
78
+ 49
79
+ 2
80
+ 2
81
+ 11
82
+ I
83
+ 3
84
+ I
85
+ 0
86
+ I
87
+ 0
88
+ I
89
+ 0
90
+ n
91
+ p
92
+ 3
93
+ x
94
+ 7
95
+ VERSION
96
+ s
97
+ 5
98
+ 0.4.0
99
+ x
100
+ 9
101
+ const_set
102
+ p
103
+ 3
104
+ I
105
+ 2
106
+ I
107
+ 2
108
+ I
109
+ c
110
+ x
111
+ 56
112
+ /Users/neevor/src/glitchy_gem/lib/glitchy_gem/version.rb
113
+ p
114
+ 0
115
+ x
116
+ 13
117
+ attach_method
118
+ p
119
+ 3
120
+ I
121
+ 0
122
+ I
123
+ 1
124
+ I
125
+ 1c
126
+ x
127
+ 56
128
+ /Users/neevor/src/glitchy_gem/lib/glitchy_gem/version.rb
129
+ p
130
+ 0
data/lib/glitchy_gem.rb CHANGED
@@ -5,19 +5,24 @@ require 'glitchy_gem/railtie' if defined?(Rails::Railtie)
5
5
 
6
6
  module GlitchyGem
7
7
  class << self
8
- attr_accessor :api_key, :environment, :logger, :url, :environments, :ignore_exceptions, :filter_params
8
+ # These are the attributes a user can set in their config file.
9
+ attr_accessor :api_key, :environment, :logger, :url, :environments, :filter_params, :filter_exceptions
9
10
  def configure
10
- self.filter_params = ["password", "password_confirmation"]
11
-
12
- yield(self)
11
+ self.filter_exceptions ||= [
12
+ lambda{|glitch|
13
+ [
14
+ 'ActiveRecord::RecordNotFound',
15
+ 'ActionController::RoutingError',
16
+ 'ActionController::InvalidAuthenticityToken',
17
+ 'ActionController::UnknownAction'
18
+ ].include?(glitch.exception.class)
19
+ }
20
+ ]
13
21
 
22
+ self.filter_params ||= ["password", "password_confirmation"]
14
23
  self.environments ||= ["production"]
15
- self.ignore_exceptions ||= [
16
- 'ActiveRecord::RecordNotFound',
17
- 'ActionController::RoutingError',
18
- 'ActionController::InvalidAuthenticityToken',
19
- 'ActionController::UnknownAction'
20
- ]
24
+
25
+ yield(self)
21
26
  end
22
27
  end
23
28
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glitchy_gem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - GlitchyApp
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-02 00:00:00 -07:00
18
+ date: 2011-07-16 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -57,6 +57,7 @@ files:
57
57
  - lib/glitchy_gem/rails/action_controller_catcher.rb
58
58
  - lib/glitchy_gem/railtie.rb
59
59
  - lib/glitchy_gem/version.rb
60
+ - lib/glitchy_gem/version.rbc
60
61
  - rails/init.rb
61
62
  has_rdoc: true
62
63
  homepage: http://rubygems.org/gems/glitchy_gem