exception_notification_telegram 0.1.0 → 0.2.0

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: 8e3cedaa9b3c33a84fd4c2bd5f40e76008b256d09d9364e113fe226812d2d138
4
+ data.tar.gz: 0b2332f2a4e1aff958514079942a77b9b12cfd1d92c7bbfb36b5abd065005d16
5
5
  SHA512:
6
- metadata.gz: ec0839595c9875e0e4e6e12f5ec02e50815440cab99b1e56a385bee8d7302c0e78667eaacbb9c731cd1c145a5e94fcffe0c1b19ac697059bf37a0774443dca7c
7
- data.tar.gz: 3704ffa3c5a7003351077f6f63a874ef0946e71cc2a5705cb9d18dab3408a2b90739d87a42b548914602b3376a2722cc41fee2dc1322f00a4ecec02b3161f4a6
6
+ metadata.gz: 1f79aaf894f075d4a1842e1a4650345fa872f02e0b3630ecbafee2b0eeec963b43c1a2a18b0c6d374bbe39b19773119eb5c2335bb120746d63bcdde3b578b888
7
+ data.tar.gz: 1ae43bc9e7701abfd92aae935914d758c4029adf93e4c30ce2b3a5fb9a208b04b57a08c8bbdded6c9b1882a41a30d4ed11a161d8323adc0c3b167dfb4767c527
@@ -0,0 +1,28 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['3.1', '3.0', '2.7']
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true
25
+ - name: Install dependencies
26
+ run: bundle install
27
+ - name: Run tests
28
+ run: bundle exec rake
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
  ---
@@ -7,7 +8,7 @@
7
8
  The [Exception Notification](https://github.com/smartinez87/exception_notification) gem provides a set of notifiers for sending notifications when errors occur in a Rack/Rails application. This gem adds support for delivering notifications to Telegram.
8
9
 
9
10
  ## Requirements
10
- * Ruby 2.3 or greater
11
+ * Ruby 2.7 or greater
11
12
 
12
13
  ## Installation
13
14
 
@@ -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.7'
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
@@ -22,10 +24,10 @@ Gem::Specification.new do |spec|
22
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
25
  spec.require_paths = ["lib"]
24
26
 
25
- spec.add_development_dependency "bundler", "~> 1.17"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "bundler", "~> 2.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.3"
30
- spec.add_dependency "httparty", "~> 0.10.2"
31
+ spec.add_dependency "exception_notification", "~> 4.4"
32
+ spec.add_dependency "httparty", "~> 0.20.0"
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module ExceptionNotificationTelegram
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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
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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Aguirrezabal
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-18 00:00:00.000000000 Z
11
+ date: 2022-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,79 +16,79 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
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.20.0
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
83
- description:
82
+ version: 0.20.0
83
+ description:
84
84
  email:
85
85
  - zirion0@gmail.com
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/ruby.yml"
90
91
  - ".gitignore"
91
- - ".travis.yml"
92
92
  - CODE_OF_CONDUCT.md
93
93
  - Gemfile
94
94
  - LICENSE.txt
@@ -104,7 +104,7 @@ homepage: https://github.com/iaguirre88/exception_notification_telegram
104
104
  licenses:
105
105
  - MIT
106
106
  metadata: {}
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -112,16 +112,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: '2.7'
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
124
- signing_key:
122
+ rubygems_version: 3.1.6
123
+ signing_key:
125
124
  specification_version: 4
126
125
  summary: Telegram notifier for exception notification gem
127
126
  test_files: []
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.3.6
7
- - 2.4.3
8
- - 2.5.0
9
- before_install:
10
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
11
- - gem install bundler -v 1.17.3
12
-
13
- install:
14
- - bundle install --jobs=3 --retry=3
15
-
16
- script: bundle exec rake spec