slack_webhook_logger 0.4.0 → 0.5.0

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: 7946d92f1bd89b5b0abe79a1d1a54566cb83017c2a2b8c96692f918f89274a5f
4
- data.tar.gz: c74d1d8381ea1b4a2a23781f949ec33d0408e89b7bffcbeb5e621bf10e3e385d
3
+ metadata.gz: a8aca45921ee3b9d9bcecb993e4b4ef9f30b7853e802babce6e0f5b208ddd2ca
4
+ data.tar.gz: abaf6b83376d4e412d6971b6885f2c3de02a3191f07a6ea7909aa77c5f0c99e1
5
5
  SHA512:
6
- metadata.gz: 8b0ae3b2a587b896ae2d55bb5f9ad066354272b05b12eb2e463f7f07c33fbe7a680412166dacc4553faf04c9794cd2dbe29197c80b74cde69c50b2728c3feaca
7
- data.tar.gz: 0a4363543af0d739112b4c17f5c6647b6a3c280ec933aaff37d78d6b2b95159d625a4ac3fbe82595167c07f0306edbbdcba9f7926312d2ab775412365f8c3d1d
6
+ metadata.gz: db1edd27e70437d26658f21caf2424b02ff3d0ca1436e56fea8888f608e8f9799b179fd61f2e63e8c3c17134d865d6796d5f66a48ac9ea3c3225152f5681630f
7
+ data.tar.gz: 2702fd661d5bf78050cf82033e2ea60ce65a201fa4cc28ae63bb8f8013abeac6ed7a452725231a83568c01d4032067c5e0d87b010573ac64b0beaaf37719d0d8
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "09:00"
8
+ timezone: "Etc/UTC"
9
+ open-pull-requests-limit: 10
10
+
11
+ - package-ecosystem: "bundler"
12
+ directory: "/"
13
+ schedule:
14
+ interval: daily
15
+ time: "09:00"
16
+ timezone: "Etc/UTC"
17
+ open-pull-requests-limit: 10
@@ -0,0 +1,14 @@
1
+ name: "Bot auto-{approve,merge}"
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request_target:
6
+
7
+ permissions:
8
+ pull-requests: write
9
+ contents: write
10
+
11
+ jobs:
12
+ dependabot:
13
+ uses: yettoapp/actions/.github/workflows/automerge_dependabot.yml@main
14
+ secrets: inherit
@@ -2,20 +2,22 @@ name: Linting
2
2
 
3
3
  on:
4
4
  pull_request:
5
- types: [opened, synchronize, reopened]
6
- push:
7
- branches:
8
- - main
5
+ paths:
6
+ - "**/*.rb"
7
+
8
+ permissions:
9
+ contents: read
9
10
 
10
11
  jobs:
11
- test:
12
+ lint:
12
13
  runs-on: ubuntu-latest
13
14
  steps:
14
- - uses: actions/checkout@v2
15
- - uses: ruby/setup-ruby@v1
15
+ - uses: actions/checkout@v3
16
+
17
+ - name: Set up Ruby
18
+ uses: yettoapp/actions/setup-languages@main
16
19
  with:
17
- ruby-version: 2.7
18
- bundler-cache: true
19
- - run: bundle install
20
+ ruby: true
21
+
20
22
  - name: Rubocop
21
23
  run: bundle exec rake rubocop
@@ -0,0 +1,19 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ paths:
9
+ - "lib/slack_webhook_logger/version.rb"
10
+
11
+ jobs:
12
+ ruby:
13
+ uses: yettoapp/actions/.github/workflows/ruby_gem_release.yml@main
14
+ secrets:
15
+ rubygems_api_key: ${{ secrets.RUBYGEMS_API_BOT_KEY }}
16
+ gh_token: ${{ secrets.PUBLIC_PUSH_TO_PROTECTED_BRANCH }}
17
+ with:
18
+ gem_name: slack_webhook_logger
19
+ version_filepath: lib/slack_webhook_logger/version.rb
@@ -0,0 +1,22 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+
16
+ - name: Set up Ruby
17
+ uses: yettoapp/actions/setup-languages@main
18
+ with:
19
+ ruby: true
20
+
21
+ - name: Run tests
22
+ run: bundle exec rake test
data/.rubocop.yml CHANGED
@@ -2,6 +2,3 @@ inherit_gem:
2
2
  rubocop-standard:
