webhook_handler 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7680541bee1397f75f588aba20c4a38e57b6da8d
4
+ data.tar.gz: 0007b101a3aa00e6f3c9967afbdd984c7aca0202
5
+ SHA512:
6
+ metadata.gz: 033bd4fd8b756476c0c9a4c61d9528958d1c4f7b2a93d801c0db54a9b0bd2e6802d0a9e3e37125c60dcecb48ea45fd504e48313846555d668e2f9205dd9baf80
7
+ data.tar.gz: afedc5f0174e7110b827fc6b9632f7518e1c90eededda5338705dd61357959f9600bc9f2a64ce25b011316cf50dfbf2845fe3af17c9729cfe896e68007742b36
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in webhook_handler.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # WebhookHandler
2
+
3
+ Combines Sinatra and Sidekiq into a neat package that makes creating simple apps that respond to webhooks a pleasure.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'webhook_handler'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install webhook_handler
20
+
21
+ ## Usage
22
+
23
+ Define a class and include the `WebhookHandler` module. This class then acts as a Sidekiq worker and a Sinatra app.
24
+
25
+ **app.rb**
26
+
27
+ ```ruby
28
+ require 'webhook_handler'
29
+
30
+ class MyApp
31
+ include WebhookHandler
32
+
33
+ def perform
34
+ puts "Working hard!"
35
+ sleep 5
36
+ end
37
+ end
38
+ ```
39
+
40
+ **config.ru**
41
+
42
+ ```ruby
43
+ require_relative './app'
44
+ run MyApp
45
+ ```
46
+
47
+ ### Sinatra compatibility
48
+
49
+ You can also declare other routes in the class:
50
+
51
+ ```ruby
52
+ class MyApp
53
+ include WebhookHandler
54
+
55
+ def perform
56
+ # ...
57
+ end
58
+
59
+ get '/status' do
60
+ "I'm a regular Sinatra route!"
61
+ end
62
+ end
63
+ ```
64
+
65
+ ## Development
66
+
67
+ 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.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/chrismytton/webhook_handler.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'webhook_handler'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/example/Procfile ADDED
@@ -0,0 +1,2 @@
1
+ web: bundle exec rackup -p $PORT
2
+ worker: bundle exec sidekiq -r ./app.rb
data/example/README.md ADDED
@@ -0,0 +1,3 @@
1
+ To run this example app you'll need to have a redis server running, then you can start the app with foreman:
2
+
3
+ bundle exec foreman start
data/example/app.rb ADDED
@@ -0,0 +1,13 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'webhook_handler'
5
+
6
+ class MyApp
7
+ include WebhookHandler
8
+
9
+ def perform
10
+ puts "Working hard!"
11
+ sleep 5
12
+ end
13
+ end
data/example/config.ru ADDED
@@ -0,0 +1,2 @@
1
+ require_relative './app'
2
+ run MyApp
@@ -0,0 +1,3 @@
1
+ module WebhookHandler
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'webhook_handler/version'
2
+ require 'sidekiq'
3
+ require 'sinatra'
4
+
5
+ module WebhookHandler
6
+ def self.included(klass)
7
+ klass.extend self
8
+ klass.include Sidekiq::Worker
9
+ klass.extend Sinatra::Delegator
10
+ klass.instance_eval do
11
+ get '/' do
12
+ 'Send a POST request to this URL to trigger the webhook'
13
+ end
14
+
15
+ post '/' do
16
+ klass.perform_async
17
+ 'ok'
18
+ end
19
+ end
20
+ end
21
+
22
+ def call(*args)
23
+ Sinatra::Application.call(*args)
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'webhook_handler/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'webhook_handler'
8
+ spec.version = WebhookHandler::VERSION
9
+ spec.authors = ['Chris Mytton']
10
+ spec.email = ['chrismytton@gmail.com']
11
+
12
+ spec.summary = 'Perform an async action in response to a webhook'
13
+ spec.homepage = 'https://github.com/chrismytton/webhook_handler'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'sidekiq'
23
+ spec.add_dependency 'sinatra'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.10'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'minitest'
28
+ spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'rack-test'
30
+ spec.add_development_dependency 'foreman'
31
+ spec.add_development_dependency 'puma'
32
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webhook_handler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Mytton
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sidekiq
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-test
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: foreman
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: puma
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - chrismytton@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".travis.yml"
148
+ - Gemfile
149
+ - README.md
150
+ - Rakefile
151
+ - bin/console
152
+ - bin/setup
153
+ - example/Procfile
154
+ - example/README.md
155
+ - example/app.rb
156
+ - example/config.ru
157
+ - lib/webhook_handler.rb
158
+ - lib/webhook_handler/version.rb
159
+ - webhook_handler.gemspec
160
+ homepage: https://github.com/chrismytton/webhook_handler
161
+ licenses: []
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.4.5.1
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: Perform an async action in response to a webhook
183
+ test_files: []