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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef153cc049df6fb2994b69e8e7fc5a260c1cb57262a7157871b36baf38aff34d
4
- data.tar.gz: a0fb98c2d45e68e4adca1bbd0fc9a3ed44747cff6aa8f56b78ef1bcc6222d4d3
3
+ metadata.gz: c80476ba099d00e9dfefb14d1b05d696a4b5cef3eb655e6f145c334e86fcf1ac
4
+ data.tar.gz: 4c1e6ae0d6cdfe4e1a013e2028b446912a636b295d949d499801e83ce4a640c8
5
5
  SHA512:
6
- metadata.gz: 7bfdc41f3a150ebb6c9ee9685ee22f3d8d3eabbd0314dbb0a42b855f41ead9a3277d0fe8049aef6b05034c6efa540cd17a5d017906b5432000af3f8532a7513b
7
- data.tar.gz: bcd1dd3624624bdfcc288591b1cfde025c3ccfce80f71fcbc649ee8119b2f143bf00c5edc899c7db3b4acf0572d0ebbd802909663a3231c215c645971ceb4b95
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.0'
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::Tenant)
42
- stripe.register(:charge_succeeded, Stripe::Processor::ChargeSucceeded::Landlord)
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", "tenant_payment_id").present?
61
+ payload.dig("metadata", "id").present?
62
62
  end
63
63
 
64
64
  def process!
65
- tenant_payment_id = payload.dig("metadata", "tenant_payment_id")
65
+ tenant_payment_id = payload.dig("metadata", "id")
66
66
  # Add your business logic here (e.g., update database records).
67
- puts "Processed tenant payment: #{tenant_payment_id}"
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.
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 processor_class [Class] the processor class
31
- def register_processor(provider, event, processor_class)
32
- registry[provider.to_sym] << { event: event.to_sym, processor: processor_class }
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 processor_class [Class] the processor class.
61
- def register(event, processor_class)
62
- entries << { event: event.to_sym, processor: processor_class }
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
@@ -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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hooksmith
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2'
5
5
  end
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.0
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-12 00:00:00.000000000 Z
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