cachai 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/cachai.gemspec +2 -2
  3. data/lib/cachai.rb +13 -15
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50e4a0cf28a5023457d6ef13943c0e414fa0b260
4
- data.tar.gz: 28f0b3c3a87ef6a572d25ad106035c9bb8410972
3
+ metadata.gz: 778a415e54b0b9ed2f7d2ceec0c29eb5470b41d4
4
+ data.tar.gz: 8dadf9f3784b8b1160e3ff2b0f3095b6f21e8de1
5
5
  SHA512:
6
- metadata.gz: c58272c69f77b00efe29462e5cee098039df79aa38b3f1ec4faad4ff0898dd2f2d87690dea5da78bbfa4383bc54520d9c4294666f2d2174072e3d4836c1f14ef
7
- data.tar.gz: 4b4540d5f5c198404f5de336cf1ba94ead68e614853514370c6bacdcaf61115ccd2489b8e450e458c0e64fe74082379a9efe417578647f29e3d663220002c53a
6
+ metadata.gz: 1ea53e02c97f929b3c3f7cbc806d0ef5380b86715e0ef072542c5648ccc18c0159710f2c5528c85f3957e167db9c0063214e2b9e3861d29360bb9a6da1f2033d
7
+ data.tar.gz: 22efbdfaf5ee0c488cf80455ca3297b5907040e159d7fa054af41e5508f55acca5fcb84cd33a8e15fab20ae0909de9db0022d21ac4437e6ed85196c72feddf7b
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "cachai"
7
- spec.version = '0.1.2'
7
+ spec.version = '0.1.3'
8
8
  spec.authors = ["Tomás Pollak"]
9
9
  spec.email = ["tomas@forkhq.com"]
10
10
  spec.description = %q{Middleware for embedabble comments.}
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "sinatra-activerecord"
27
27
  spec.add_dependency "sqlite3"
28
28
  spec.add_dependency "rake"
29
- spec.add_dependency "sendgrid-ruby"
29
+ spec.add_dependency "rest-client"
30
30
  end
@@ -34,9 +34,10 @@ module Cachai
34
34
  puts "No Akismet key found! Will not check comments for spam."
35
35
  end
36
36
 
37
- if sendgrid_opts = opts.delete(:sendgrid)
38
- require 'sendgrid-ruby'
39
- @sendgrid = SendGrid::Client.new(sendgrid_opts)
37
+ if mailgun_opts = opts.delete(:mailgun)
38
+ require 'rest-client'
39
+ @mailgun_domain = mailgun_opts[:domain]
40
+ @mailgun_api_key = mailgun_opts[:api_key]
40
41
  @recipient = opts.delete(:recipient) or raise "No recipient set!"
41
42
  end
42
43
 
@@ -88,7 +89,7 @@ module Cachai
88
89
  post = Post.find_or_create_by_path(data['path'])
89
90
  response = Response.create!(attrs.merge(:post_id => post.id))
90
91
  Cachai.clear_cache(data['path'])
91
- notify_new_response(response, data['path']) if @sendgrid
92
+ notify_new_response(response, data['path']) if @recipient
92
93
 
93
94
  json({ :status => 'ok', :comment => response })
94
95
 
@@ -192,17 +193,14 @@ module Cachai
192
193
  end
193
194
 
194
195
  def notify_new_response(response, path)
195
- mail = SendGrid::Mail.new do |m|
196
- m.to = @recipient
197
- m.from = 'comments@' + Cachai.domain
198
- m.reply_to = response.author_email
199
- m.subject = "New comment from #{response.author_name} at #{path}"
200
- m.text = "#{response.content}\n\n--\nhttp://#{Cachai.domain}/#{path}"
201
- end
202
-
203
- puts @sendgrid.send(mail)
204
- rescue SendGrid::Exception => e
205
- puts e.inspect
196
+ RestClient.post "https://api:#{@mailgun_api_key}"\
197
+ "@api.mailgun.net/v3/#{@mailgun_domain}/messages",
198
+ :from => 'comments@' + Cachai.domain
199
+ :to => @recipient,
200
+ :subject => "New comment from #{response.author_name} at #{path}",
201
+ :text => "#{response.content}\n\n--\nhttp://#{Cachai.domain}/#{path}"
202
+ rescue => e
203
+ puts "MAIL ERROR: #{e.message}"
206
204
  end
207
205
 
208
206
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cachai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: sendgrid-ruby
126
+ name: rest-client
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="