pigeon-ruby 0.3.1 → 0.3.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 +5 -5
- data/.gitignore +1 -0
- data/README.md +66 -3
- data/bin/console +3 -10
- data/bin/setup +0 -2
- data/lib/pigeon-ruby/client.rb +24 -2
- data/lib/pigeon-ruby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ab603586f5144bc39ea234f69d78340a81e37947
|
4
|
+
data.tar.gz: c6fbe3a2a0f33aba53024d5cdf12246d909db40f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67bdf87432736cd695d56666a4d9a2ef872115d7b6e93f2552906d0729699722fb4da9b21d5c9d66c6e273abc2af828fc9c89b3b1b998c5eb4ef7dd91551e9ec
|
7
|
+
data.tar.gz: 703a6edc1721c1441a85478efa569d1914b50e4f1821f8ce047f150501eec499dc80eaee55b0755fa56f838f7f2e6f3443ef150c8992a373833585517bbecdb6
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -18,10 +18,60 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install pigeon
|
20
20
|
|
21
|
+
|
21
22
|
## Usage
|
22
23
|
|
24
|
+
```ruby
|
25
|
+
Pigeon.deliver('message-identifier', to: 'john@example.com')
|
23
26
|
```
|
24
|
-
|
27
|
+
|
28
|
+
## Configuration
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Pigeon.configure do |config|
|
32
|
+
config.public_key = ENV['PIGEON_PUBLIC_KEY']
|
33
|
+
config.private_key = ENV['PIGEON_PRIVATE_KEY']
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
To integrate Pigeon with your Rails application, create a new initializer `config/initializers/pigeon.rb`.
|
38
|
+
|
39
|
+
## Examples
|
40
|
+
|
41
|
+
### Multiple recipients
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Pigeon.deliver('message-identifier', {
|
45
|
+
to: 'John Doe <john@example.com>',
|
46
|
+
cc: ['admin@example.com', 'sales@example.com>']
|
47
|
+
})
|
48
|
+
```
|
49
|
+
|
50
|
+
### Template variables
|
51
|
+
|
52
|
+
Template variables are passed inside `:data`.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
Pigeon.deliver('message-identifier', {
|
56
|
+
to: 'john@example.com',
|
57
|
+
data: { name: 'John' }
|
58
|
+
})
|
59
|
+
```
|
60
|
+
|
61
|
+
### Attachments support
|
62
|
+
|
63
|
+
`:file` can be a local file path, remote URL, or a File object.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
Pigeon.deliver('message-identifier', {
|
67
|
+
to: 'jane@example.com',
|
68
|
+
attachments: [
|
69
|
+
{
|
70
|
+
file: '/path/to/handbook.pdf',
|
71
|
+
name: 'Handbook'
|
72
|
+
}
|
73
|
+
]
|
74
|
+
})
|
25
75
|
```
|
26
76
|
|
27
77
|
## Development
|
@@ -32,7 +82,20 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
82
|
|
33
83
|
## Contributing
|
34
84
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
85
|
+
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.
|
86
|
+
|
87
|
+
## Releasing
|
88
|
+
|
89
|
+
We use the [gem-release](https://github.com/svenfuchs/gem-release) library for versioning, tagging and releasing.
|
90
|
+
|
91
|
+
```
|
92
|
+
gem bump
|
93
|
+
gem release
|
94
|
+
gem tag --push
|
95
|
+
git push origin master
|
96
|
+
```
|
97
|
+
|
98
|
+
Use `gem bump -v [major|minor|patch|pre|release|x.x.x]` for specific version increases.
|
36
99
|
|
37
100
|
## License
|
38
101
|
|
@@ -40,4 +103,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
103
|
|
41
104
|
## Code of Conduct
|
42
105
|
|
43
|
-
Everyone interacting in the Pigeon project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
106
|
+
Everyone interacting in the Pigeon project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pigeonapp/pigeon-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/console
CHANGED
@@ -1,14 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'pigeon-ruby'
|
5
|
+
require 'irb'
|
5
6
|
|
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
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
7
|
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
data/lib/pigeon-ruby/client.rb
CHANGED
@@ -7,7 +7,7 @@ module Pigeon
|
|
7
7
|
def initialize(config)
|
8
8
|
@config = config
|
9
9
|
|
10
|
-
self.class.base_uri(@config.base_uri || 'https://api.pigeonapp.io')
|
10
|
+
self.class.base_uri(@config.base_uri || 'https://api.pigeonapp.io/v1')
|
11
11
|
end
|
12
12
|
|
13
13
|
def deliver(message_identifier, parcels = nil)
|
@@ -18,9 +18,31 @@ module Pigeon
|
|
18
18
|
},
|
19
19
|
body: {
|
20
20
|
message_identifier: message_identifier,
|
21
|
-
parcels: parcels
|
21
|
+
parcels: process_parcels(parcels)
|
22
22
|
}
|
23
23
|
})
|
24
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def process_parcels(parcels)
|
29
|
+
parcels = [parcels] if parcels.is_a? Hash
|
30
|
+
|
31
|
+
parcels.each do |parcel|
|
32
|
+
(parcel[:attachments] || []).each do |attachment|
|
33
|
+
next unless File.file?(attachment[:file])
|
34
|
+
|
35
|
+
prepare_attachment_content(attachment)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def prepare_attachment_content(attachment)
|
41
|
+
file = attachment[:file]
|
42
|
+
file = File.open(file) if file.is_a? String
|
43
|
+
attachment[:content] = Base64.strict_encode64(file.read)
|
44
|
+
attachment[:name] ||= File.basename(file, '.*')
|
45
|
+
attachment.delete(:file)
|
46
|
+
end
|
25
47
|
end
|
26
48
|
end
|
data/lib/pigeon-ruby/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pradeep Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.12
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Pigeon Ruby Library
|