3
3
  - config/default.yml
4
4
  - config/minitest.yml
5
-
6
- AllCops:
7
- TargetRubyVersion: 3.0
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.1
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "[ruby]": {
3
3
  "editor.defaultFormatter": "Shopify.ruby-lsp"
4
+ },
5
+ "[markdown]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
4
7
  }
5
8
  }
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## [v0.5.0] - 05-07-2023
2
+ null
data/Gemfile CHANGED
@@ -1,15 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in slack-webhooklogger.gemspec
6
6
  gemspec
7
7
 
8
- gem 'awesome_print', '~> 1.8'
9
- gem 'minitest', '~> 5.0'
10
- gem 'rake', '~> 12.0'
8
+ gem 'minitest', '~> 5.18'
9
+ gem 'rake', '~> 13.0'
11
10
  gem 'rubocop', '~> 1.6'
12
- gem 'rubocop-performance', '~> 1.9'
13
- gem 'rubocop-standard', '~> 5.1'
11
+ gem "rubocop-standard"
14
12
 
15
- gem 'webmock', '~> 3.11'
13
+ gem "webmock", "~> 3.11"
14
+ # mocking lib
15
+ gem "mocha", "~> 2.0"
16
+
17
+ gem "amazing_print", require: false
18
+ gem "debug", require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack_webhook_logger (0.4.0)
4
+ slack_webhook_logger (0.5.0)
5
5
  activesupport (>= 5.0, < 8.0)
6
6
  httpx (~> 0.20)
7
7
  railties (>= 5.0, < 8.0)
@@ -9,103 +9,127 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (7.0.4.3)
13
- actionview (= 7.0.4.3)
14
- activesupport (= 7.0.4.3)
15
- rack (~> 2.0, >= 2.2.0)
12
+ actionpack (7.0.6)
13
+ actionview (= 7.0.6)
14
+ activesupport (= 7.0.6)
15
+ rack (~> 2.0, >= 2.2.4)
16
16
  rack-test (>= 0.6.3)
17
17
  rails-dom-testing (~> 2.0)
18
18
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
- actionview (7.0.4.3)
20
- activesupport (= 7.0.4.3)
19
+ actionview (7.0.6)
20
+ activesupport (= 7.0.6)
21
21
  builder (~> 3.1)
22
22
  erubi (~> 1.4)
23
23
  rails-dom-testing (~> 2.0)
24
24
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
- activesupport (7.0.4.3)
25
+ activesupport (7.0.6)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (>= 1.6, < 2)
28
28
  minitest (>= 5.1)
29
29
  tzinfo (~> 2.0)
30
30
  addressable (2.8.4)
31
31
  public_suffix (>= 2.0.2, < 6.0)
32
+ amazing_print (1.5.0)
32
33
  ast (2.4.2)
33
- awesome_print (1.9.2)
34
34
  builder (3.2.4)
35
35
  concurrent-ruby (1.2.2)
36
36
  crack (0.4.5)
37
37
  rexml
38
38
  crass (1.0.6)
39
+ debug (1.8.0)
40
+ irb (>= 1.5.0)
41
+ reline (>= 0.3.1)
39
42
  erubi (1.12.0)
40
43
  hashdiff (1.0.1)
41
44
  http-2-next (0.5.1)
42
- httpx (0.23.1)
45
+ httpx (0.24.1)
43
46
  http-2-next (>= 0.4.1)
44
- i18n (1.13.0)
47
+ i18n (1.14.1)
45
48
  concurrent-ruby (~> 1.0)
49
+ io-console (0.6.0)
50
+ irb (1.7.1)
51
+ reline (>= 0.3.0)
46
52
  json (2.6.3)
47
- loofah (2.20.0)
53
+ language_server-protocol (3.17.0.3)
54
+ loofah (2.21.3)
48
55
  crass (~> 1.0.2)
