bugsify 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14517552fa77ab0f3223d16146a1f73bee88cdf16acad2385891c5df0c9db362
4
- data.tar.gz: 4641664b93a5d12434cad5e3033f528ba02997d08415e6f1777b26da18dec322
3
+ metadata.gz: 85caf0bd205a532ee78258e22eb3b6b20e7079b7a413ded72837717187297cc7
4
+ data.tar.gz: 43da62d201e63ff5dc1187953bd2f81a49e2aa2f85f0859e2faee1cad1d18280
5
5
  SHA512:
6
- metadata.gz: e1dc9c90d6619196ccddc86eb05ec5f555b6996c9e66a0e32b746f884f02c8e64260bdf8859aa249a82f256ac45d44424e50d20c34ac49931a60195c8819b477
7
- data.tar.gz: 1197180e153c21b48d318fa0af21883dfa6cb9e42787b0d560d6931cf338ce641fc38e12f34ba1540676d4e5f395e6e28d4c15c90d3b9807dda7c4a28efbdf76
6
+ metadata.gz: 362505cd1565d01bc6c27d9603544641c159d2981e8e62ecd5935f79aac1948adc5754b64012d888fedc35dbf3a333a11bb7d010b678fdf95f22e6ae830a1418
7
+ data.tar.gz: 83ee8cfdee730f5b65a07c9aa431e118b5bbeed36ccd37c1a41bdc3f752a355127cbc09be9b52ab357881a942deee7fac30527abb7ecd1c0c9923d0da5231370
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bugsify (1.0.2)
4
+ bugsify (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bugsify.gemspec CHANGED
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/bugsify/version"
3
+ require_relative "lib/bugsify/config/config"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "bugsify"
7
- spec.version = Bugsify::VERSION
8
- spec.authors = ["Aleksandar Popovic"]
9
- spec.email = ["aleksandar.popovic@hotmail.com"]
6
+ spec.name = Bugsify::Config::NAME
7
+ spec.version = Bugsify::Config::VERSION
8
+ spec.authors = Bugsify::Config::AUTHORS
9
+ spec.email = Bugsify::Config::EMAIL
10
10
 
11
- spec.summary = "Ruby notifier for bugsify.io"
12
- spec.description = "Bugsify error monitoring & exception reporter for Ruby"
13
- spec.homepage = "https://github.com/bugsify/bugsify_ruby"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
11
+ spec.summary = Bugsify::Config::SUMMARY
12
+ spec.description = Bugsify::Config::DESCRIPTION
13
+ spec.homepage = Bugsify::Config::HOMEPAGE
14
+ spec.license = Bugsify::Config::LICENSE
15
+ spec.required_ruby_version = Bugsify::Config::REQUIRED_RUBY_VERSION
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/bugsify/bugsify_ruby"
19
- spec.metadata["changelog_uri"] = "https://github.com/bugsify/bugsify_ruby/blob/main/CHANGELOG.md"
18
+ spec.metadata["source_code_uri"] = Bugsify::Config::SOURCE_CODE_URI
19
+ spec.metadata["changelog_uri"] = Bugsify::Config::CHANGELOG_URI
20
20
 
21
21
  spec.files = Dir.chdir(__dir__) do
22
22
  `git ls-files -z`.split("\x0").reject do |f|
File without changes
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bugsify
4
+ # Config
5
+ module Config
6
+ def self.included(host_class)
7
+ host_class.extend ClassMethods
8
+ end
9
+
10
+ # ClassMethods
11
+ module ClassMethods
12
+ def config
13
+ @config ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield config
18
+ end
19
+ end
20
+
21
+ extend ClassMethods
22
+
23
+ # Configuration
24
+ class Configuration
25
+ attr_accessor :api_key
26
+ end
27
+
28
+ specs = {
29
+ name: "bugsify",
30
+ version: "1.0.5",
31
+ authors: ["Aleksandar Popovic"],
32
+ email: ["aleksandar.popovic@hotmail.com"],
33
+ summary: "Ruby notifier for bugsify.io",
34
+ description: "Bugsify error monitoring & exception reporter for Ruby",
35
+ homepage: "https://github.com/bugsify/bugsify_ruby",
36
+ license: "MIT",
37
+ required_ruby_version: ">= 2.6.0",
38
+ source_code_uri: "https://github.com/bugsify/bugsify_ruby",
39
+ changelog_uri: "https://github.com/bugsify/bugsify_ruby/blob/main/CHANGELOG.md"
40
+ }
41
+
42
+ specs.each { |k, v| const_set(k.upcase, v) }
43
+ end
44
+ end
@@ -2,13 +2,12 @@
2
2
 
3
3
  if Gem.loaded_specs.key?("rails")
4
4
  require "rails"
5
- require_relative "../middlewares/rails"
6
5
 
7
6
  module Bugsify
8
7
  # BugsifyEngine
9
8
  class BugsifyEngine < Rails::Engine
10
9
  initializer "bugsify_engine.add_middleware" do |app|
11
- app.middleware.use Bugsify::Middleware::Rails
10
+ app.middleware.use Middleware
12
11
  end
13
12
  end
14
13
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bugsify
4
+ # Middleware
5
+ class Middleware
6
+ include Parser
7
+
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ @app.call(env)
14
+ rescue Exception => e
15
+ Gem.loaded_specs.key?("rails") ? rails(e) : rack(e)
16
+ end
17
+ end
18
+ end
@@ -3,8 +3,19 @@
3
3
  module Bugsify
4
4
  # Error
5
5
  module Notifier
6
+ include Client
7
+ include Parser
8
+
9
+ def capture_exception(exception)
10
+ raise "Argument #{exception} is not exception" unless exception.is_a?(Exception)
11
+
12
+ manual(exception)
13
+ end
14
+
15
+ private
16
+
6
17
  # rubocop:disable Metrics/MethodLength
7
- def auto_notify(args = {})
18
+ def auto_capture_exception(args = {})
8
19
  params = {
9
20
  errorClass: args[:errorClass],
10
21
  errorBacktrace: args[:errorBacktrace],
@@ -13,7 +24,7 @@ module Bugsify
13
24
  applicationEnvironment: args[:applicationEnvironment]
14
25
  }
15
26
 
16
- Bugsify::Client::Api.new.request(
27
+ Api.new.request(
17
28
  "collectors/ruby",
18
29
  "Post",
19
30
  params,
@@ -22,8 +33,6 @@ module Bugsify
22
33
  end
23
34
  # rubocop:enable Metrics/MethodLength
24
35
 
25
- private
26
-
27
36
  def parse(response)
28
37
  puts response
29
38
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "debug"
4
+
5
+ module Bugsify
6
+ # Rails
7
+ module Parser
8
+ include Reporter
9
+
10
+ def rails(e)
11
+ trace = e.backtrace.select { |l| l.start_with?(Rack::Directory.new("").root) }.join("\n ")
12
+ payload = {
13
+ error_class: e.class,
14
+ error_backtrace: "\n#{e.class}\n#{e.message}\n#{trace}",
15
+ error_full_backtrace: e.backtrace.select { |l| l }.join("\n "),
16
+ runtime_version: runtime_version
17
+ }
18
+ report(payload)
19
+ raise e
20
+ end
21
+
22
+ def rack(e)
23
+ payload = {
24
+ error_class: e.class,
25
+ error_backtrace: e,
26
+ error_full_backtrace: "\n#{e.class}\n#{e.message}\n#{e}",
27
+ runtime_version: runtime_version
28
+ }
29
+ report(payload)
30
+ raise e
31
+ end
32
+
33
+ def manual(e)
34
+ debugger
35
+ payload = {
36
+ error_class: e.class,
37
+ error_backtrace: e,
38
+ runtime_version: runtime_version
39
+ }
40
+ report(payload)
41
+ raise e
42
+ end
43
+
44
+ private
45
+
46
+ def runtime_version
47
+ {
48
+ ruby_version: RUBY_VERSION,
49
+ ruby_release_date: RUBY_RELEASE_DATE,
50
+ ruby_platform: RUBY_PLATFORM,
51
+ load_path: $LOAD_PATH,
52
+ env: ENV
53
+ }
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bugsify
4
+ # Rack
5
+ module Reporter
6
+ # @param [Object] event
7
+ def report(event)
8
+ Bugsify.send(:auto_capture_exception, {
9
+ errorClass: event[:error_class],
10
+ errorBacktrace: event[:error_backtrace],
11
+ errorFullBacktrace: event[:error_full_backtrace],
12
+ runtimeVersion: event[:runtime_version],
13
+ applicationEnvironment: ENV.fetch("RACK_ENV", nil)
14
+ })
15
+ end
16
+ end
17
+ end
data/lib/bugsify.rb CHANGED
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bugsify/version"
4
- require "bugsify/config"
5
- require "bugsify/client"
6
- require "bugsify/notifier"
7
- require "bugsify/engines/bugsify" if Gem.loaded_specs.key?("rails")
8
- require "bugsify/middlewares/rails" if Gem.loaded_specs.key?("rails")
9
- require "bugsify/middlewares/sinatra" if Gem.loaded_specs.key?("sinatra")
10
- require "bugsify/middlewares/padrino" if Gem.loaded_specs.key?("padrino")
3
+ require "bugsify/config/config"
4
+ require "bugsify/client/client"
5
+ require "bugsify/reporter/reporter"
6
+ require "bugsify/parser/parser"
7
+ require "bugsify/middleware/middleware"
8
+ require "bugsify/notifier/notifier"
9
+ require "bugsify/engine/bugsify"
11
10
 
12
11
  # Bugsify
13
12
  module Bugsify
14
13
  include Config
15
14
  include Client
15
+ include Reporter
16
+ include Parser
16
17
  extend Notifier
17
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandar Popovic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Bugsify error monitoring & exception reporter for Ruby
14
14
  email:
@@ -32,18 +32,14 @@ files:
32
32
  - Rakefile
33
33
  - bugsify.gemspec
34
34
  - lib/bugsify.rb
35
- - lib/bugsify/client.rb
36
- - lib/bugsify/config.rb
37
- - lib/bugsify/engines/bugsify.rb
38
- - lib/bugsify/middlewares/padrino.rb
39
- - lib/bugsify/middlewares/rails.rb
40
- - lib/bugsify/middlewares/sinatra.rb
41
- - lib/bugsify/notifier.rb
42
- - lib/bugsify/reporters/rack.rb
43
- - lib/bugsify/reporters/rails.rb
44
- - lib/bugsify/version.rb
35
+ - lib/bugsify/client/client.rb
36
+ - lib/bugsify/config/config.rb
37
+ - lib/bugsify/engine/bugsify.rb
38
+ - lib/bugsify/middleware/middleware.rb
39
+ - lib/bugsify/notifier/notifier.rb
40
+ - lib/bugsify/parser/parser.rb
41
+ - lib/bugsify/reporter/reporter.rb
45
42
  - lib/generators/bugsify/install_generator.rb
46
- - sig/bugsify.rbs
47
43
  homepage: https://github.com/bugsify/bugsify_ruby
48
44
  licenses:
49
45
  - MIT
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bugsify
4
- # Config
5
- module Config
6
- def self.included(host_class)
7
- host_class.extend ClassMethods
8
- end
9
-
10
- # ClassMethods
11
- module ClassMethods
12
- def config
13
- @config ||= Configuration.new
14
- end
15
-
16
- def configure
17
- yield config
18
- end
19
- end
20
-
21
- extend ClassMethods
22
-
23
- class Configuration
24
- attr_accessor :api_key
25
- end
26
- end
27
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Gem.loaded_specs.key?("padrino")
4
- require_relative "../reporters/rack"
5
-
6
- module Bugsify
7
- module Middleware
8
- # Padrino
9
- class Padrino
10
- include Bugsify::Reporter::Rack
11
-
12
- def initialize(app)
13
- @app = app
14
- end
15
-
16
- # rubocop:disable Metrics/MethodLength
17
- # rubocop:disable Lint/RescueException
18
- def call(env)
19
- @app.call(env)
20
- rescue Exception => e
21
- payload = {
22
- error_class: e.class,
23
- error_backtrace: e,
24
- error_full_backtrace: "\n#{e.class}\n#{e.message}\n#{e}",
25
- runtime_version: {
26
- padrino: Gem.loaded_specs["padrino"].version,
27
- rack: Gem.loaded_specs["rake"].version,
28
- ruby: RUBY_VERSION
29
- }
30
- }
31
- notify(payload)
32
- raise e
33
- end
34
- # rubocop:enable Metrics/MethodLength
35
- # rubocop:enable Lint/RescueException
36
- end
37
- end
38
- end
39
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Gem.loaded_specs.key?("rails")
4
- require_relative "../reporters/rails"
5
-
6
- module Bugsify
7
- module Middleware
8
- # Rails
9
- class Rails
10
- include Bugsify::Reporter::Rails
11
-
12
- def initialize(app)
13
- @app = app
14
- end
15
-
16
- # rubocop:disable Metrics/MethodLength
17
- # rubocop:disable Lint/RescueException
18
- # rubocop:disable Metrics/AbcSize
19
- def call(env)
20
- @app.call(env)
21
- rescue Exception => e
22
- trace = e.backtrace.select { |l| l.start_with?(Rack::Directory.new("").root) }.join("\n ")
23
- payload = {
24
- error_class: e.class,
25
- error_backtrace: "\n#{e.class}\n#{e.message}\n#{trace}",
26
- error_full_backtrace: e.backtrace.select { |l| l }.join("\n "),
27
- runtime_version: {
28
- rails: Gem.loaded_specs["rails"].version,
29
- rack: Gem.loaded_specs["rake"].version,
30
- ruby: RUBY_VERSION
31
- }
32
- }
33
- notify(payload)
34
- raise e
35
- end
36
- # rubocop:enable Metrics/MethodLength
37
- # rubocop:enable Lint/RescueException
38
- # rubocop:enable Metrics/AbcSize
39
- end
40
- end
41
- end
42
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Gem.loaded_specs.key?("sinatra")
4
- require_relative "../reporters/rack"
5
-
6
- module Bugsify
7
- module Middleware
8
- # Sinatra
9
- class Sinatra
10
- include Bugsify::Reporter::Rack
11
-
12
- def initialize(app)
13
- @app = app
14
- end
15
-
16
- # rubocop:disable Metrics/MethodLength
17
- # rubocop:disable Lint/RescueException
18
- def call(env)
19
- @app.call(env)
20
- rescue Exception => e
21
- payload = {
22
- error_class: e.class,
23
- error_backtrace: e,
24
- error_full_backtrace: "\n#{e.class}\n#{e.message}\n#{e}",
25
- runtime_version: {
26
- padrino: Gem.loaded_specs["sinatra"].version,
27
- rack: Gem.loaded_specs["rake"].version,
28
- ruby: RUBY_VERSION
29
- }
30
- }
31
- notify(payload)
32
- raise e
33
- end
34
- # rubocop:enable Metrics/MethodLength
35
- # rubocop:enable Lint/RescueException
36
- end
37
- end
38
- end
39
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bugsify
4
- module Reporter
5
- # Rack
6
- module Rack
7
- def notify(event)
8
- Bugsify.auto_notify({
9
- errorClass: event[:error_class],
10
- errorBacktrace: event[:error_backtrace],
11
- errorFullBacktrace: event[:error_full_backtrace],
12
- runtimeVersion: event[:runtime_version],
13
- applicationEnvironment: ENV["RACK_ENV"]
14
- })
15
- end
16
- end
17
- end
18
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bugsify
4
- module Reporter
5
- # Rails
6
- module Rails
7
- # rubocop:disable Metrics/MethodLength
8
- def notify(event)
9
- semaphore = Thread::Mutex.new
10
-
11
- Thread.new do
12
- semaphore.synchronize do
13
- Bugsify.auto_notify({
14
- errorClass: event[:error_class],
15
- errorBacktrace: event[:error_backtrace],
16
- errorFullBacktrace: event[:error_full_backtrace],
17
- runtimeVersion: event[:runtime_version],
18
- applicationEnvironment: ENV["RACK_ENV"]
19
- })
20
- end
21
- end
22
- end
23
- # rubocop:enable Metrics/MethodLength
24
- end
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bugsify
4
- VERSION = "1.0.3"
5
- end
data/sig/bugsify.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Bugsify
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end