pokey-sendgrid 0.1.1

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: 2267dda332347e006ace1fe92ccbb1db280ce12d
4
+ data.tar.gz: 47be71f73cdc13d6432c9a7307963487e84c74fd
5
+ SHA512:
6
+ metadata.gz: e1c5e559bbe26d7b0f9105489379d217c8a67daab668e9bcabaea8dc00143e92df78754a4196cb674ef5ddb39b8135f31b70163b5dd26d0ed0580044e20329d8
7
+ data.tar.gz: de4186d5c62cd34f52ed659b9680ee37e19be870beeb94fa9566d51f46dfc0e4a7c7342b93e61334d0732f52de97375eb77589e5247d06807e9df0be17b29f30
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pokey-sendgrid.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Chuck Callebs
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,108 @@
1
+ # Pokey::Sendgrid
2
+
3
+ Sensible defaults to emulate Sendgrid data on development/QA using Pokey hooks.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pokey-sendgrid'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pokey-sendgrid
20
+
21
+ ## Usage
22
+
23
+ If this is your first installation (and you're on Rails), run
24
+
25
+ `$ rails g pokey:install`
26
+
27
+ This will create an initializer file that defines your `hook_dir` (the
28
+ location where all hooks will be defined). Just create a new file in that
29
+ directory that inherits from `Pokey::Sendgrid::Hook`.
30
+
31
+ Simple example:
32
+
33
+ ``` RUBY
34
+ class SendgridHook < Pokey::Sendgrid::Hook
35
+ # Your Sendgrid webhook endpoint
36
+ def destination
37
+ # Defaults to /api/sendgrid/events
38
+ "http://localhost:3000/api/sendgrid/events"
39
+ end
40
+
41
+ # Time (in seconds) between Pokey requests
42
+ def interval
43
+ 5 # Defaults to 5
44
+ end
45
+ end
46
+ ```
47
+
48
+ #### Categories and Unique Arguments
49
+ This gem also supports dynamic categories / unique arguments when generating
50
+ data. To use:
51
+
52
+ ``` RUBY
53
+ class SendgridHook < Pokey::SendgridHook
54
+ def categories
55
+ [
56
+ ["User", "Welcome Email"],
57
+ ["Billing", "Payment Successful"]
58
+ ]
59
+ end
60
+
61
+ def unique_args
62
+ {
63
+ "custom-identifier" => 15
64
+ }
65
+ end
66
+ end
67
+ ```
68
+
69
+ #### Limiting Events
70
+ By default, Pokey::Sendgrid will generate all types of SendGrid events:
71
+ - processed
72
+ - dropped
73
+ - delivered
74
+ - deferred
75
+ - bounce
76
+ - open
77
+ - click
78
+ - spam_report
79
+ - unsubscribe
80
+ - group_unsubscribe
81
+ - group_resubscribe
82
+
83
+ To limit the amount of events your application receives, override the
84
+ `sendgrid_events` method like so:
85
+
86
+ ``` RUBY
87
+ class SendgridHook < Pokey::SendgridHook
88
+ protected
89
+
90
+ # Limits events to only "Open" and "Click"
91
+ def sendgrid_events
92
+ ["open", "click"]
93
+ end
94
+ end
95
+ ```
96
+
97
+ #### Start generating data
98
+ If you're on rails, just start your server. Otherwise, start your application.
99
+
100
+ ## Contributing
101
+
102
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pokey-sendgrid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
103
+
104
+
105
+ ## License
106
+
107
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
108
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,9 @@
1
+ require "pokey/sendgrid/version"
2
+ require "pokey/sendgrid/mock_data"
3
+ require "pokey/sendgrid/hook"
4
+
5
+ module Pokey
6
+ module Sendgrid
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,79 @@
1
+ require 'pokey/hook'
2
+ require 'faker'
3
+
4
+ module Pokey
5
+ module Sendgrid
6
+ # Reference: https://sendgrid.com/docs/API_Reference/Webhooks/event.html
7
+ class Hook < Pokey::Hook
8
+ include Pokey::Sendgrid::MockData
9
+
10
+ def destination
11
+ "http://localhost:3000/api/sendgrid/events"
12
+ end
13
+
14
+ def interval
15
+ 5
16
+ end
17
+
18
+ def http_method
19
+ :post
20
+ end
21
+
22
+ def data
23
+ data = base_data
24
+
25
+ case data["event"]
26
+ # Delivery events
27
+ when "bounce", "deferred", "delivered", "dropped", "processed"
28
+ data.merge!({
29
+ "smtp-id" => smtp_id
30
+ })
31
+ # Engagement events
32
+ when "click", "open", "spamreport", "unsubscribe"
33
+ data.merge!({
34
+ "useragent" => user_agents.sample,
35
+ "ip" => Faker::Internet.ip_v4_address
36
+ })
37
+ end
38
+
39
+ data.merge!(unique_args)
40
+ data
41
+ end
42
+
43
+ def categories
44
+ []
45
+ end
46
+
47
+ def unique_args
48
+ {}
49
+ end
50
+
51
+ protected
52
+
53
+ def base_data
54
+ {
55
+ "timestamp" => Time.now.to_i,
56
+ "category" => categories.sample,
57
+ "event" => sendgrid_events.sample,
58
+ "email" => Faker::Internet.email
59
+ }
60
+ end
61
+
62
+ def sendgrid_events
63
+ [
64
+ "processed",
65
+ "dropped",
66
+ "delivered",
67
+ "deferred",
68
+ "bounce",
69
+ "open",
70
+ "click",
71
+ "spamreport",
72
+ "unsubscribe",
73
+ "group_unsubscribe",
74
+ "group_resubscribe"
75
+ ]
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,22 @@
1
+ module Pokey
2
+ module Sendgrid
3
+ module MockData
4
+ def user_agents
5
+ [
6
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12",
7
+ "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0",
8
+ "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36",
9
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0",
10
+ "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
11
+ ]
12
+ end
13
+
14
+ def smtp_id
15
+ prefix = Faker::Internet.password(10, 20)
16
+ suffix = Faker::Internet.password(10, 20)
17
+ domain = Faker::Internet.domain_word
18
+ "#{prefix}_#{suffix}@#{domain}.mail"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Pokey
2
+ module Sendgrid
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pokey/sendgrid/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pokey-sendgrid"
8
+ spec.version = Pokey::Sendgrid::VERSION
9
+ spec.authors = ["Chuck Callebs"]
10
+ spec.email = ["chuck@callebs.io"]
11
+
12
+ spec.summary = %q{Easily simulate Sendgrid webhooks using Pokey.}
13
+ spec.homepage = "https://github.com/ccallebs/pokey-sendgrid"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "pokey", "~> 0.2"
22
+ spec.add_runtime_dependency "faker", "~> 1.5"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "pry"
28
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pokey-sendgrid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chuck Callebs
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pokey
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
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: rspec
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
+ description:
98
+ email:
99
+ - chuck@callebs.io
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/pokey/sendgrid.rb
113
+ - lib/pokey/sendgrid/hook.rb
114
+ - lib/pokey/sendgrid/mock_data.rb
115
+ - lib/pokey/sendgrid/version.rb
116
+ - pokey-sendgrid.gemspec
117
+ homepage: https://github.com/ccallebs/pokey-sendgrid
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.8
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Easily simulate Sendgrid webhooks using Pokey.
141
+ test_files: []