49
- nokogiri (>= 1.5.9)
56
+ nokogiri (>= 1.12.0)
50
57
  method_source (1.0.0)
51
- minitest (5.18.0)
52
- nokogiri (1.14.3-arm64-darwin)
58
+ minitest (5.18.1)
59
+ mocha (2.0.4)
60
+ ruby2_keywords (>= 0.0.5)
61
+ nokogiri (1.15.3-arm64-darwin)
62
+ racc (~> 1.4)
63
+ nokogiri (1.15.3-x86_64-linux)
53
64
  racc (~> 1.4)
54
65
  parallel (1.23.0)
55
- parser (3.2.2.1)
66
+ parser (3.2.2.3)
56
67
  ast (~> 2.4.1)
68
+ racc
57
69
  public_suffix (5.0.1)
58
- racc (1.6.2)
70
+ racc (1.7.1)
59
71
  rack (2.2.7)
60
72
  rack-test (2.1.0)
61
73
  rack (>= 1.3)
62
- rails-dom-testing (2.0.3)
63
- activesupport (>= 4.2.0)
74
+ rails-dom-testing (2.1.1)
75
+ activesupport (>= 5.0.0)
76
+ minitest
64
77
  nokogiri (>= 1.6)
65
- rails-html-sanitizer (1.5.0)
66
- loofah (~> 2.19, >= 2.19.1)
67
- railties (7.0.4.3)
68
- actionpack (= 7.0.4.3)
69
- activesupport (= 7.0.4.3)
78
+ rails-html-sanitizer (1.6.0)
79
+ loofah (~> 2.21)
80
+ nokogiri (~> 1.14)
81
+ railties (7.0.6)
82
+ actionpack (= 7.0.6)
83
+ activesupport (= 7.0.6)
70
84
  method_source
71
85
  rake (>= 12.2)
72
86
  thor (~> 1.0)
73
87
  zeitwerk (~> 2.5)
74
88
  rainbow (3.1.1)
75
- rake (12.3.3)
76
- regexp_parser (2.8.0)
89
+ rake (13.0.6)
90
+ regexp_parser (2.8.1)
91
+ reline (0.3.5)
92
+ io-console (~> 0.5)
77
93
  rexml (3.2.5)
78
- rubocop (1.50.2)
94
+ rubocop (1.54.1)
79
95
  json (~> 2.3)
96
+ language_server-protocol (>= 3.17.0)
80
97
  parallel (~> 1.10)
81
- parser (>= 3.2.0.0)
98
+ parser (>= 3.2.2.3)
82
99
  rainbow (>= 2.2.2, < 4.0)
83
100
  regexp_parser (>= 1.8, < 3.0)
84
101
  rexml (>= 3.2.5, < 4.0)
85
102
  rubocop-ast (>= 1.28.0, < 2.0)
86
103
  ruby-progressbar (~> 1.7)
87
104
  unicode-display_width (>= 2.4.0, < 3.0)
88
- rubocop-ast (1.28.1)
105
+ rubocop-ast (1.29.0)
89
106
  parser (>= 3.2.1.0)
90
- rubocop-minitest (0.30.0)
107
+ rubocop-minitest (0.31.0)
91
108
  rubocop (>= 1.39, < 2.0)
92
- rubocop-performance (1.17.1)
109
+ rubocop-performance (1.18.0)
93
110
  rubocop (>= 1.7.0, < 2.0)
94
111
  rubocop-ast (>= 0.4.0)
95
- rubocop-rails (2.19.1)
112
+ rubocop-rails (2.20.2)
96
113
  activesupport (>= 4.2.0)
97
114
  rack (>= 1.1)
98
115
  rubocop (>= 1.33.0, < 2.0)
99
116
  rubocop-rake (0.6.0)
100
117
  rubocop (~> 1.0)
101
- rubocop-standard (5.2.1)
118
+ rubocop-shopify (2.14.0)
119
+ rubocop (~> 1.51)
120
+ rubocop-sorbet (0.7.0)
121
+ rubocop (>= 0.90.0)
122
+ rubocop-standard (7.1.0)
102
123
  rubocop
