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 +4 -4
- data/.travis.yml +3 -3
- data/README.md +1 -0
- data/example/sample_app.rb +1 -1
- data/exception_notification_telegram.gemspec +6 -4
- data/lib/exception_notification_telegram.rb +17 -65
- data/lib/exception_notification_telegram/version.rb +1 -1
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62a118bad5770bf6eb912ff15cba1b755f7720e5b5f2ce88e74e53ca2c65dd30
|
4
|
+
data.tar.gz: 2b956de041c904f901fdcacd10608f51695269bc954889885d2712fd47b6cad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f2c9474d6f6aaf380f17e9e2de893a96a1d0b17f5ac0760a83836b3eaf9eb869021aac21288e452a46bd8578c82fe8dc39d4094047343e628564a5d7e7bc717
|
7
|
+
data.tar.gz: e9d5c05ce05a5ecf8ef0b926e78df05f723f62507ff79154eb6158fa56cb2d3fcfe9c4cae022038aaf7bef05352d278ee80e665bce63f41595708fbe042579c3
|
data/.travis.yml
CHANGED
@@ -3,12 +3,12 @@ sudo: false
|
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
|
-
- 2.
|
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
|
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
|
+
[](https://badge.fury.io/rb/exception_notification_telegram)
|
3
4
|
[](https://travis-ci.com/iaguirre88/exception_notification_telegram)
|
4
5
|
|
5
6
|
---
|
data/example/sample_app.rb
CHANGED
@@ -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", "~>
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.
|
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.
|
30
|
-
spec.add_dependency "httparty", "~> 0.
|
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
|
-
|
44
|
+
"\nApplication: *#{@formatter.app_name || 'N/A'}*",
|
45
|
+
@formatter.subtitle,
|
42
46
|
'',
|
43
|
-
|
47
|
+
@formatter.title,
|
44
48
|
"*#{exception.message.tr('`', "'")}*"
|
45
49
|
]
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
81
|
-
|
57
|
+
if (backtrace = @formatter.backtrace_message.presence)
|
58
|
+
text << ''
|
59
|
+
text << '*Backtrace:*'
|
60
|
+
text << backtrace
|
61
|
+
end
|
82
62
|
|
83
|
-
|
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
|
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.
|
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:
|
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: '
|
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: '
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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: '
|
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
|
-
|
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
|