croket 0.0.1
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.
- checksums.yaml +7 -0
- data/.autotest +25 -0
- data/Gemfile +12 -0
- data/History.txt +6 -0
- data/Manifest.txt +17 -0
- data/README.txt +61 -0
- data/Rakefile +21 -0
- data/bin/croket +3 -0
- data/lib/croket.rb +51 -0
- data/lib/croket/configuration.rb +17 -0
- data/lib/croket/rack.rb +38 -0
- data/lib/croket/rails.rb +24 -0
- data/lib/croket/rails/action_controller_catcher.rb +48 -0
- data/lib/croket/rails/controller_methods.rb +14 -0
- data/lib/croket/rails/middleware.rb +40 -0
- data/lib/croket/railtie.rb +41 -0
- data/lib/croket/version.rb +3 -0
- data/test/test_croket.rb +9 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c144e62c278f13143d315ec0209e53e6176c8263
|
4
|
+
data.tar.gz: 38ad38c0d63240503557b90ec4fbebda1d7c0290
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f7055198d0701fd56421e08ae76900642342c839e44354c588f7730791654a3838e5ddfe1401203b8804b37ddfd973602b1a4d921daecf731fe463635f005aa
|
7
|
+
data.tar.gz: 0a5417145c2afa6de0e2c20107bbd9de15abd5f664de61189efe6e5da992b8aa43fcc96ce05489b0c77db4b8f48a807eef9d6ae61f0135d2bb7ff3a484484c30
|
data/.autotest
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "autotest/restart"
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.testlib = "minitest/unit"
|
7
|
+
#
|
8
|
+
# at.extra_files << "../some/external/dependency.rb"
|
9
|
+
#
|
10
|
+
# at.libs << ":../some/external"
|
11
|
+
#
|
12
|
+
# at.add_exception "vendor"
|
13
|
+
#
|
14
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
15
|
+
# at.files_matching(/test_.*rb$/)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# %w(TestA TestB).each do |klass|
|
19
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
# Autotest.add_hook :run_command do |at|
|
24
|
+
# system "rake build"
|
25
|
+
# end
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
|
4
|
+
|
5
|
+
source "https://rubygems.org/"
|
6
|
+
|
7
|
+
gem "rest-client", "~>0.9"
|
8
|
+
|
9
|
+
gem "rdoc", "~>4.0", :group => [:development, :test]
|
10
|
+
gem "hoe", "~>3.14", :group => [:development, :test]
|
11
|
+
|
12
|
+
# vim: syntax=ruby
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
.autotest
|
2
|
+
History.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
Gemfile
|
7
|
+
bin/croket
|
8
|
+
lib/croket.rb
|
9
|
+
lib/croket/configuration.rb
|
10
|
+
lib/croket/rack.rb
|
11
|
+
lib/croket/rails.rb
|
12
|
+
lib/croket/rails/action_controller_catcher.rb
|
13
|
+
lib/croket/rails/controller_methods.rb
|
14
|
+
lib/croket/rails/middleware.rb
|
15
|
+
lib/croket/railtie.rb
|
16
|
+
lib/croket/version.rb
|
17
|
+
test/test_croket.rb
|
data/README.txt
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= croket
|
2
|
+
|
3
|
+
home :: https://src.sibext.com/ruby/croket
|
4
|
+
code :: git@src.sibext.com:ruby/croket.git
|
5
|
+
rdoc :: FIX (url)
|
6
|
+
bugs :: FIX (url)
|
7
|
+
... etc ...
|
8
|
+
|
9
|
+
== DESCRIPTION:
|
10
|
+
|
11
|
+
Croket for Ruby
|
12
|
+
|
13
|
+
== FEATURES/PROBLEMS:
|
14
|
+
|
15
|
+
* FIX (list of features or problems)
|
16
|
+
|
17
|
+
== SYNOPSIS:
|
18
|
+
|
19
|
+
FIX (code sample of usage)
|
20
|
+
|
21
|
+
== REQUIREMENTS:
|
22
|
+
|
23
|
+
* FIX (list of requirements)
|
24
|
+
|
25
|
+
== INSTALL:
|
26
|
+
|
27
|
+
* FIX (sudo gem install, anything else)
|
28
|
+
|
29
|
+
== DEVELOPERS:
|
30
|
+
|
31
|
+
After checking out the source, run:
|
32
|
+
|
33
|
+
$ rake newb
|
34
|
+
|
35
|
+
This task will install any missing dependencies, run the tests/specs,
|
36
|
+
and generate the RDoc.
|
37
|
+
|
38
|
+
== LICENSE:
|
39
|
+
|
40
|
+
(The MIT License)
|
41
|
+
|
42
|
+
Copyright (c) 2015 Sibext Ltd.
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
45
|
+
a copy of this software and associated documentation files (the
|
46
|
+
'Software'), to deal in the Software without restriction, including
|
47
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to
|
50
|
+
the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be
|
53
|
+
included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
56
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
57
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
58
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
59
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
60
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
61
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
|
6
|
+
# Hoe.plugin :compiler
|
7
|
+
# Hoe.plugin :gem_prelude_sucks
|
8
|
+
# Hoe.plugin :inline
|
9
|
+
# Hoe.plugin :racc
|
10
|
+
# Hoe.plugin :rcov
|
11
|
+
# Hoe.plugin :rdoc
|
12
|
+
Hoe.plugin :bundler
|
13
|
+
Hoe.plugin :gemspec
|
14
|
+
|
15
|
+
Hoe.spec "croket" do
|
16
|
+
developer("Nikolay Moskvin", "moskvin@sibext.com")
|
17
|
+
license "MIT"
|
18
|
+
dependency 'rest-client', '~> 0.9'
|
19
|
+
end
|
20
|
+
|
21
|
+
# vim: syntax=ruby
|
data/bin/croket
ADDED
data/lib/croket.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'croket/version'
|
10
|
+
require 'croket/configuration'
|
11
|
+
require 'croket/railtie' if defined?(Rails)
|
12
|
+
require 'rest_client'
|
13
|
+
|
14
|
+
module Croket
|
15
|
+
|
16
|
+
class << self
|
17
|
+
|
18
|
+
def configure silent = false
|
19
|
+
yield configuration
|
20
|
+
end
|
21
|
+
|
22
|
+
def configuration
|
23
|
+
@configuration ||= Configuration.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def notify exception, opts = {}
|
27
|
+
l = configuration.logger
|
28
|
+
l.debug "[CROKET] notify about '#{exception}' #{opts['rack.errors']}"
|
29
|
+
controller = opts['action_controller.instance']
|
30
|
+
request = ::Rack::Request.new(opts)
|
31
|
+
params = request.env['action_dispatch.request.parameters']
|
32
|
+
version = "Rails/#{::Rails.version}" if defined?(::Rails)
|
33
|
+
r = RestClient::Request.execute url: "http://#{configuration.host}/v1/issues.json", method: :post,
|
34
|
+
payload: {
|
35
|
+
issue: {
|
36
|
+
title: "#{exception}",
|
37
|
+
description: "* *Url*: #{request.url}\n* *Controller*: #{controller.controller_name}\n* *Action*: #{controller.action_name}\n* *Params*: #{params}\n* *Error*: #{exception.backtrace[0]}",
|
38
|
+
category: 'crash',
|
39
|
+
package: configuration.package,
|
40
|
+
environment: configuration.environment,
|
41
|
+
version: version
|
42
|
+
}
|
43
|
+
}, headers: {'Authorization' => "Token token=#{configuration.api_key}"}, content_type: :json, accept: :json
|
44
|
+
r = JSON.parse r
|
45
|
+
l.debug "[CROKET] id: #{r['issue']['id']}, number: #{r['issue']['tracker_number']}, dup: #{r['issue']['duplication']}"
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Croket
|
10
|
+
class Configuration
|
11
|
+
attr_accessor :api_key, :host, :package, :root_path, :logger, :environment
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/croket/rack.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Croket
|
10
|
+
|
11
|
+
class Rack
|
12
|
+
def initialize app
|
13
|
+
@app = app
|
14
|
+
end
|
15
|
+
|
16
|
+
def call env
|
17
|
+
begin
|
18
|
+
response = @app.call env
|
19
|
+
rescue Exception => e
|
20
|
+
notify_croket env, e
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
if framework_exception = env["action_dispatch.exception"]
|
24
|
+
notify_croket env, framework_exception
|
25
|
+
end
|
26
|
+
response
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def notify_croket env, e
|
32
|
+
Croket.notify e, env
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/croket/rails.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Croket
|
10
|
+
module Rails
|
11
|
+
def self.initialize
|
12
|
+
if defined?(ActionController::Base)
|
13
|
+
ActionController::Base.send(:include, Croket::Rails::ActionControllerCatcher)
|
14
|
+
ActionController::Base.send(:include, Croket::Rails::ControllerMethods)
|
15
|
+
end
|
16
|
+
if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
|
17
|
+
::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',
|
18
|
+
Croket::Rack
|
19
|
+
#::Rails.configuration.middleware.insert_after 'Rack::Lock',
|
20
|
+
# Hahulya::UserInformer
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Croket
|
10
|
+
module Rails
|
11
|
+
module ActionControllerCatcher
|
12
|
+
|
13
|
+
def self.included(base)
|
14
|
+
if base.method_defined?(:rescue_action_in_public)
|
15
|
+
base.send(:alias_method, :rescue_action_in_public_without_croket, :rescue_action_in_public)
|
16
|
+
base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_croket)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
KINDS = [:commit, :rollback].freeze
|
21
|
+
|
22
|
+
def run_callbacks(kind, *args, &block)
|
23
|
+
if KINDS.include?(kind)
|
24
|
+
begin
|
25
|
+
super
|
26
|
+
rescue StandardError => exception
|
27
|
+
# This exception will NOT be escalated, so notify it here.
|
28
|
+
Croket.notify(exception, nil)
|
29
|
+
raise
|
30
|
+
end
|
31
|
+
else
|
32
|
+
# Let the post process handle the exception
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# Overrides the rescue_action method in ActionController::Base, but does not inhibit
|
40
|
+
# any custom processing that is defined with Rails 2's exception helpers.
|
41
|
+
def rescue_action_in_public_with_hahulya(exception)
|
42
|
+
error_id = Croket.notify(exception, hahulya_request_data)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Croket
|
10
|
+
module Rails
|
11
|
+
class Middleware
|
12
|
+
|
13
|
+
def initialize app
|
14
|
+
@app = app
|
15
|
+
end
|
16
|
+
|
17
|
+
def call env
|
18
|
+
begin
|
19
|
+
response = @app.call env
|
20
|
+
rescue Exception => e
|
21
|
+
notify_croket env, e
|
22
|
+
raise e
|
23
|
+
end
|
24
|
+
if framework_exception = env["action_dispatch.exception"]
|
25
|
+
notify_croket env, framework_exception
|
26
|
+
end
|
27
|
+
#p env["rack.errors"], env["action_dispatch.show_exceptions"], env["action_dispatch.show_detailed_exceptions"]
|
28
|
+
p env.keys.select {|i| i.include? 'exception' or i.include? 'err'}
|
29
|
+
response
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def notify_croket env, e
|
35
|
+
Croket.notify e, env
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Created on 2015-04-08
|
4
|
+
|
5
|
+
@author: Nikolay Moskvin <moskvin@sibext.com>
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'rails'
|
10
|
+
require 'croket/rails/middleware'
|
11
|
+
|
12
|
+
module Croket
|
13
|
+
|
14
|
+
class Railtie < ::Rails::Railtie
|
15
|
+
initializer 'croket.middleware' do |app|
|
16
|
+
|
17
|
+
middleware = if defined?(ActionDispatch::DebugExceptions)
|
18
|
+
# Rails >= 3.2.0
|
19
|
+
"ActionDispatch::DebugExceptions"
|
20
|
+
else
|
21
|
+
# Rails < 3.2.0
|
22
|
+
"ActionDispatch::ShowExceptions"
|
23
|
+
end
|
24
|
+
|
25
|
+
app.config.middleware.insert_after middleware, "Croket::Rails::Middleware"
|
26
|
+
#app.config.middleware.insert 0, "Croket::Rails::Middleware"
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after_initialize do
|
30
|
+
ActiveSupport.on_load(:action_controller) do
|
31
|
+
# Lazily load action_controller methods
|
32
|
+
#
|
33
|
+
require 'croket/rails/controller_methods'
|
34
|
+
|
35
|
+
include Croket::Rails::ControllerMethods
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/test/test_croket.rb
ADDED
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: croket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Moskvin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.14'
|
55
|
+
description: Croket for Ruby
|
56
|
+
email:
|
57
|
+
- moskvin@sibext.com
|
58
|
+
executables:
|
59
|
+
- croket
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- History.txt
|
63
|
+
- Manifest.txt
|
64
|
+
- README.txt
|
65
|
+
files:
|
66
|
+
- ".autotest"
|
67
|
+
- Gemfile
|
68
|
+
- History.txt
|
69
|
+
- Manifest.txt
|
70
|
+
- README.txt
|
71
|
+
- Rakefile
|
72
|
+
- bin/croket
|
73
|
+
- lib/croket.rb
|
74
|
+
- lib/croket/configuration.rb
|
75
|
+
- lib/croket/rack.rb
|
76
|
+
- lib/croket/rails.rb
|
77
|
+
- lib/croket/rails/action_controller_catcher.rb
|
78
|
+
- lib/croket/rails/controller_methods.rb
|
79
|
+
- lib/croket/rails/middleware.rb
|
80
|
+
- lib/croket/railtie.rb
|
81
|
+
- lib/croket/version.rb
|
82
|
+
- test/test_croket.rb
|
83
|
+
homepage: https://src.sibext.com/ruby/croket
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- "--main"
|
90
|
+
- README.txt
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.4.5.1
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Croket for Ruby
|
109
|
+
test_files: []
|