103
124
  rubocop-minitest
104
125
  rubocop-performance
105
126
  rubocop-rails
106
127
  rubocop-rake
128
+ rubocop-shopify
129
+ rubocop-sorbet
107
130
  ruby-progressbar (1.13.0)
108
- thor (1.2.1)
131
+ ruby2_keywords (0.0.5)
132
+ thor (1.2.2)
109
133
  tzinfo (2.0.6)
110
134
  concurrent-ruby (~> 1.0)
111
135
  unicode-display_width (2.4.2)
@@ -116,15 +140,17 @@ GEM
116
140
  zeitwerk (2.6.8)
117
141
 
118
142
  PLATFORMS
119
- ruby
143
+ arm64-darwin-22
144
+ x86_64-linux
120
145
 
121
146
  DEPENDENCIES
122
- awesome_print (~> 1.8)
123
- minitest (~> 5.0)
124
- rake (~> 12.0)
147
+ amazing_print
148
+ debug
149
+ minitest (~> 5.18)
150
+ mocha (~> 2.0)
151
+ rake (~> 13.0)
125
152
  rubocop (~> 1.6)
126
- rubocop-performance (~> 1.9)
127
- rubocop-standard (~> 5.1)
153
+ rubocop-standard
128
154
  slack_webhook_logger!
129
155
  webmock (~> 3.11)
130
156
 
data/README.md CHANGED
@@ -7,7 +7,7 @@ A simple Slack logger using ActiveSupport broadcast and a slim HTTPS call.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'slack-webhooklogger'
10
+ gem 'slack_webhook_logger'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -19,13 +19,13 @@ $ bundle install
19
19
  Or install it yourself as:
20
20
 
21
21
  ```
22
- $ gem install slack-webhooklogger
22
+ $ gem install slack_webhook_logger
23
23
  ```
24
24
 
25
25
  Then, run the install generator:
26
26
 
27
27
  ```
28
- $ rails generate slack-webhooklogger:install
28
+ $ rails generate slack_webhook_logger:install
29
29
  ```
30
30
 
31
31
  Provide the webhook URL in the config, and finally, extend the logger:
@@ -38,4 +38,28 @@ end
38
38
 
39
39
  ## Configuration
40
40
 
41
+ You should have a file in `config/initializers/slack_webhook_logger.rb` that looks somrthing like this:
42
+
43
+ ```ruby
44
+ SlackWebhookLogger.setup do |config|
45
+ # The URL where messages will be sent. This is required.
46
+ config.webhook_url = 'https://hooks.slack.com/services/xxx/yyy/zzz'
47
+
48
+ # The minimum error level to see in Slack. This is optional; the default is :WARN.
49
+ #
50
+ # All log levels are supported, but don't rely on anything less then :WARN
51
+ # since Slack only allows one message per minute.
52
+ # config.level = :WARN
53
+
54
+ # You can provide a custom log formatter if you want to. This is optional.
55
+ # The formatter must construct a JSON blob that adheres to Slack's expected
56
+ # POST payload for `chat.postMessage`: https://api.slack.com/methods/chat.postMessage
57
+ # config.formatter = SomeOtherFormatter.new
58
+
59
+ # You can provide an array of regular expressions to ignore certain messages
60
+ # from being sent to Slack. This is optional.
61
+ # config.ignore_patterns = []
62
+ end
63
+ ```
64
+
41
65
  You can change the log level or the format of the logging text if you wish. See the generated slack_webhook_logger.rb file for more information on that.
data/Rakefile CHANGED
@@ -1,16 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
3
+ require "bundler/gem_tasks"
4
+ require "rubygems/package_task"
5
+ require "rake/testtask"
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
10
11
  end
11
12
 
12
- task default: :test
13
+ require "rubocop/rake_task"
13
14
 
14
- require 'rubocop/rake_task'
15
+ RuboCop::RakeTask.new
15
16
 
