tootsie 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ module Tootsie
2
+ module Tasks
3
+
4
+ class NotifyTask
5
+
6
+ def initialize(attributes = {})
7
+ attributes = attributes.with_indifferent_access
8
+ @url = attributes[:url]
9
+ @message = attributes[:message]
10
+ end
11
+
12
+ def execute!
13
+ Application.get.logger.info "Notifying #{@url} with message: #{@message.inspect}"
14
+ HTTPClient.new.post(@url, @message)
15
+ end
16
+
17
+ def attributes
18
+ {:url => @url, :message => @message}
19
+ end
20
+
21
+ attr_accessor :url
22
+ attr_accessor :message
23
+
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Tootsie
2
+ VERSION = '0.9.0'
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'sinatra/base'
2
+
3
+ module Tootsie
4
+
5
+ class WebService < Sinatra::Base
6
+ set :sessions, false
7
+ set :run, false
8
+
9
+ get '/' do
10
+ 404
11
+ end
12
+
13
+ post '/job' do
14
+ job_data = JSON.parse(request.env["rack.input"].read)
15
+ logger.info "Handling job: #{job_data.inspect}"
16
+ job = Tasks::JobTask.new(job_data)
17
+ unless job.valid?
18
+ halt 400, 'Invalid job specification'
19
+ end
20
+ Application.get.task_manager.schedule(job)
21
+ 201
22
+ end
23
+
24
+ get '/status' do
25
+ queue = Application.get.queue
26
+ {'queue_count' => queue.count}.to_json
27
+ end
28
+
29
+ private
30
+
31
+ def logger
32
+ return @logger ||= Application.get.logger
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,21 @@
1
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'bundler'
6
+ rescue LoadError
7
+ # Ignore this
8
+ else
9
+ Bundler.setup(:test)
10
+ end
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+
15
+ require 'rspec'
16
+ require 'rspec/autorun'
17
+ require 'pp'
18
+ require 'tootsie'
19
+
20
+ # Ensure application exists
21
+ Tootsie::Application.new
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Tootsie::CommandRunner do
6
+
7
+ it 'run simple commands' do
8
+ Tootsie::CommandRunner.new('ls').run.should == true
9
+ end
10
+
11
+ it 'replace arguments in command lines' do
12
+ lines = []
13
+ Tootsie::CommandRunner.new('echo :text').run(:text => "test") do |line|
14
+ lines << line.strip
15
+ end
16
+ lines.should == ["test"]
17
+ end
18
+
19
+ it 'throw exceptions on failure' do
20
+ lambda { Tootsie::CommandRunner.new('exit 1').run }.should raise_error(
21
+ Tootsie::CommandExecutionFailed)
22
+ end
23
+
24
+ it 'not throw exceptions on failure with option' do
25
+ lambda { Tootsie::CommandRunner.new('exit 1', :ignore_exit_code => true).run }.should_not raise_error
26
+ Tootsie::CommandRunner.new('exit 1', :ignore_exit_code => true).run.should == false
27
+ end
28
+
29
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Tootsie::ImageMetadataExtractor do
6
+
7
+ it 'should read EXIF data' do
8
+ extractor = Tootsie::ImageMetadataExtractor.new
9
+ extractor.extract_from_file(
10
+ File.expand_path('../../test_files/BF 0622 1820.tif', __FILE__))
11
+ extractor.metadata['Exif.Image.ImageWidth'][:type].should == 'short'
12
+ extractor.metadata['Exif.Image.ImageWidth'][:value].should == 10
13
+ extractor.metadata['Exif.Image.ImageLength'][:type].should == 'short'
14
+ extractor.metadata['Exif.Image.ImageLength'][:value].should == 10
15
+ extractor.metadata['Exif.Image.ImageDescription'][:type].should == 'ascii'
16
+ extractor.metadata['Exif.Image.ImageDescription'][:value].should == 'Tømmer på vannet ved Krøderen'
17
+ end
18
+
19
+ it 'should read IPTC data' do
20
+ extractor = Tootsie::ImageMetadataExtractor.new
21
+ extractor.extract_from_file(
22
+ File.expand_path('../../test_files/BF 0622 1820.tif', __FILE__))
23
+ extractor.metadata['Iptc.Application2.City'][:type].should == 'string'
24
+ extractor.metadata['Iptc.Application2.City'][:value].should == 'Krødsherad'
25
+ extractor.metadata['Iptc.Application2.ObjectName'][:type].should == 'string'
26
+ extractor.metadata['Iptc.Application2.ObjectName'][:value].should == 'Parti fra Krødsherad'
27
+ end
28
+
29
+ it 'should read XMP data' do
30
+ extractor = Tootsie::ImageMetadataExtractor.new
31
+ extractor.extract_from_file(
32
+ File.expand_path('../../test_files/BF 0622 1820.tif', __FILE__))
33
+ extractor.metadata['Xmp.dc.description'][:type].should == 'lang_alt'
34
+ extractor.metadata['Xmp.dc.description'][:value].should == 'lang="x-default" Tømmer på vannet ved Krøderen'
35
+ extractor.metadata['Xmp.tiff.YResolution'][:type].should == 'xmp_text'
36
+ extractor.metadata['Xmp.tiff.YResolution'][:value].should == '300'
37
+ end
38
+
39
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Tootsie::S3Utilities do
6
+
7
+ it 'parses URIs with bucket and path' do
8
+ out = Tootsie::S3Utilities.parse_uri("s3:mybucket/some/path")
9
+ out[:bucket].should == 'mybucket'
10
+ out[:key].should == 'some/path'
11
+ out.length.should == 2
12
+ end
13
+
14
+ it 'parses URIs and returns indifferent hash' do
15
+ out = Tootsie::S3Utilities.parse_uri("s3:mybucket/some/path")
16
+ out[:bucket].should == out['bucket']
17
+ end
18
+
19
+ it 'parses URIs with bucket and path and one key' do
20
+ out = Tootsie::S3Utilities.parse_uri("s3:mybucket/some/path?a=1")
21
+ out[:bucket].should == 'mybucket'
22
+ out[:key].should == 'some/path'
23
+ out[:a].to_s.should == '1'
24
+ out.length.should == 3
25
+ end
26
+
27
+ it 'parses URIs with bucket and path and multiple keys' do
28
+ out = Tootsie::S3Utilities.parse_uri("s3:mybucket/some/path?a=1&b=2")
29
+ out[:bucket].should == 'mybucket'
30
+ out[:key].should == 'some/path'
31
+ out[:a].to_s.should == '1'
32
+ out[:b].to_s.should == '2'
33
+ out.length.should == 4
34
+ end
35
+
36
+ it 'throws exceptions on non-S3 URIs' do
37
+ lambda { Tootsie::S3Utilities.parse_uri('http://example.com/') }.should raise_error
38
+ end
39
+
40
+ end
metadata ADDED
@@ -0,0 +1,337 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tootsie
3
+ version: !ruby/object:Gem::Version
4
+ hash: 59
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
+ platform: ruby
12
+ authors:
13
+ - Alexander Staubo
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 1
31
+ - 4
32
+ - 6
33
+ version: 1.4.6
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: sinatra
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: activesupport
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 3
62
+ - 0
63
+ - 0
64
+ version: 3.0.0
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: httpclient
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 5
76
+ segments:
77
+ - 2
78
+ - 2
79
+ - 1
80
+ version: 2.2.1
81
+ type: :runtime
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: builder
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ hash: 15
92
+ segments:
93
+ - 2
94
+ - 1
95
+ - 2
96
+ version: 2.1.2
97
+ type: :runtime
98
+ version_requirements: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ name: mime-types
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ~>
106
+ - !ruby/object:Gem::Version
107
+ hash: 47
108
+ segments:
109
+ - 1
110
+ - 16
111
+ version: "1.16"
112
+ type: :runtime
113
+ version_requirements: *id006
114
+ - !ruby/object:Gem::Dependency
115
+ name: xml-simple
116
+ prerelease: false
117
+ requirement: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ hash: 15
123
+ segments:
124
+ - 1
125
+ - 0
126
+ - 12
127
+ version: 1.0.12
128
+ type: :runtime
129
+ version_requirements: *id007
130
+ - !ruby/object:Gem::Dependency
131
+ name: thin
132
+ prerelease: false
133
+ requirement: &id008 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ hash: 17
139
+ segments:
140
+ - 1
141
+ - 2
142
+ - 7
143
+ version: 1.2.7
144
+ type: :runtime
145
+ version_requirements: *id008
146
+ - !ruby/object:Gem::Dependency
147
+ name: s3
148
+ prerelease: false
149
+ requirement: &id009 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ~>
153
+ - !ruby/object:Gem::Version
154
+ hash: 29
155
+ segments:
156
+ - 0
157
+ - 3
158
+ - 7
159
+ version: 0.3.7
160
+ type: :runtime
161
+ version_requirements: *id009
162
+ - !ruby/object:Gem::Dependency
163
+ name: sqs
164
+ prerelease: false
165
+ requirement: &id010 !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ~>
169
+ - !ruby/object:Gem::Version
170
+ hash: 31
171
+ segments:
172
+ - 0
173
+ - 1
174
+ - 2
175
+ version: 0.1.2
176
+ type: :runtime
177
+ version_requirements: *id010
178
+ - !ruby/object:Gem::Dependency
179
+ name: unicorn
180
+ prerelease: false
181
+ requirement: &id011 !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ~>
185
+ - !ruby/object:Gem::Version
186
+ hash: 57
187
+ segments:
188
+ - 4
189
+ - 1
190
+ - 1
191
+ version: 4.1.1
192
+ type: :runtime
193
+ version_requirements: *id011
194
+ - !ruby/object:Gem::Dependency
195
+ name: i18n
196
+ prerelease: false
197
+ requirement: &id012 !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ hash: 11
203
+ segments:
204
+ - 0
205
+ - 4
206
+ - 2
207
+ version: 0.4.2
208
+ type: :runtime
209
+ version_requirements: *id012
210
+ - !ruby/object:Gem::Dependency
211
+ name: scashin133-syslog_logger
212
+ prerelease: false
213
+ requirement: &id013 !ruby/object:Gem::Requirement
214
+ none: false
215
+ requirements:
216
+ - - ~>
217
+ - !ruby/object:Gem::Version
218
+ hash: 13
219
+ segments:
220
+ - 1
221
+ - 7
222
+ - 3
223
+ version: 1.7.3
224
+ type: :runtime
225
+ version_requirements: *id013
226
+ - !ruby/object:Gem::Dependency
227
+ name: rspec
228
+ prerelease: false
229
+ requirement: &id014 !ruby/object:Gem::Requirement
230
+ none: false
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ hash: 3
235
+ segments:
236
+ - 0
237
+ version: "0"
238
+ type: :development
239
+ version_requirements: *id014
240
+ - !ruby/object:Gem::Dependency
241
+ name: rake
242
+ prerelease: false
243
+ requirement: &id015 !ruby/object:Gem::Requirement
244
+ none: false
245
+ requirements:
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ hash: 3
249
+ segments:
250
+ - 0
251
+ version: "0"
252
+ type: :development
253
+ version_requirements: *id015
254
+ description: Tootsie is a simple audio/video/image transcoding/modification application.
255
+ email:
256
+ - alex@origo.no
257
+ executables:
258
+ - tootsie_task_manager
259
+ extensions: []
260
+
261
+ extra_rdoc_files: []
262
+
263
+ files:
264
+ - .gitignore
265
+ - Gemfile
266
+ - License
267
+ - README.md
268
+ - Rakefile
269
+ - Tootsie.gemspec
270
+ - bin/tootsie_task_manager
271
+ - config.ru
272
+ - config/development-sample.yml
273
+ - lib/tootsie.rb
274
+ - lib/tootsie/application.rb
275
+ - lib/tootsie/client.rb
276
+ - lib/tootsie/command_runner.rb
277
+ - lib/tootsie/configuration.rb
278
+ - lib/tootsie/daemon.rb
279
+ - lib/tootsie/ffmpeg_adapter.rb
280
+ - lib/tootsie/image_metadata_extractor.rb
281
+ - lib/tootsie/input.rb
282
+ - lib/tootsie/output.rb
283
+ - lib/tootsie/processors/image_processor.rb
284
+ - lib/tootsie/processors/video_processor.rb
285
+ - lib/tootsie/queues/file_system_queue.rb
286
+ - lib/tootsie/queues/sqs_queue.rb
287
+ - lib/tootsie/s3_utilities.rb
288
+ - lib/tootsie/spawner.rb
289
+ - lib/tootsie/task_manager.rb
290
+ - lib/tootsie/tasks/job_task.rb
291
+ - lib/tootsie/tasks/notify_task.rb
292
+ - lib/tootsie/version.rb
293
+ - lib/tootsie/web_service.rb
294
+ - spec/spec_helper.rb
295
+ - spec/test_files/BF 0622 1820.tif
296
+ - spec/tootsie/command_runner_spec.rb
297
+ - spec/tootsie/image_metadata_extracter_spec.rb
298
+ - spec/tootsie/s3_utilities_spec.rb
299
+ homepage: http://github.com/alexstaubo/tootsie
300
+ licenses: []
301
+
302
+ post_install_message:
303
+ rdoc_options: []
304
+
305
+ require_paths:
306
+ - lib
307
+ required_ruby_version: !ruby/object:Gem::Requirement
308
+ none: false
309
+ requirements:
310
+ - - ">="
311
+ - !ruby/object:Gem::Version
312
+ hash: 3
313
+ segments:
314
+ - 0
315
+ version: "0"
316
+ required_rubygems_version: !ruby/object:Gem::Requirement
317
+ none: false
318
+ requirements:
319
+ - - ">="
320
+ - !ruby/object:Gem::Version
321
+ hash: 3
322
+ segments:
323
+ - 0
324
+ version: "0"
325
+ requirements: []
326
+
327
+ rubyforge_project: tootsie
328
+ rubygems_version: 1.8.6
329
+ signing_key:
330
+ specification_version: 3
331
+ summary: Tootsie is a simple audio/video/image transcoding/modification application.
332
+ test_files:
333
+ - spec/spec_helper.rb
334
+ - spec/test_files/BF 0622 1820.tif
335
+ - spec/tootsie/command_runner_spec.rb
336
+ - spec/tootsie/image_metadata_extracter_spec.rb
337
+ - spec/tootsie/s3_utilities_spec.rb