cachai 0.1.2 → 0.1.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 +4 -4
- data/cachai.gemspec +2 -2
- data/lib/cachai.rb +13 -15
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 778a415e54b0b9ed2f7d2ceec0c29eb5470b41d4
|
|
4
|
+
data.tar.gz: 8dadf9f3784b8b1160e3ff2b0f3095b6f21e8de1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ea53e02c97f929b3c3f7cbc806d0ef5380b86715e0ef072542c5648ccc18c0159710f2c5528c85f3957e167db9c0063214e2b9e3861d29360bb9a6da1f2033d
|
|
7
|
+
data.tar.gz: 22efbdfaf5ee0c488cf80455ca3297b5907040e159d7fa054af41e5508f55acca5fcb84cd33a8e15fab20ae0909de9db0022d21ac4437e6ed85196c72feddf7b
|
data/cachai.gemspec
CHANGED
|
@@ -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.
|
|
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 "
|
|
29
|
+
spec.add_dependency "rest-client"
|
|
30
30
|
end
|
data/lib/cachai.rb
CHANGED
|
@@ -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
|
|
38
|
-
require '
|
|
39
|
-
@
|
|
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 @
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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.
|
|
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:
|
|
126
|
+
name: rest-client
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - ">="
|