pigeon-ruby 0.6.4 → 0.6.5

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: 2dac127a5ea1a527e870c52772625f5874b7b81175dd0b8c12450cff63c6a847
4
- data.tar.gz: 7daa4c1bc8ff6927cce63522fd5216b111bbbe99d58b4589d2cb3353e624e87e
3
+ metadata.gz: d58454e15366079bbe09c2621460b1e43da1d80ef1ab1ab207fadea6e9ce5ed8
4
+ data.tar.gz: dc2b64e8c7ce1e1d485148c24e91ad457ad3126572144ac0c47c7a48a932bfb0
5
5
  SHA512:
6
- metadata.gz: 927197a29a9f5d577b8c3e043937a83065f31f02a66dfc6a4b563bc0b1d88a3000543910c722314fa576f9f69690cd892620941b7be90fe3dfe26a29592ccdd6
7
- data.tar.gz: a477a73e12b3d16145df8c3868b23168eb5167993ef2f2e0ffa0c4f59d7ff29ef6ce1d99cc3c99d74a1f01246681ec05201f15ada22fedde1749fa5a3b29b893
6
+ metadata.gz: 9c469d5b8857e58f23998bfe430edd146c8e5a41a33c67bcd92f0747b76d2573c649bd29efd6c65ebe3e3695d4d1d32366c799b4a24f3ab86509332a14fcb20b
7
+ data.tar.gz: ec802b1f7bd635936331d1920bac70f8f467567de14561a7d190f451bec44233be9d169837abb5d23c6bb0412231c6323f5863a574a40a6c9c4d0a948a78a591
data/README.md CHANGED
@@ -80,6 +80,18 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
80
80
 
81
81
  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).
82
82
 
83
+ ### Testing
84
+
85
+ You can use the stub option to cause all requests to be stubbed, making it easier to test with this library.
86
+
87
+ ```ruby
88
+ Pigeon.configure do |config|
89
+ .
90
+ .
91
+ config.stub = Rails.env.test? # defaults to false
92
+ end
93
+ ```
94
+
83
95
  ## Contributing
84
96
 
85
97
  Bug reports and pull requests are welcome on GitHub at https://github.com/pigeonapp/pigeon-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -18,7 +18,7 @@ module Pigeon
18
18
  end
19
19
 
20
20
  def deliver(message_identifier, attrs)
21
- self.class.post('/deliveries', {
21
+ send_request(:post, '/deliveries', {
22
22
  body: process_delivery_attributes(attrs).merge({
23
23
  message_identifier: message_identifier
24
24
  })
@@ -26,19 +26,19 @@ module Pigeon
26
26
  end
27
27
 
28
28
  def track(attrs = {})
29
- self.class.post('/event_logs', {
29
+ send_request(:post, '/event_logs', {
30
30
  body: process_track_attributes(attrs)
31
31
  })
32
32
  end
33
33
 
34
34
  def identify(attrs = {})
35
- self.class.post('/customers', {
35
+ send_request(:post, '/customers', {
36
36
  body: process_identify_attributes(attrs)
37
37
  })
38
38
  end
39
39
 
40
40
  def add_contact(customer_id, attrs = {})
41
- self.class.post('/contacts', {
41
+ send_request(:post, '/contacts', {
42
42
  body: process_contact_attributes(customer_id, attrs)
43
43
  })
44
44
  end
@@ -128,5 +128,13 @@ module Pigeon
128
128
  def check_presence!(obj, name = obj)
129
129
  raise ArgumentError, "#{name} cannot be blank." if obj.nil? || (obj.is_a?(String) && obj.empty?)
130
130
  end
131
+
132
+ def send_request(method, path, options)
133
+ if !!@config.stub
134
+ Net::HTTPResponse.new(method, 200, {})
135
+ else
136
+ self.class.send(method, path, options)
137
+ end
138
+ end
131
139
  end
132
140
  end
@@ -3,5 +3,6 @@ module Pigeon
3
3
  attr_accessor :base_uri
4
4
  attr_accessor :public_key
5
5
  attr_accessor :private_key
6
+ attr_accessor :stub
6
7
  end
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module Pigeon
2
- VERSION = '0.6.4'
2
+ VERSION = '0.6.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pigeon-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pradeep Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-25 00:00:00.000000000 Z
11
+ date: 2020-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler