wat_catcher 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Guardfile +5 -0
- data/Rakefile +9 -0
- data/lib/wat_catcher/version.rb +1 -1
- data/spec/javascripts/support/jasmine.yml +86 -0
- data/spec/javascripts/wat_catcher_spec.coffee +34 -0
- data/vendor/assets/javascripts/wat_catcher.coffee +27 -13
- data/wat_catcher.gemspec +3 -0
- metadata +58 -5
- data/.idea/scopes/scope_settings.xml +0 -5
- data/.idea/wat_catcher.iml +0 -10
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
wat_catcher
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p195
|
data/Guardfile
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
#guard automatically ignores some directories including vendor
|
2
|
+
ignore! /git/, /bundle/, /log/, /tmp/
|
3
|
+
|
4
|
+
guard 'coffeescript', :input => 'spec/javascripts', :output => 'spec/javascripts/tmp/'
|
5
|
+
guard 'coffeescript', :input => 'vendor/assets/javascripts', :output => 'tmp/vendor/assets/javascripts'
|
data/Rakefile
CHANGED
data/lib/wat_catcher/version.rb
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
# src_files
|
2
|
+
#
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
4
|
+
# Default: []
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_files:
|
9
|
+
# - lib/source1.js
|
10
|
+
# - lib/source2.js
|
11
|
+
# - dist/**/*.js
|
12
|
+
#
|
13
|
+
src_files:
|
14
|
+
- 'tmp/vendor/**/*.js'
|
15
|
+
|
16
|
+
|
17
|
+
# stylesheets
|
18
|
+
#
|
19
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
20
|
+
# Default: []
|
21
|
+
#
|
22
|
+
# EXAMPLE:
|
23
|
+
#
|
24
|
+
# stylesheets:
|
25
|
+
# - css/style.css
|
26
|
+
# - stylesheets/*.css
|
27
|
+
#
|
28
|
+
stylesheets:
|
29
|
+
|
30
|
+
# helpers
|
31
|
+
#
|
32
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
33
|
+
# Default: ["helpers/**/*.js"]
|
34
|
+
#
|
35
|
+
# EXAMPLE:
|
36
|
+
#
|
37
|
+
# helpers:
|
38
|
+
# - helpers/**/*.js
|
39
|
+
#
|
40
|
+
helpers:
|
41
|
+
- 'helpers/**/*.js'
|
42
|
+
# spec_files
|
43
|
+
#
|
44
|
+
# Return an array of filepaths relative to spec_dir to include.
|
45
|
+
# Default: ["**/*[sS]pec.js"]
|
46
|
+
#
|
47
|
+
# EXAMPLE:
|
48
|
+
#
|
49
|
+
# spec_files:
|
50
|
+
# - **/*[sS]pec.js
|
51
|
+
#
|
52
|
+
spec_files:
|
53
|
+
- '**/*[sS]pec.js'
|
54
|
+
|
55
|
+
# src_dir
|
56
|
+
#
|
57
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
58
|
+
# Default: project root
|
59
|
+
#
|
60
|
+
# EXAMPLE:
|
61
|
+
#
|
62
|
+
# src_dir: public
|
63
|
+
#
|
64
|
+
src_dir:
|
65
|
+
|
66
|
+
# spec_dir
|
67
|
+
#
|
68
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
69
|
+
# Default: spec/javascripts
|
70
|
+
#
|
71
|
+
# EXAMPLE:
|
72
|
+
#
|
73
|
+
# spec_dir: spec/javascripts
|
74
|
+
#
|
75
|
+
spec_dir:
|
76
|
+
|
77
|
+
# spec_helper
|
78
|
+
#
|
79
|
+
# Ruby file that Jasmine server will require before starting.
|
80
|
+
# Returned relative to your root path
|
81
|
+
# Default spec/support/jasmine_helper.rb
|
82
|
+
#
|
83
|
+
# EXAMPLE:
|
84
|
+
#
|
85
|
+
# spec_helper: spec/support/jasmine_helper.rb
|
86
|
+
#
|
@@ -0,0 +1,34 @@
|
|
1
|
+
describe "WatCatcher", ->
|
2
|
+
beforeEach ->
|
3
|
+
@errorTarget = {}
|
4
|
+
@errorTarget.onerror = -> "Howdy"
|
5
|
+
@watCatcher = new WatCatcher @errorTarget
|
6
|
+
@watCatcher.appEnvsToWorryAbout = ['production', 'staging', 'demo']
|
7
|
+
@watCatcher.appEnv = 'production'
|
8
|
+
|
9
|
+
@xmlhttp = jasmine.createSpyObj('XMLHttpRequest', ['send', 'setRequestHeader', 'open'])
|
10
|
+
spyOn(window, 'XMLHttpRequest').andReturn(@xmlhttp)
|
11
|
+
|
12
|
+
@msg = 'sadly, there was a terrible mistake'
|
13
|
+
@line = '42'
|
14
|
+
|
15
|
+
it "attaches watHandler to onerror argument", ->
|
16
|
+
@watCatcher.watHandler(@msg, document.URL, @line)
|
17
|
+
expect(@errorTarget.onerror).toEqual @watCatcher.watHandler
|
18
|
+
|
19
|
+
it "preserves previous onerror handler", ->
|
20
|
+
@watCatcher.watHandler(@msg, document.URL, @line)
|
21
|
+
expect(@watCatcher.watHandler()).toEqual "Howdy"
|
22
|
+
|
23
|
+
it "sends xhr on error", ->
|
24
|
+
try
|
25
|
+
window.goobilygoo()
|
26
|
+
catch error
|
27
|
+
@watCatcher.watHandler(error.message, document.URL, error.lineNumber)
|
28
|
+
|
29
|
+
expect(@xmlhttp.send).toHaveBeenCalled()
|
30
|
+
|
31
|
+
it "doesn't send wats in irrelevant appEnv", ->
|
32
|
+
@watCatcher.appEnv = 'development'
|
33
|
+
@watCatcher.watHandler(@msg, document.URL, @line)
|
34
|
+
expect(@xmlhttp.send).not.toHaveBeenCalled()
|
@@ -1,16 +1,30 @@
|
|
1
1
|
#Send the error to the same host that served this file (I think)
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
else
|
6
|
-
new ActiveXObject("Microsoft.XMLHTTP")
|
2
|
+
class @WatCatcher
|
3
|
+
appEnv: undefined
|
4
|
+
appEnvsToWorryAbout: []
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
constructor: (target=window) ->
|
7
|
+
@oldErrorHandler = target.onerror
|
8
|
+
target.onerror = @watHandler
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
watHandler: (msg, url, line) =>
|
11
|
+
if @appEnvsToWorryAbout.indexOf(@appEnv) >= 0
|
12
|
+
xmlhttp = if window.XMLHttpRequest
|
13
|
+
new XMLHttpRequest()
|
14
|
+
else
|
15
|
+
new ActiveXObject("Microsoft.XMLHTTP")
|
16
|
+
|
17
|
+
params = "wat[page_url]=#{escape(window.location.toString())}"
|
18
|
+
params += "&wat[message]=#{escape(msg)}"
|
19
|
+
params += "&wat[backtrace][]=#{escape(url+":"+line)}"
|
20
|
+
params += "&wat[app_env]=#{escape(@appEnv)}"
|
21
|
+
|
22
|
+
xmlhttp.open("POST", "/wats", true);
|
23
|
+
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
24
|
+
xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
25
|
+
xmlhttp.send(params);
|
26
|
+
|
27
|
+
if typeof @oldErrorHandler == 'function'
|
28
|
+
@oldErrorHandler(msg, url, line)
|
29
|
+
|
30
|
+
window.watCatcher = new WatCatcher()
|
data/wat_catcher.gemspec
CHANGED
@@ -20,5 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "jasmine"
|
24
|
+
spec.add_development_dependency "guard-coffeescript"
|
25
|
+
spec.add_development_dependency "rb-readline"
|
23
26
|
spec.add_runtime_dependency 'coffee-rails'
|
24
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wat_catcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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: 2013-06-
|
12
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,6 +43,54 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jasmine
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: guard-coffeescript
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rb-readline
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
46
94
|
- !ruby/object:Gem::Dependency
|
47
95
|
name: coffee-rails
|
48
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,9 +115,10 @@ extensions: []
|
|
67
115
|
extra_rdoc_files: []
|
68
116
|
files:
|
69
117
|
- .gitignore
|
70
|
-
- .
|
71
|
-
- .
|
118
|
+
- .ruby-gemset
|
119
|
+
- .ruby-version
|
72
120
|
- Gemfile
|
121
|
+
- Guardfile
|
73
122
|
- LICENSE.txt
|
74
123
|
- README.md
|
75
124
|
- Rakefile
|
@@ -79,6 +128,8 @@ files:
|
|
79
128
|
- lib/wat_catcher/middleware.rb
|
80
129
|
- lib/wat_catcher/railtie.rb
|
81
130
|
- lib/wat_catcher/version.rb
|
131
|
+
- spec/javascripts/support/jasmine.yml
|
132
|
+
- spec/javascripts/wat_catcher_spec.coffee
|
82
133
|
- vendor/assets/javascripts/wat_catcher.coffee
|
83
134
|
- wat_catcher.gemspec
|
84
135
|
homepage: ''
|
@@ -106,4 +157,6 @@ rubygems_version: 1.8.21
|
|
106
157
|
signing_key:
|
107
158
|
specification_version: 3
|
108
159
|
summary: A gem for registering Wats from your rails app
|
109
|
-
test_files:
|
160
|
+
test_files:
|
161
|
+
- spec/javascripts/support/jasmine.yml
|
162
|
+
- spec/javascripts/wat_catcher_spec.coffee
|
data/.idea/wat_catcher.iml
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="NewModuleRootManager">
|
4
|
-
<content url="file://$MODULE_DIR$" />
|
5
|
-
<orderEntry type="inheritedJdk" />
|
6
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
7
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v0.9.2.2, RVM: ruby-1.9.3-p125 [nodeventdemo]) [gem]" level="application" />
|
8
|
-
</component>
|
9
|
-
</module>
|
10
|
-
|