sendgrid_ruby 0.0.1 → 0.0.3

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
  SHA1:
3
- metadata.gz: de1314e5105ecfc087659fd6ceedc9c61ec51545
4
- data.tar.gz: eedb261cf51d403b09dfbdfc5edd64fba1a878d3
3
+ metadata.gz: 30e2b87da6d8e5c9c53553e02cc568b944367396
4
+ data.tar.gz: ecfba134d8e2f5f268ff1e62775e2492445bd71a
5
5
  SHA512:
6
- metadata.gz: 67a3bc99c2bffbc1df7ea30f78983ac6c79266b57f3b3ecd9d68073b412fdf3985ea69b0b3ffad6682313ee07de68cc97a59bba324439de6e881a8ae912a9f6c
7
- data.tar.gz: bb1c2b20b7ca2484704bc2b042a1cc3461be145419c48d37a3749d262a23205ebf1880f520e21c3d43bacefed6c1084939d068506d45a344b8909fa81ae8e0dd
6
+ metadata.gz: dc2f049217ef17b4e8793b1ed71c1f6ba9d262955f0aae5b41ead6c9a7c80e1cc58d1565644e7f447741d5e1ef65847c689bca510a46d9437a29b500dc2d6f72
7
+ data.tar.gz: e874813cc42d235cb81eb08e4ae6ebe127add052395ce5f1201d23acc10ded445d0069c512db79b3605a6216801626397d7e84ea8283aa4f34099c1c14d2bf3e
data/.env.example ADDED
@@ -0,0 +1,4 @@
1
+ SENDGRID_USERNAME=your_username
2
+ SENDGRID_PASSWORD=your_password
3
+ TOS=you@youremail.com,friend1@friendemail.com,friend2@friendemail.com
4
+ FROM=you@youremail.com
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .env
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # sendgrid_ruby
2
2
 
3
- This gem allows you to quickly and easily send emails through SendGrid using Ruby.
3
+ This gem allows you to quickly and easily send emails through SendGrid using Ruby.
4
+ See [Usage](https://github.com/SendGridJP/sendgridjp-ruby-example).
4
5
 
5
6
  [![Build Status](https://travis-ci.org/SendGridJP/sendgrid-ruby.svg?branch=master)](https://travis-ci.org/SendGridJP/sendgrid-ruby)
6
7
 
@@ -284,7 +284,7 @@ module SendgridRuby
284
284
  web = {
285
285
  'to' => @to,
286
286
  'from' => get_from,
287
- 'x-smtpapi' => @smtpapi.json_string,
287
+ 'x-smtpapi' => @smtpapi.to_json,
288
288
  'subject' => @subject,
289
289
  'text' => @text,
290
290
  'html' => @html,
@@ -1,3 +1,3 @@
1
1
  module SendgridRuby
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/sendgrid_ruby.rb CHANGED
@@ -22,7 +22,9 @@ module SendgridRuby
22
22
 
23
23
  RestClient.log = $stderr if @debug_output
24
24
 
25
- response = RestClient.post 'https://api.sendgrid.com/api/mail.send.json', form, :content_type => :json
25
+ headers = Hash.new
26
+ headers[:content_type] = :json
27
+ response = RestClient.post 'https://api.sendgrid.com/api/mail.send.json', form, :content_type => :json, "User-Agent" => "sendgrid/#{SendgridRuby::VERSION};ruby"
26
28
 
27
29
  JSON.parse(response.body)
28
30
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "rest-client"
23
23
  spec.add_development_dependency "bundler", "~> 1.5"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "dotenv"
25
26
  end
@@ -1,13 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require "test/unit"
3
+ require "dotenv"
3
4
  require "./lib/sendgrid_ruby"
4
5
  require "./lib/sendgrid_ruby/version"
5
6
  require "./lib/sendgrid_ruby/email"
6
7
 
7
8
  class SendgridRubyTest < Test::Unit::TestCase
8
9
 
10
+ def setup
11
+ config = Dotenv.load
12
+ @username = ENV["SENDGRID_USERNAME"]
13
+ @password = ENV["SENDGRID_PASSWORD"]
14
+ @from = ENV["FROM"]
15
+ @tos = ENV["TOS"].split(',') if ENV["TOS"] != nil
16
+ end
17
+
9
18
  def test_version
10
- assert_equal("0.0.1", SendgridRuby::VERSION)
19
+ assert_equal("0.0.3", SendgridRuby::VERSION)
11
20
  end
12
21
 
13
22
  def test_initialize
@@ -127,4 +136,21 @@ class SendgridRubyTest < Test::Unit::TestCase
127
136
 
128
137
  end
129
138
 
139
+ def test_send_if_avairable
140
+
141
+ if @from == nil || @tos == nil
142
+ return
143
+ end
144
+
145
+ email = SendgridRuby::Email.new
146
+ email.set_from(@from).
147
+ set_subject('test_send subject').
148
+ set_text('foobar text').
149
+ add_to(@tos[0])
150
+
151
+ sendgrid = SendgridRuby::Sendgrid.new(@username, @password)
152
+ sendgrid.debug_output = true
153
+ sendgrid.send(email)
154
+ end
155
+
130
156
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wataru Sato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smtpapi
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
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'
69
83
  description: Web API wrapper for SendGrid.
70
84
  email:
71
85
  - awwa500@gmail.com
@@ -73,6 +87,7 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - ".env.example"
76
91
  - ".gitignore"
77
92
  - ".travis.yml"
78
93
  - Gemfile
@@ -110,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
125
  version: '0'
111
126
  requirements: []
112
127
  rubyforge_project:
113
- rubygems_version: 2.2.1
128
+ rubygems_version: 2.2.2
114
129
  signing_key:
115
130
  specification_version: 4
116
131
  summary: Web API wrapper for SendGrid.
@@ -122,3 +137,4 @@ test_files:
122
137
  - test/gif.gif
123
138
  - test/sendgrid_ruby.rb
124
139
  - test/sendgrid_ruby/email.rb
140
+ has_rdoc: