trackets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57945f5d2b533f59570edf167b351a93f0865ade
4
+ data.tar.gz: 6b9cb0d7cb672064e578814112303c20337a9954
5
+ SHA512:
6
+ metadata.gz: 7452d325e39df95ffa2f4d449fa095cdca8ffea0cad84bdd222253b9b8b312703d69b80e2ee746fba814fa7eff39149c533a4b1bfe020b9bfca00a62ff507c71
7
+ data.tar.gz: 3ccb2799e4bab794ece8d7b060bfa220887b5af9fb74bc14cff7d83e1e42ac2fc092c982e3d9e2ad93959065ab0151825793e3f9d3750e875abb55323884410d
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trackets.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jan Votava
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # Trackets
2
+
3
+ WIP gem for Trackets.com service
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'trackets'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ $ rails g trackets:install API_KEY
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it ( https://github.com/[my-github-username]/trackets/fork )
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,13 @@
1
+ module Trackets
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root ::File.expand_path('../templates', __FILE__)
5
+
6
+ argument :api_key
7
+ desc "Creates Trackets configuration file in config/initializers"
8
+ def install
9
+ template "initializer.rb", "config/initializers/trackets.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ Trackets.setup do |config|
2
+ config.api_key = "<%= @api_key %>"
3
+ end
@@ -0,0 +1,22 @@
1
+ require "trackets/version"
2
+ require "trackets/railtie" if defined?(Rails)
3
+ require "trackets/configuration"
4
+ require "trackets/client"
5
+
6
+ module Trackets
7
+ class << self
8
+
9
+ def setup
10
+ yield(configuration)
11
+ end
12
+
13
+ def configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def notify(exception, env)
18
+ Client.notify(exception, env)
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ module Trackets
2
+ class Backtrace
3
+
4
+ attr_reader :backtrace
5
+
6
+ def initialize(backtrace)
7
+ @backtrace = backtrace
8
+ end
9
+
10
+ def parse
11
+ backtrace.map do |line|
12
+ next if line =~ %r{lib/trackets}
13
+
14
+ line.sub!(Trackets.configuration.project_root, "[PROJECT_ROOT]") if Trackets.configuration.project_root
15
+
16
+ if defined?(Gem)
17
+ Gem.path.inject(line) { |current, path| current.sub(path, "[GEM_ROOT]") }
18
+ end
19
+ end.compact
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,53 @@
1
+ require "httparty"
2
+ require "trackets/backtrace"
3
+
4
+ module Trackets
5
+ class Client
6
+
7
+ include HTTParty
8
+
9
+ class << self
10
+
11
+ def notify(exception, env)
12
+ new(exception, env).send
13
+ end
14
+
15
+ end
16
+
17
+ attr_reader :exception, :env
18
+
19
+ def initialize(exception, env)
20
+ @exception = exception
21
+ @env = env
22
+ end
23
+
24
+ def backtrace
25
+ @backtrace ||= Backtrace.new(exception.backtrace)
26
+ end
27
+
28
+ def whitelisted_env
29
+ env.reject { |k,v| !Trackets.configuration.whitelisted_env.include?(k) }
30
+ end
31
+
32
+ def payload
33
+ {
34
+ language: "ruby",
35
+ message: exception.message,
36
+ class_name: exception.class.to_s,
37
+ stacktrace: backtrace.parse.join("\n"),
38
+ env: whitelisted_env,
39
+ environment_name: config.environment_name,
40
+ project_root: config.project_root,
41
+ framework: config.framework
42
+ }
43
+ end
44
+
45
+ def config
46
+ Trackets.configuration
47
+ end
48
+
49
+ def send
50
+ self.class.post "#{config.api_url}/reports/#{config.api_key}", body: { error: payload }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,37 @@
1
+ module Trackets
2
+ class Configuration
3
+
4
+ DEFAULT_WHITELISTED_ENV_KEYS = [
5
+ "REQUEST_METHOD",
6
+ "PATH_INFO",
7
+ "QUERY_STRING",
8
+ "SCRIPT_NAME",
9
+ "REMOTE_ADDR",
10
+ "SERVER_ADDR",
11
+ "SERVER_NAME",
12
+ "SERVER_PORT",
13
+ "HTTP_HOST",
14
+ "HTTP_CONNECTION",
15
+ "CONTENT_LENGTH",
16
+ "HTTP_ACCEPT",
17
+ "HTTP_ORIGIN",
18
+ "HTTP_USER_AGENT",
19
+ "CONTENT_TYPE",
20
+ "HTTP_REFERER",
21
+ "HTTP_ACCEPT_ENCODING",
22
+ "HTTP_ACCEPT_LANGUAGE",
23
+ "REMOTE_PORT",
24
+ "ORIGINAL_FULLPATH"
25
+ ].freeze
26
+
27
+ DEFAULT_API_URL = "https://trackets.dev"
28
+
29
+ attr_accessor :api_url, :api_key, :environment_name, :project_root, :framework, :whitelisted_env
30
+
31
+ def initialize
32
+ @api_url = DEFAULT_API_URL
33
+ @whitelisted_env = DEFAULT_WHITELISTED_ENV_KEYS
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ module Trackets
2
+ module Middleware
3
+ class RackExceptionHandler
4
+
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ response = @app.call(env)
11
+ rescue RuntimeError => exception
12
+ Trackets.notify(exception, env)
13
+ raise exception
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ require "trackets/view_helpers"
2
+ require "trackets/middleware/rack_exception_handler"
3
+
4
+ module Trackets
5
+ class Railtie < Rails::Railtie
6
+
7
+ initializer "trackets.view_helpers" do
8
+ ActionView::Base.send :include, ViewHelpers
9
+ end
10
+
11
+ initializer "trackets.configure_rails_initialization" do |app|
12
+ after = defined?(ActionDispatch::DebugExceptions) ? "ActionDispatch::DebugExceptions" : "ActionDispatch::ShowExceptions"
13
+
14
+ app.config.middleware.insert_after after, "Trackets::Middleware::RackExceptionHandler"
15
+ end
16
+
17
+ config.after_initialize do
18
+ Trackets.setup do |config|
19
+ config.environment_name ||= ::Rails.env
20
+ config.project_root ||= ::Rails.root.to_s
21
+ config.framework = "Rails: #{::Rails::VERSION::STRING}"
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Trackets
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ module Trackets
2
+ module ViewHelpers
3
+ def trackets_include_tag
4
+ javascript_include_tag "//trackets.s3.amazonaws.com/client.js"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trackets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trackets"
8
+ spec.version = Trackets::VERSION
9
+ spec.authors = ["Jan Votava"]
10
+ spec.email = ["votava@deployment.cz"]
11
+ spec.summary = %q{Trackets.com Ruby support GEM}
12
+ spec.description = %q{Helpers for Trackets.com error tracking service}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "json"
22
+ spec.add_runtime_dependency "httparty", "~> 0.13"
23
+ spec.add_runtime_dependency "rack"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trackets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jan Votava
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Helpers for Trackets.com error tracking service
84
+ email:
85
+ - votava@deployment.cz
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/generators/trackets/install_generator.rb
96
+ - lib/generators/trackets/templates/initializer.rb
97
+ - lib/trackets.rb
98
+ - lib/trackets/backtrace.rb
99
+ - lib/trackets/client.rb
100
+ - lib/trackets/configuration.rb
101
+ - lib/trackets/middleware/rack_exception_handler.rb
102
+ - lib/trackets/railtie.rb
103
+ - lib/trackets/version.rb
104
+ - lib/trackets/view_helpers.rb
105
+ - trackets.gemspec
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Trackets.com Ruby support GEM
130
+ test_files: []