16
- RuboCop::RakeTask.new(:rubocop)
17
+ GEMSPEC = Bundler.load_gemspec("slack_webhook_logger.gemspec")
18
+ gem_path = Gem::PackageTask.new(GEMSPEC).define
19
+ desc "Package the ruby gem"
20
+ task "package" => [gem_path]
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/base'
3
+ require "rails/generators/base"
4
4
 
5
5
  module SlackWebhookLogger
6
6
  class InstallGenerator < Rails::Generators::Base
7
7
  source_root File.expand_path("..#{File::SEPARATOR}..#{File::SEPARATOR}templates", __FILE__)
8
8
 
9
- desc 'Create a Slack::WebhookLogger initializer'
9
+ desc "Create a Slack::WebhookLogger initializer"
10
10
 
11
11
  def copy_initializer
12
- template 'slack_webhook_logger.rb', 'config/initializers/slack_webhook_logger.rb'
12
+ template("slack_webhook_logger.rb", "config/initializers/slack_webhook_logger.rb")
13
13
  end
14
14
  end
15
15
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  SlackWebhookLogger.setup do |config|
4
4
  # The URL where messages will be sent. This is required.
5
- config.webhook_url = 'https://hooks.slack.com/services/xxx/yyy/zzz'
5
+ config.webhook_url = "https://hooks.slack.com/services/xxx/yyy/zzz"
6
6
 
7
7
  # The minimum error level to see in Slack. This is optional; the default is :WARN.
8
8
  #
@@ -7,21 +7,21 @@ module SlackWebhookLogger
7
7
  def format
8
8
  @format ||= proc do |severity, time, _progname, msg|
9
9
  heading = case severity
10
- when 'FATAL'
11
- "📛 *#{severity}*"
12
- when 'ERROR'
13
- "🛑 *#{severity}*"
14
- when 'WARN'
15
- "⚠️ *#{severity}*"
16
- when 'INFO'
17
- "ℹ️ *#{severity}*"
18
- when 'DEBUG'
19
- "🐛 *#{severity}*"
20
- else
21
- '🪵 *Logger*'
22
- end
10
+ when "FATAL"
11
+ "📛 *#{severity}*"
12
+ when "ERROR"
13
+ "🛑 *#{severity}*"
14
+ when "WARN"
15
+ "⚠️ *#{severity}*"
16
+ when "INFO"
17
+ "ℹ️ *#{severity}*"
18
+ when "DEBUG"
19
+ "🐛 *#{severity}*"
20
+ else
21
+ "🪵 *Logger*"
22
+ end
23
23
 
24
- title = "#{heading} (#{time}) [#{ENV.fetch('RAILS_ENV', nil)}]"
24
+ title = "#{heading} (#{time}) [#{ENV.fetch("RAILS_ENV", nil)}]"
25
25
 
26
26
  text = <<~MSG
27
27
  #{msg2str(msg)}
@@ -40,23 +40,23 @@ module SlackWebhookLogger
40
40
  text: [title, text].join("\n").to_s,
41
41
  blocks: [
42
42
  {
43
- type: 'section',
43
+ type: "section",
44
44
  text: {
45
- type: 'mrkdwn',
46
- text: title
47
- }
45
+ type: "mrkdwn",
46
+ text: title,
47
+ },
48
48
  },
49
49
  {
50
- type: 'divider'
50
+ type: "divider",
51
51
  },
52
52
  {
53
- type: 'section',
53
+ type: "section",
54
54
  text: {
55
- type: 'plain_text',
56
- text: text
57
- }
58
- }
59
- ]
55
+ type: "plain_text",
56
+ text: text,
57
+ },
58
+ },
59
+ ],
60
60
  }
61
61
  end
62
62
 
@@ -66,7 +66,7 @@ module SlackWebhookLogger
66
66
  msg
67
67
  when ::Exception
68
68
  "#{msg.message} (#{msg.class})\n" <<
69
- (msg.backtrace || []).join("\n")
69
+ (msg.backtrace || []).join("\n")
70
70
  else
71
71
  msg.inspect
72
72
  end
@@ -1,12 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/module/delegation'
3
+ require "active_support/core_ext/module/delegation"
4
4
 
5
5
  module SlackWebhookLogger
