macaco 0.0.4 → 0.0.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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +13 -9
- data/README.md +7 -13
- data/lib/macaco/api.rb +4 -3
- data/lib/macaco/senders/mandrill.rb +5 -0
- data/lib/macaco/senders/sender.rb +1 -1
- data/lib/macaco/senders/sendgrid.rb +9 -16
- data/lib/macaco/version.rb +1 -1
- data/lib/macaco.rb +1 -5
- data/macaco.gemspec +4 -6
- data/spec/lib/macaco/senders/sender_spec.rb +2 -2
- data/spec/lib/macaco/senders/sendgrid_spec.rb +1 -2
- data/spec/lib/macaco_spec.rb +2 -2
- metadata +10 -28
- data/bin/bundler +0 -16
- data/bin/rake +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c311cce7eb6b749472dc6545918ec37cd9b0f4a
|
4
|
+
data.tar.gz: fd41959ac47959eebe4511f602f7d9ddeba47eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807ada9767d78334929d61824d3256e442406ea682867507b358750169d2a3e3cd8bff1b98110514580b84320cfcee64636d090f3e0241379b4b17a4e913a48e
|
7
|
+
data.tar.gz: 050d3a949f4c66deb632cab47e7c6cd75233bd29db41665fa59dd30bc0790f01f79a1fed32ee9c7e1377a2d29bf41aefcf72bf87b4f86b97c4576adb6d9c8986
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
cache: bundler
|
4
|
+
|
3
5
|
rvm:
|
4
|
-
- 1.9.
|
5
|
-
- 1
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- jruby-19mode
|
9
|
-
|
6
|
+
- 1.9.3
|
7
|
+
- 2.1
|
8
|
+
- 2.2
|
9
|
+
- 2.3.0
|
10
|
+
- jruby-19mode
|
11
|
+
|
12
|
+
before_install:
|
13
|
+
- gem install bundler -v 1.11.2
|
14
|
+
|
10
15
|
env:
|
11
16
|
global:
|
12
|
-
- secure:
|
13
|
-
- secure:
|
14
|
-
- secure: dDpqHaTNH7Fway0b0WcVHCuaedMemAv3HMt92xD7wIHYkgue/Selx1MVA9e9f+/+x+2EkzyziktniKBGX77TgpCLBCq5x1CWOTQX0HSOt+hDOgJrLx2Yklo0LKoFGkjDw0tbH9nrMe6tA//bbn9FmUuKO3h5/nV7JZm1bmOQX84=
|
17
|
+
- secure: er1Lqs3NDljT6tTinixr2pHonlCP8G33dW1INaEQwoTFRR9BqRqsfci6LVF9yJH+vtrK1d6Pf+rmtq9Qf8M+PqHmDe5YPhF6qRsrVAcnQt27sYP6c+XPB0v3IY9Nokl8mR+CysLgv/mPwEUEdoMymgpdiTKcA+c3ZOUaoKVk+Is=
|
18
|
+
- secure: pHFAESEdswQm3Ser9ex+gmdRTz0UBEj3+57lzi3lQyZu2cHoV3kEirZjwEdjJUzXcMxV00I2i87ULnO+IuDPvbMvmvncJtseMHQ2WeX17tvWTe5TiEFxLE4IqwzTiHbuFFqAAO6gi+rbNa3St09zAf/7FPDP9aY4+5JSqW8hK/s=
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Macaco
|
2
|
-
[](https://travis-ci.org/jamesduncombe/macaco)
|
3
3
|
|
4
|
-
Tiny wrapper around (
|
4
|
+
Tiny wrapper around [Sendgrid](https://sendgrid.com/docs/API_Reference/Web_API/mail.html#-send) and [Mandrill API's send methods](https://mandrillapp.com/api/docs/messages.JSON.html#method=send).
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -19,24 +19,19 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
However, you can configure Macaco to use a different key by passing a block to the
|
26
|
-
configure method. Here I've used a different environment variable:
|
22
|
+
You can configure Macaco to use your API key by passing a block to the
|
23
|
+
configure method. Here I've used one for Sendgrid:
|
27
24
|
|
28
25
|
```ruby
|
29
26
|
Macaco.configure do |config|
|
30
|
-
config.api_key = ENV['
|
27
|
+
config.api_key = ENV['SENDGRID_API_KEY']
|
31
28
|
end
|
32
29
|
```
|
33
30
|
|
34
|
-
At the moment we just have the [send message](https://mandrillapp.com/api/docs/messages.JSON.html#method=send) method. Use it like this:
|
35
|
-
|
36
31
|
First create a new mail object:
|
37
32
|
|
38
33
|
```ruby
|
39
|
-
mail = Macaco::
|
34
|
+
mail = Macaco::Sendgrid.new do
|
40
35
|
to 'to@test.com'
|
41
36
|
from 'from@test.com'
|
42
37
|
subject 'This is my subject'
|
@@ -54,8 +49,7 @@ mail.send
|
|
54
49
|
## Todo
|
55
50
|
|
56
51
|
- Add further reflection methods to be able to inspect the mail object
|
57
|
-
- Add support for
|
58
|
-
|
52
|
+
- Add support for other API's send methods
|
59
53
|
|
60
54
|
## Contributing
|
61
55
|
|
data/lib/macaco/api.rb
CHANGED
@@ -2,12 +2,10 @@ module Macaco
|
|
2
2
|
class Api
|
3
3
|
|
4
4
|
def self.post(args = {})
|
5
|
-
|
6
5
|
request = request_instance(args)
|
7
6
|
request.body = args[:data]
|
8
7
|
|
9
8
|
JSON.parse(http_response(request, args).body)
|
10
|
-
|
11
9
|
end
|
12
10
|
|
13
11
|
private
|
@@ -17,7 +15,10 @@ module Macaco
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def self.request_instance(args)
|
20
|
-
|
18
|
+
headers = {
|
19
|
+
'Content-Type' => args[:mail].content_type
|
20
|
+
}.merge(args.fetch(:headers) { Hash.new })
|
21
|
+
Net::HTTP::Post.new(args[:mail].api_path, headers)
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.http_instance(args)
|
@@ -2,7 +2,7 @@ module Macaco
|
|
2
2
|
class Sendgrid < Sender
|
3
3
|
|
4
4
|
def docs
|
5
|
-
'
|
5
|
+
'https://sendgrid.com/docs/API_Reference/Web_API/mail.html#-send'
|
6
6
|
end
|
7
7
|
|
8
8
|
def api_root
|
@@ -27,30 +27,23 @@ module Macaco
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
def to(val = nil)
|
31
|
-
return @to unless val
|
32
|
-
@to << val
|
33
|
-
end
|
34
|
-
|
35
30
|
def send
|
36
|
-
data = to_hash
|
37
|
-
Macaco::Api.post({
|
31
|
+
data = to_hash
|
32
|
+
Macaco::Api.post({
|
33
|
+
mail: self,
|
34
|
+
data: convert_data_params(data),
|
35
|
+
headers: { "Authorization" => "Bearer #{api_key}" }
|
36
|
+
})
|
38
37
|
end
|
39
38
|
|
40
39
|
private
|
41
40
|
|
42
41
|
def convert_data_params(data)
|
43
|
-
|
44
|
-
addr.query_values = data
|
45
|
-
addr.query
|
42
|
+
URI.encode_www_form(data)
|
46
43
|
end
|
47
44
|
|
48
45
|
def api_key
|
49
|
-
Macaco.config.api_key || ENV['
|
50
|
-
end
|
51
|
-
|
52
|
-
def api_user
|
53
|
-
Macaco.config.api_user || ENV['MACACO_USER']
|
46
|
+
Macaco.config.api_key || ENV['SENDGRID_API_KEY']
|
54
47
|
end
|
55
48
|
|
56
49
|
end
|
data/lib/macaco/version.rb
CHANGED
data/lib/macaco.rb
CHANGED
data/macaco.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Macaco::VERSION
|
9
9
|
gem.authors = ["James Duncombe"]
|
10
10
|
gem.email = ["james@jamesduncombe.com"]
|
11
|
-
gem.summary = %q{
|
12
|
-
gem.description = %q{Tiny gem to
|
11
|
+
gem.summary = %q{When all you want to do is send email}
|
12
|
+
gem.description = %q{Tiny gem to send email using popular email providers}
|
13
13
|
gem.homepage = "https://github.com/jamesduncombe/macaco"
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
@@ -19,10 +19,8 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
21
|
gem.add_development_dependency 'minitest', '~> 5.0'
|
22
|
-
gem.add_development_dependency 'webmock', '~>
|
23
|
-
gem.add_development_dependency 'vcr', '~>
|
22
|
+
gem.add_development_dependency 'webmock', '~> 0'
|
23
|
+
gem.add_development_dependency 'vcr', '~> 3.0'
|
24
24
|
gem.add_development_dependency 'rake', '~> 10.1'
|
25
25
|
|
26
|
-
gem.add_runtime_dependency 'addressable', '~> 2.3'
|
27
|
-
|
28
26
|
end
|
@@ -21,7 +21,7 @@ describe Macaco::Sender do
|
|
21
21
|
|
22
22
|
describe '#to' do
|
23
23
|
it 'sets the recipient if theres a string provided' do
|
24
|
-
mail.to.must_equal [
|
24
|
+
mail.to.must_equal [ 'to@test.com' ]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -52,5 +52,5 @@ describe Macaco::Sender do
|
|
52
52
|
n.body_text.must_equal 'This is a test'
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
end
|
@@ -5,7 +5,6 @@ describe Macaco::Sendgrid do
|
|
5
5
|
before do
|
6
6
|
Macaco.configure do |config|
|
7
7
|
config.api_key = ENV['SENDGRID_API_KEY']
|
8
|
-
config.api_user = ENV['SENDGRID_USER']
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
@@ -21,7 +20,7 @@ describe Macaco::Sendgrid do
|
|
21
20
|
|
22
21
|
describe '#docs' do
|
23
22
|
it 'returns back the address for the documentation for the REAL API method' do
|
24
|
-
Macaco::Sendgrid.new.docs.must_equal '
|
23
|
+
Macaco::Sendgrid.new.docs.must_equal 'https://sendgrid.com/docs/API_Reference/Web_API/mail.html#-send'
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
data/spec/lib/macaco_spec.rb
CHANGED
@@ -5,9 +5,9 @@ describe Macaco do
|
|
5
5
|
describe '#configure' do
|
6
6
|
it 'configures the gem' do
|
7
7
|
Macaco.configure do |config|
|
8
|
-
config.api_key = '
|
8
|
+
config.api_key = 'YOUR_API_KEY'
|
9
9
|
end
|
10
|
-
Macaco.config.api_key.must_match '
|
10
|
+
Macaco.config.api_key.must_match 'YOUR_API_KEY'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macaco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Duncombe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: vcr
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,26 +66,10 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.1'
|
69
|
-
|
70
|
-
name: addressable
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2.3'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '2.3'
|
83
|
-
description: Tiny gem to wrap Mandrill API's send method without other gem dependencies
|
69
|
+
description: Tiny gem to send email using popular email providers
|
84
70
|
email:
|
85
71
|
- james@jamesduncombe.com
|
86
|
-
executables:
|
87
|
-
- bundler
|
88
|
-
- rake
|
72
|
+
executables: []
|
89
73
|
extensions: []
|
90
74
|
extra_rdoc_files: []
|
91
75
|
files:
|
@@ -95,8 +79,6 @@ files:
|
|
95
79
|
- LICENSE.txt
|
96
80
|
- README.md
|
97
81
|
- Rakefile
|
98
|
-
- bin/bundler
|
99
|
-
- bin/rake
|
100
82
|
- lib/macaco.rb
|
101
83
|
- lib/macaco/api.rb
|
102
84
|
- lib/macaco/senders/mandrill.rb
|
@@ -129,10 +111,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
111
|
version: '0'
|
130
112
|
requirements: []
|
131
113
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.4.8
|
133
115
|
signing_key:
|
134
116
|
specification_version: 4
|
135
|
-
summary:
|
117
|
+
summary: When all you want to do is send email
|
136
118
|
test_files:
|
137
119
|
- spec/lib/macaco/senders/mandrill_spec.rb
|
138
120
|
- spec/lib/macaco/senders/sender_spec.rb
|
data/bin/bundler
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'bundler' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('macaco', 'bundler')
|
data/bin/rake
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rake' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('macaco', 'rake')
|