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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 417ea3b3aa99576f3ee03f7c7eda300fbe11fb1ea9826862d60d2cf99b4faf73
4
- data.tar.gz: 2e3c8a0c56b7eb1e10875915dc5bc1d25f00c04b1e545720475df016d052c81f
2
+ SHA1:
3
+ metadata.gz: ab603586f5144bc39ea234f69d78340a81e37947
4
+ data.tar.gz: c6fbe3a2a0f33aba53024d5cdf12246d909db40f
5
5
  SHA512:
6
- metadata.gz: 1f6ae48fb22ebf2753df62a5b6a0acbf0814f4e93807891044ecaec78834dcf035b74fc00072e4ca2b0d839aed271ba6c601775889c957b688b8d0bcd57440fc
7
- data.tar.gz: 5648b6c7f0b5a12091ba6007efe83dbcbc8037e80e499893ff17dd8952d25f30a9be1c3074149e1e6781e968e6f1c14f09a6ca8ada4c8536ff0fca81fc207a60
6
+ metadata.gz: 67bdf87432736cd695d56666a4d9a2ef872115d7b6e93f2552906d0729699722fb4da9b21d5c9d66c6e273abc2af828fc9c89b3b1b998c5eb4ef7dd91551e9ec
7
+ data.tar.gz: 703a6edc1721c1441a85478efa569d1914b50e4f1821f8ce047f150501eec499dc80eaee55b0755fa56f838f7f2e6f3443ef150c8992a373833585517bbecdb6
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
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
- Pigeon.deliver('message-identifier', to: 'user@example.com')
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/[USERNAME]/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.
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/[USERNAME]/pigeon-ruby/blob/master/CODE_OF_CONDUCT.md).
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).
@@ -1,14 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "pigeon"
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
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pigeon
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
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.3.1
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-01-12 00:00:00.000000000 Z
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.7.6
112
+ rubygems_version: 2.6.12
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Pigeon Ruby Library