6
6
  class Logger < ::ActiveSupport::Logger
7
7
  class << self
8
- delegate :fatal, :error, :warn, :info, :debug,
9
- :add, :log, to: :instance
8
+ delegate :fatal,
9
+ :error,
10
+ :warn,
11
+ :info,
12
+ :debug,
13
+ :add,
14
+ :log,
15
+ to: :instance
10
16
  end
11
17
  end
12
18
  end
@@ -1,21 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
- require 'json'
5
- require 'httpx'
3
+ require "uri"
4
+ require "json"
5
+ require "httpx"
6
6
 
7
7
  module SlackWebhookLogger
8
8
  class RequestIO
9
- def self.close
10
- true
11
- end
9
+ class << self
10
+ def close
11
+ true
12
+ end
13
+
14
+ def write(hash)
15
+ return if hash.blank?
16
+
17
+ return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| hash[:text].match(ignore_pattern) }
12
18
 
13
- def self.write(hash)
14
- return if hash.blank?
19
+ response = HTTPX.post(SlackWebhookLogger.webhook_uri.to_s, form: hash)
15
20
 
16
- return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| hash[:text].match(ignore_pattern) }
21
+ return if (200..299).cover?(response.status)
17
22
 
18
- HTTPX.post(SlackWebhookLogger.webhook_uri.to_s, form: hash)
23
+ case response
24
+ when HTTPX::ErrorResponse
25
+ warn(response)
26
+ else
27
+ warn(response.body)
28
+ end
29
+ end
19
30
  end
20
31
  end
21
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlackWebhookLogger
4
- VERSION = '0.4.0'
4
+ VERSION = "0.5.0"
5
5
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/logger'
4
- require 'active_support/core_ext/module/attribute_accessors'
3
+ require "active_support/logger"
4
+ require "active_support/core_ext/module/attribute_accessors"
5
5
 
6
- require 'net/http'
7
- require 'net/https'
8
- require 'uri'
6
+ require "net/http"
7
+ require "net/https"
8
+ require "uri"
9
9
 
10
- require 'slack_webhook_logger/logger'
11
- require 'slack_webhook_logger/formatter'
12
- require 'slack_webhook_logger/request_io'
10
+ require "slack_webhook_logger/logger"
11
+ require "slack_webhook_logger/formatter"
12
+ require "slack_webhook_logger/request_io"
13
13
 
14
14
  module SlackWebhookLogger
15
15
  # Can be modified in Rails app
@@ -23,22 +23,24 @@ module SlackWebhookLogger
23
23
  mattr_reader :logger
24
24
  mattr_reader :https
25
25
 
26
- # rubocop:disable Style/ClassVars
27
- def self.setup
28
- @@logger = SlackWebhookLogger::Logger.new(SlackWebhookLogger::RequestIO)
26
+ class << self
27
+ # rubocop:disable Style/ClassVars
28
+ def setup
29
+ @@logger = SlackWebhookLogger::Logger.new(SlackWebhookLogger::RequestIO)
29
30
 
30
- yield self
31
+ yield self
31
32
 
32
- @@logger.formatter = @@formatter || SlackWebhookLogger::Formatter.new
33
- @@logger.level = @@level || :warn
33
+ @@logger.formatter = @@formatter || SlackWebhookLogger::Formatter.new
34
+ @@logger.level = @@level || :warn
34
35
 
35
- begin
36
- @@webhook_uri = URI.parse(@@webhook_url)
37
- rescue URI::InvalidURIError
38
- raise ArgumentError, 'Invalid URI for webhook_url'
39
- end
36
+ begin
37
+ @@webhook_uri = URI.parse(@@webhook_url)
38
+ rescue URI::InvalidURIError
39
+ raise ArgumentError, "Invalid URI for webhook_url"
40
+ end
40
41
 
41
- @@ignore_patterns ||= []
42
+ @@ignore_patterns ||= []
43
+ end
44
+ # rubocop:enable Style/ClassVars
42
45
  end
