exception_notification_telegram 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b12ecde6c8da572aae68af5c2a297b861e94c2bf192f7401269382e95f81403
4
- data.tar.gz: 314ae01ea23de43955780c3bc3b90135a78c46d3321a35a10df9d59e06eb3fa0
3
+ metadata.gz: 62a118bad5770bf6eb912ff15cba1b755f7720e5b5f2ce88e74e53ca2c65dd30
4
+ data.tar.gz: 2b956de041c904f901fdcacd10608f51695269bc954889885d2712fd47b6cad1
5
5
  SHA512:
6
- metadata.gz: ec0839595c9875e0e4e6e12f5ec02e50815440cab99b1e56a385bee8d7302c0e78667eaacbb9c731cd1c145a5e94fcffe0c1b19ac697059bf37a0774443dca7c
7
- data.tar.gz: 3704ffa3c5a7003351077f6f63a874ef0946e71cc2a5705cb9d18dab3408a2b90739d87a42b548914602b3376a2722cc41fee2dc1322f00a4ecec02b3161f4a6
6
+ metadata.gz: 3f2c9474d6f6aaf380f17e9e2de893a96a1d0b17f5ac0760a83836b3eaf9eb869021aac21288e452a46bd8578c82fe8dc39d4094047343e628564a5d7e7bc717
7
+ data.tar.gz: e9d5c05ce05a5ecf8ef0b926e78df05f723f62507ff79154eb6158fa56cb2d3fcfe9c4cae022038aaf7bef05352d278ee80e665bce63f41595708fbe042579c3
@@ -3,12 +3,12 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.3.6
7
- - 2.4.3
6
+ - 2.4.7
8
7
  - 2.5.0
8
+ - 2.6.0
9
9
  before_install:
10
10
  - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
11
- - gem install bundler -v 1.17.3
11
+ - gem install bundler -v '< 2'
12
12
 
13
13
  install:
14
14
  - bundle install --jobs=3 --retry=3
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Exception Notification - Telegram Notifier
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/exception_notification_telegram.svg)](https://badge.fury.io/rb/exception_notification_telegram)
3
4
  [![Build Status](https://travis-ci.com/iaguirre88/exception_notification_telegram.svg?branch=master)](https://travis-ci.com/iaguirre88/exception_notification_telegram)
4
5
 
5
6
  ---
@@ -8,7 +8,7 @@ gemfile do
8
8
  source 'https://rubygems.org'
9
9
 
10
10
  gem 'rails', '5.0.0'
11
- gem 'exception_notification', '4.3.0'
11
+ gem 'exception_notification', '4.4.0'
12
12
  gem 'exception_notification_telegram', path: '../../exception_notification_telegram'
13
13
  end
14
14
 
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/iaguirre88/exception_notification_telegram"
14
14
  spec.license = "MIT"
15
15
 
16
+ spec.required_ruby_version = '~> 2.4'
17
+
16
18
  # Specify which files should be added to the gem when it is released.
17
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
20
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -23,9 +25,9 @@ Gem::Specification.new do |spec|
23
25
  spec.require_paths = ["lib"]
24
26
 
25
27
  spec.add_development_dependency "bundler", "~> 1.17"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "rake", "~> 12.3"
29
+ spec.add_development_dependency "rspec", "~> 3.8"
28
30
 
29
- spec.add_dependency "exception_notification", "~> 4.3"
30
- spec.add_dependency "httparty", "~> 0.10.2"
31
+ spec.add_dependency "exception_notification", "~> 4.4"
32
+ spec.add_dependency "httparty", "~> 0.13.2"
31
33
  end
@@ -1,3 +1,4 @@
1
+ require 'exception_notification'
1
2
  require 'exception_notification_telegram/version'
2
3
  require 'httparty'
3
4
  require 'json'
@@ -15,6 +16,8 @@ module ExceptionNotifier
15
16
  @options = options
16
17
  @exception = exception
17
18
 
19
+ @formatter = Formatter.new(exception, options)
20
+
18
21
  url = "https://api.telegram.org/bot#{@token}/sendMessage"
19
22
  HTTParty.post(url, httparty_options)
20
23
  end
@@ -38,77 +41,26 @@ module ExceptionNotifier
38
41
 
39
42
  def message
40
43
  text = [
41
- header,
44
+ "\nApplication: *#{@formatter.app_name || 'N/A'}*",
45
+ @formatter.subtitle,
42
46
  '',
43
- "⚠️ Error 500 in #{defined?(Rails) ? Rails.env : 'N/A'} ⚠️",
47
+ @formatter.title,
44
48
  "*#{exception.message.tr('`', "'")}*"
45
49
  ]
46
50
 
47
- text += message_request
48
- text += message_backtrace
49
-
50
- text.join("\n")
51
- end
52
-
53
- def header
54
- text = ["\nApplication: *#{app_name}*"]
55
-
56
- errors_text = errors_count > 1 ? errors_count : 'An'
57
- text << "#{errors_text} *#{exception.class}* occured#{controller_text}."
58
-
59
- text
60
- end
61
-
62
- def message_request
63
- return [] unless (env = options[:env])
64
-
65
- request = ActionDispatch::Request.new(env)
66
-
67
- [
68
- '',
69
- '*Request:*',
70
- '```',
71
- "* url : #{request.original_url}",
72
- "* http_method : #{request.method}",
73
- "* ip_address : #{request.remote_ip}",
74
- "* parameters : #{request.filtered_parameters}",
75
- "* timestamp : #{Time.current}",
76
- '```'
77
- ]
78
- end
51
+ if (request = @formatter.request_message.presence)
52
+ text << ''
53
+ text << '*Request:*'
54
+ text << request
55
+ end
79
56
 
80
- def message_backtrace
81
- backtrace = exception.backtrace
57
+ if (backtrace = @formatter.backtrace_message.presence)
58
+ text << ''
59
+ text << '*Backtrace:*'
60
+ text << backtrace
61
+ end
82
62
 
83
- return [] unless backtrace
84
-
85
- text = []
86
-
87
- text << ''
88
- text << '*Backtrace:*'
89
- text << '```'
90
- backtrace.first(3).each { |line| text << "* #{line}" }
91
- text << '```'
92
-
93
- text
94
- end
95
-
96
- def app_name
97
- options[:app_name] || rails_app_name || 'N/A'
98
- end
99
-
100
- def errors_count
101
- options[:accumulated_errors_count].to_i
102
- end
103
-
104
- def rails_app_name
105
- Rails.application.class.name.underscore if defined?(Rails)
106
- end
107
-
108
- def controller_text
109
- controller = options.dig(:env, 'action_controller.instance')
110
-
111
- " in *#{controller.controller_name}##{controller.action_name}*" if controller
63
+ text.join("\n")
112
64
  end
113
65
  end
114
66
  end
@@ -1,3 +1,3 @@
1
1
  module ExceptionNotificationTelegram
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification_telegram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Aguirrezabal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-18 00:00:00.000000000 Z
11
+ date: 2020-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,56 +30,56 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '12.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '12.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3.8'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: exception_notification
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.3'
61
+ version: '4.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.3'
68
+ version: '4.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: httparty
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.10.2
75
+ version: 0.13.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.10.2
82
+ version: 0.13.2
83
83
  description:
84
84
  email:
85
85
  - zirion0@gmail.com
@@ -110,17 +110,16 @@ require_paths:
110
110
  - lib
111
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">="
113
+ - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: '2.4'
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.7.8
122
+ rubygems_version: 3.0.6
124
123
  signing_key:
125
124
  specification_version: 4
126
125
  summary: Telegram notifier for exception notification gem