Skip to content

Commit

Permalink
WIP /error_notifier/dlnk_error_notifier/g
Browse files Browse the repository at this point in the history
  • Loading branch information
dalink committed Nov 20, 2024
1 parent 5ae35a1 commit d9a201f
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

# Specify your gem's dependencies in error_notifier.gemspec
# Specify your gem's dependencies in dlnk_error_notifier.gemspec
gemspec

gem "rake", "~> 13.0"
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "error_notifier"
require "dlnk_error_notifier"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
Binary file added dlnk_error_notifier-0.1.0.gem
Binary file not shown.
4 changes: 2 additions & 2 deletions error_notifier.gemspec → dlnk_error_notifier.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "lib/error_notifier/version"
require_relative "lib/dlnk_error_notifier/version"

Gem::Specification.new do |spec|
spec.name = "dlnk_error_notifier"
spec.version = ErrorNotifier::VERSION
spec.version = DlnkErrorNotifier::VERSION
spec.authors = ["dalink"]
spec.email = ["[email protected]"]

Expand Down
Binary file removed error_notifier-0.1.0.gem
Binary file not shown.
10 changes: 10 additions & 0 deletions lib/dlnk_error_notifier.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require "dlnk_error_notifier/version"
require_relative "dlnk_error_notifier/middleware"
require "dlnk_error_notifier/jobs/http_post_job"

module DlnkErrorNotifier
class Error < StandardError; end
# Your code goes here...
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
require "active_job"
require "httparty"

module ErrorNotifier
module DlnkErrorNotifier
# HttpPostJob is an ActiveJob that performs an HTTP POST request.
# This job is enqueued to run in the background, preventing the main thread
# from being blocked by the HTTP request.
#
# @example Enqueue the job
# ErrorNotifier::HttpPostJob.perform_later('https://your-webhook-url.com', { key: 'value' }.to_json)
# DlnkErrorNotifier::HttpPostJob.perform_later('https://your-webhook-url.com', { key: 'value' }.to_json)
#
# @param url [String] the URL to which the POST request is sent
# @param body [String] the body of the POST request, typically in JSON format
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require "rack/request"
require "error_notifier/jobs/http_post_job"
require "dlnk_error_notifier/jobs/http_post_job"

module ErrorNotifier
module DlnkErrorNotifier
# Middleware to catch exceptions and send them to a webhook
class Middleware
def initialize(app)
Expand Down Expand Up @@ -37,7 +37,7 @@ def notify_error(env, exception)
end

def send_webhook(error_details)
ErrorNotifier::HttpPostJob.perform_later(
DlnkErrorNotifier::HttpPostJob.perform_later(
ENV["WEBHOOK_URL"] || "http://localhost:3000/webhook",
error_details.to_json
)
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions lib/error_notifier.rb

This file was deleted.

2 changes: 1 addition & 1 deletion sig/error_notifier.rbs → sig/dlnk_error_notifier.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ErrorNotifier
module DlnkErrorNotifier
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require "test_helper"

class TestErrorNotifier < Minitest::Test
class TestDlnkErrorNotifier < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::ErrorNotifier::VERSION
refute_nil ::DlnkErrorNotifier::VERSION
end

def test_it_does_something_useful
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "error_notifier"
require "dlnk_error_notifier"

require "minitest/autorun"

0 comments on commit d9a201f

Please sign in to comment.