ungulate 0.0.10 → 0.0.11
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.
- data/VERSION +1 -1
- data/lib/ungulate/job.rb +15 -1
- data/spec/ungulate/job_spec.rb +34 -1
- data/ungulate.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11
|
data/lib/ungulate/job.rb
CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
|
|
6
6
|
|
7
7
|
module Ungulate
|
8
8
|
class Job
|
9
|
-
attr_accessor :bucket, :key, :queue, :versions
|
9
|
+
attr_accessor :bucket, :key, :notification_url, :queue, :versions
|
10
10
|
|
11
11
|
def self.s3
|
12
12
|
@s3 ||=
|
@@ -37,6 +37,7 @@ module Ungulate
|
|
37
37
|
def attributes=(options)
|
38
38
|
self.bucket = Job.s3.bucket(options[:bucket])
|
39
39
|
self.key = options[:key]
|
40
|
+
self.notification_url = options[:notification_url]
|
40
41
|
self.versions = options[:versions]
|
41
42
|
end
|
42
43
|
|
@@ -79,6 +80,19 @@ module Ungulate
|
|
79
80
|
)
|
80
81
|
image.destroy!
|
81
82
|
end
|
83
|
+
send_notification
|
84
|
+
end
|
85
|
+
|
86
|
+
def send_notification
|
87
|
+
return false if notification_url.blank?
|
88
|
+
|
89
|
+
@logger.info "Sending notification to #{notification_url}"
|
90
|
+
|
91
|
+
url = URI.parse(notification_url)
|
92
|
+
|
93
|
+
Net::HTTP.start(url.host) do |http|
|
94
|
+
http.put(url.path, nil)
|
95
|
+
end
|
82
96
|
end
|
83
97
|
|
84
98
|
def version_key(version)
|
data/spec/ungulate/job_spec.rb
CHANGED
@@ -99,7 +99,8 @@ module Ungulate
|
|
99
99
|
job.attributes = {
|
100
100
|
:bucket => 'hello',
|
101
101
|
:key => 'path/to/filename.gif',
|
102
|
-
:versions => @versions
|
102
|
+
:versions => @versions,
|
103
|
+
:notification_url => 'http://some.host/with/simple/path',
|
103
104
|
}
|
104
105
|
job
|
105
106
|
end
|
@@ -107,6 +108,7 @@ module Ungulate
|
|
107
108
|
its(:bucket) { should == @bucket }
|
108
109
|
its(:key) { should == 'path/to/filename.gif' }
|
109
110
|
its(:versions) { should == @versions }
|
111
|
+
its(:notification_url) { should == 'http://some.host/with/simple/path' }
|
110
112
|
end
|
111
113
|
|
112
114
|
describe :source do
|
@@ -175,6 +177,7 @@ module Ungulate
|
|
175
177
|
job.stub(:bucket).and_return(@bucket)
|
176
178
|
job.stub(:version_key).with(:big).and_return('path/to/someimage_big.jpg')
|
177
179
|
job.stub(:version_key).with(:little).and_return('path/to/someimage_little.jpg')
|
180
|
+
job.stub(:send_notification)
|
178
181
|
job
|
179
182
|
end
|
180
183
|
|
@@ -203,6 +206,10 @@ module Ungulate
|
|
203
206
|
expected_headers)
|
204
207
|
end
|
205
208
|
|
209
|
+
it "should notify" do
|
210
|
+
subject.should_receive(:send_notification)
|
211
|
+
end
|
212
|
+
|
206
213
|
context "empty array" do
|
207
214
|
before do
|
208
215
|
subject.stub(:processed_versions).and_return([])
|
@@ -213,6 +220,32 @@ module Ungulate
|
|
213
220
|
end
|
214
221
|
end
|
215
222
|
|
223
|
+
describe :send_notification do
|
224
|
+
after { subject.send_notification }
|
225
|
+
|
226
|
+
context "notification URL provided" do
|
227
|
+
before do
|
228
|
+
subject.stub(:notification_url).and_return('http://some.host/processing_images/some/path')
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should PUT to the URL" do
|
232
|
+
http = mock('Net::HTTP')
|
233
|
+
Net::HTTP.stub(:start).with('some.host').and_yield(http)
|
234
|
+
http.should_receive(:put).with('/processing_images/some/path', nil)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context "notification URL not provided" do
|
239
|
+
before do
|
240
|
+
subject.stub(:notification_url).and_return(nil)
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should not PUT" do
|
244
|
+
Net::HTTP.should_not_receive(:put)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
216
249
|
describe :version_key do
|
217
250
|
subject do
|
218
251
|
job = Job.new
|
data/ungulate.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ungulate}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew Bruce"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-13}
|
13
13
|
s.default_executable = %q{ungulate_server.rb}
|
14
14
|
s.description = %q{WIP}
|
15
15
|
s.email = %q{andrew@camelpunch.com}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ungulate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 11
|
10
|
+
version: 0.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Bruce
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-13 00:00:00 +01:00
|
19
19
|
default_executable: ungulate_server.rb
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|