43
- # rubocop:enable Style/ClassVars
44
46
  end
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/slack_webhook_logger/version'
3
+ require_relative "lib/slack_webhook_logger/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'slack_webhook_logger'
6
+ spec.name = "slack_webhook_logger"
7
7
  spec.version = SlackWebhookLogger::VERSION
8
- spec.authors = ['Garen J. Torikian']
9
- spec.email = ['gjtorikian@gmail.com']
8
+ spec.authors = ["Garen J. Torikian"]
9
+ spec.email = ["gjtorikian@gmail.com"]
10
10
 
11
- spec.summary = 'A slim wrapper for posting to Rails logs to Slack'
12
- spec.homepage = 'https://github.com/gjtorikian/slack_webhook_logger'
13
- spec.license = 'MIT'
14
- spec.required_ruby_version = Gem::Requirement.new('~> 3.0')
11
+ spec.summary = "A slim wrapper for posting to Rails logs to Slack"
12
+ spec.homepage = "https://github.com/gjtorikian/slack_webhook_logger"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new("~> 3.0")
15
15
 
16
- spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
23
  end
24
24
 
25
- spec.require_paths = ['lib']
25
+ spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency 'activesupport', '>= 5.0', '< 8.0'
28
- spec.add_dependency 'httpx', '~> 0.20'
29
- spec.add_dependency 'railties', '>= 5.0', '< 8.0' # for the generators
27
+ spec.add_dependency("activesupport", ">= 5.0", "< 8.0")
28
+ spec.add_dependency("httpx", "~> 0.20")
29
+ spec.add_dependency("railties", ">= 5.0", "< 8.0") # for the generators
30
30
  spec.metadata = {
31
- 'rubygems_mfa_required' => 'true'
31
+ "rubygems_mfa_required" => "true",
32
32
  }
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_webhook_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2023-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -64,7 +64,7 @@ dependencies:
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '8.0'
67
- description:
67
+ description:
68
68
  email:
69
69
  - gjtorikian@gmail.com
70
70
  executables: []
@@ -72,11 +72,16 @@ extensions: []
72
72
  extra_rdoc_files: []
73
73
  files:
74
74
  - ".github/FUNDING.yml"
75
- - ".github/workflows/ci.yml"
75
+ - ".github/dependabot.yml"
76
+ - ".github/workflows/automerge.yml"
76
77
  - ".github/workflows/lint.yml"
78
+ - ".github/workflows/release.yml"
79
+ - ".github/workflows/test.yml"
77
80
  - ".gitignore"
78
81
  - ".rubocop.yml"
82
+ - ".ruby-version"
79
83
  - ".vscode/settings.json"
84
+ - CHANGELOG.md
80
85
  - CODE_OF_CONDUCT.md
81
86
  - Gemfile
82
87
  - Gemfile.lock
@@ -98,7 +103,7 @@ licenses:
98
103
  - MIT
99
104
  metadata:
100
105
  rubygems_mfa_required: 'true'
101
- post_install_message:
106
+ post_install_message:
102
107
  rdoc_options: []
103
108
  require_paths:
104
109
  - lib
@@ -113,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
118
  - !ruby/object:Gem::Version
114
119
  version: '0'
115
120
  requirements: []
116
- rubygems_version: 3.4.12
117
- signing_key:
121
+ rubygems_version: 3.4.15
122
+ signing_key:
118
123
  specification_version: 4
119
124
  summary: A slim wrapper for posting to Rails logs to Slack
120
125
  test_files: []
@@ -1,28 +0,0 @@
1
- name: Ruby CI
2
-
3
- on:
4
- push:
5
-
6
- jobs:
7
- test:
8
- runs-on: ubuntu-latest
9
-
10
- strategy:
11
- fail-fast: false
12
- matrix:
13
- ruby-version: [3.0.2]
14
-
15
- steps:
16
- - uses: actions/checkout@v2
17
-
18
- - name: Set up Ruby ${{ matrix.ruby-version }}
19
- uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: ${{ matrix.ruby-version }}
22
- bundler-cache: true
23
-
24
- - name: Install dependencies
25
- run: bundle install
26
-
27
- - name: Run tests
28
- run: bundle exec rake