puma-plugin-stripe 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d701a31887818f8b5fa89413988ba8bee2ab34938d03cc421cb04be94a698b68
4
+ data.tar.gz: 489fc733af7b69328168a4a131de5c6b57a5b81bb157c548332003ca98868195
5
+ SHA512:
6
+ metadata.gz: 64fd0e8a23e58277f78ed72c9766ebbaaf2ff96fb1ab51fc5a4a30c16cc4bd8ac4e6a0d063b238c1eb7781c62a519ff9ecce8371a3fe48bec824cd0b4d63e4e0
7
+ data.tar.gz: 30a8d90727a1df042ba595c807ed8a05244560314782b7c30aebd79bf004925c61ba66a54cb8cf7bdaba0d6f7b085350c167f37b789d1eed2e4f322982dd5b15
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ # Want to disable a check for a specific case? To disable checks inline:
2
+ # http://docs.rubocop.org/en/latest/configuration/#disabling-cops-within-source-code
3
+
4
+ inherit_gem: { rubocop-rails-omakase: rubocop.yml }
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2025-02-19
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Zacharias Knudsen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Puma::Plugin::Stripe
2
+
3
+ Forward Stripe webhook events to your web server.
4
+
5
+ ## Installation
6
+
7
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ ```bash
12
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
13
+ ```
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ ```bash
18
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Add `plugin :stripe` to `puma.rb`.
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `puma-plugin-stripe.gemspec`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zachasme/puma-plugin-stripe.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "stripe"
4
+ require "puma/plugin"
5
+
6
+ Puma::Plugin.create do
7
+ def start(launcher)
8
+ @launcher = launcher
9
+
10
+ launcher.events.on_booted do
11
+ launcher.log_writer.log "Stripe: forwarding webhooks to #{forward_to}"
12
+ @pid = fork do
13
+ exec "stripe listen --forward-to #{forward_to} --api-key #{Stripe.api_key}"
14
+ rescue Errno::ENOENT
15
+ launcher.log_writer.log "[Stripe] Not found. See https://docs.stripe.com/stripe-cli#install"
16
+ end
17
+ end
18
+
19
+ launcher.events.on_stopped { stop_stripe }
20
+ end
21
+
22
+ private
23
+ def stop_stripe
24
+ Process.waitpid(@pid, Process::WNOHANG)
25
+ @launcher.log_writer.log "[Stripe] Stopping..."
26
+ Process.kill(:INT, @pid) if @pid
27
+ Process.wait(@pid)
28
+ rescue Errno::ECHILD, Errno::ESRCH
29
+ end
30
+
31
+ def forward_to
32
+ path = @launcher.options.fetch(:stripe_forward_to, "/stripe_events")
33
+ _, port, host = @launcher.binder.ios.first.addr
34
+ URI::HTTP.build(port:, host:, path:)
35
+ end
36
+ end
37
+
38
+ module Puma
39
+ class DSL
40
+ def stripe_forward_to(path)
41
+ @options[:stripe_forward_to] = path
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puma-plugin-stripe
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Zacharias Knudsen
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-02-19 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: puma
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '3.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '3.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: stripe
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rubocop-rails-omakase
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ email: z@chari.as
55
+ executables: []
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - ".rubocop.yml"
60
+ - CHANGELOG.md
61
+ - LICENSE.txt
62
+ - README.md
63
+ - Rakefile
64
+ - lib/puma/plugin/stripe.rb
65
+ homepage: https://github.com/zachasme/puma-plugin-stripe
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ homepage_uri: https://github.com/zachasme/puma-plugin-stripe
70
+ source_code_uri: https://github.com/zachasme/puma-plugin-stripe
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 3.6.3
86
+ specification_version: 4
87
+ summary: Forward Stripe webhook events to your web server.
88
+ test_files: []