hooksmith 0.1.0 → 0.1.2
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/README.md +8 -8
- data/hooksmith-0.1.0.gem +0 -0
- data/lib/hooksmith/configuration.rb +6 -6
- data/lib/hooksmith/dispatcher.rb +1 -1
- data/lib/hooksmith/railtie.rb +0 -2
- data/lib/hooksmith/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80476ba099d00e9dfefb14d1b05d696a4b5cef3eb655e6f145c334e86fcf1ac
|
4
|
+
data.tar.gz: 4c1e6ae0d6cdfe4e1a013e2028b446912a636b295d949d499801e83ce4a640c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c004376be79241af2a779aa9eeafe4bd4075d09ab45da029d8c9d88ed6faa2d1248652b160ac0761a107c7e0ddddec81a41cec8ed1f5e147f1e6f43d8dd9ca0
|
7
|
+
data.tar.gz: c555b8226888a88774fb0fd97bd3b57a1741a35bdd615d462bbd479786ab6a1aede0875a070cb9fcbc0d76f4b3ad6ac85256ff023dd2d9e9ccd552fcd8d928fe
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
Add this line to your application's Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'hooksmith', '~> 0.1.
|
18
|
+
gem 'hooksmith', '~> 0.1.1'
|
19
19
|
```
|
20
20
|
|
21
21
|
Then execute:
|
@@ -38,12 +38,12 @@ Configure your webhook processors in an initializer (e.g., `config/initializers/
|
|
38
38
|
```ruby
|
39
39
|
Hooksmith.configure do |config|
|
40
40
|
config.provider(:stripe) do |stripe|
|
41
|
-
stripe.register(:charge_succeeded, Stripe::Processor::ChargeSucceeded::
|
42
|
-
stripe.register(:charge_succeeded, Stripe::Processor::ChargeSucceeded::
|
41
|
+
stripe.register(:charge_succeeded, 'Stripe::Processor::ChargeSucceeded::First')
|
42
|
+
stripe.register(:charge_succeeded, 'Stripe::Processor::ChargeSucceeded::Second')
|
43
43
|
end
|
44
44
|
|
45
45
|
config.provider(:paypal) do |paypal|
|
46
|
-
paypal.register(:payment_received, Paypal::Processor::PaymentReceived)
|
46
|
+
paypal.register(:payment_received, 'Paypal::Processor::PaymentReceived')
|
47
47
|
end
|
48
48
|
end
|
49
49
|
```
|
@@ -58,13 +58,13 @@ module Stripe
|
|
58
58
|
class Tenant < Hooksmith::Processor::Base
|
59
59
|
# Only handle events with a tenant_payment_id.
|
60
60
|
def can_handle?(payload)
|
61
|
-
payload.dig("metadata", "
|
61
|
+
payload.dig("metadata", "id").present?
|
62
62
|
end
|
63
63
|
|
64
64
|
def process!
|
65
|
-
tenant_payment_id = payload.dig("metadata", "
|
65
|
+
tenant_payment_id = payload.dig("metadata", "id")
|
66
66
|
# Add your business logic here (e.g., update database records).
|
67
|
-
puts "Processed
|
67
|
+
puts "Processed id : #{id}"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -116,4 +116,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/gregor
|
|
116
116
|
|
117
117
|
|
118
118
|
## License
|
119
|
-
The gem is available as open source under the terms of the MIT License.
|
119
|
+
The gem is available as open source under the terms of the MIT License.
|
data/hooksmith-0.1.0.gem
ADDED
Binary file
|
@@ -27,9 +27,9 @@ module Hooksmith
|
|
27
27
|
#
|
28
28
|
# @param provider [Symbol, String] the provider name
|
29
29
|
# @param event [Symbol, String] the event name
|
30
|
-
# @param
|
31
|
-
def register_processor(provider, event,
|
32
|
-
registry[provider.to_sym] << { event: event.to_sym, processor:
|
30
|
+
# @param processor_class_name [String] the processor class name
|
31
|
+
def register_processor(provider, event, processor_class_name)
|
32
|
+
registry[provider.to_sym] << { event: event.to_sym, processor: processor_class_name }
|
33
33
|
end
|
34
34
|
|
35
35
|
# Returns all processor entries for a given provider and event.
|
@@ -57,9 +57,9 @@ module Hooksmith
|
|
57
57
|
# Registers a processor for a specific event.
|
58
58
|
#
|
59
59
|
# @param event [Symbol, String] the event name.
|
60
|
-
# @param
|
61
|
-
def register(event,
|
62
|
-
entries << { event: event.to_sym, processor:
|
60
|
+
# @param processor_class_name [String] the processor class name.
|
61
|
+
def register(event, processor_class_name)
|
62
|
+
entries << { event: event.to_sym, processor: processor_class_name }
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/hooksmith/dispatcher.rb
CHANGED
@@ -33,7 +33,7 @@ module Hooksmith
|
|
33
33
|
|
34
34
|
# Instantiate each processor and filter by condition.
|
35
35
|
matching_processors = entries.map do |entry|
|
36
|
-
processor = entry[:processor].new(@payload)
|
36
|
+
processor = Object.const_get(entry[:processor]).new(@payload)
|
37
37
|
processor if processor.can_handle?(@payload)
|
38
38
|
end.compact
|
39
39
|
|
data/lib/hooksmith/railtie.rb
CHANGED
@@ -7,8 +7,6 @@ if defined?(Rails)
|
|
7
7
|
# This file allows Hooksmith to integrate seamlessly with a Rails application.
|
8
8
|
class Railtie < Rails::Railtie
|
9
9
|
initializer 'hooksmith.configure_rails_initialization' do |_|
|
10
|
-
Hooksmith.logger.info('Hooksmith initialized in Rails')
|
11
|
-
# Optionally set the gem logger to use Rails.logger if available.
|
12
10
|
if defined?(Rails.logger) && Rails.logger
|
13
11
|
Hooksmith::Logger.instance.instance_variable_set(:@logger, Rails.logger)
|
14
12
|
end
|
data/lib/hooksmith/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hooksmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gregoryrivage
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-13 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: Hooksmith is a gem that allows you to handle webhooks in your Rails application.
|
13
|
+
It provides a simple and flexible way to receive, validate, and process webhooks
|
14
|
+
from various services. With Hooksmith, you can easily configure webhook endpoints,
|
15
|
+
handle authentication, retry failed webhooks, and manage webhook payloads in a consistent
|
16
|
+
manner.
|
13
17
|
email:
|
14
18
|
- gregory@rivage.immo
|
15
19
|
executables: []
|
@@ -23,6 +27,7 @@ files:
|
|
23
27
|
- LICENSE.txt
|
24
28
|
- README.md
|
25
29
|
- Rakefile
|
30
|
+
- hooksmith-0.1.0.gem
|
26
31
|
- lib/hooksmith.rb
|
27
32
|
- lib/hooksmith/configuration.rb
|
28
33
|
- lib/hooksmith/dispatcher.rb
|