phocoder-rails 0.0.42 → 0.0.43
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -6
- data/README.md +108 -0
- data/VERSION +1 -1
- data/app/models/encodable_job.rb +63 -2
- data/lib/phocoder_rails/acts_as_phocodable.rb +3 -2
- data/lib/tasks/phocoder_rails/phocoder_rails.rake +12 -0
- data/phocoder-rails.gemspec +4 -2
- data/spec/helpers/phocoder_helper_spec.rb +9 -9
- data/spec/integration/navigation_spec.rb +6 -6
- data/spec/models/acts_as_phocodable_spec.rb +3 -1
- data/spec/models/encodable_job_spec.rb +64 -19
- data/spec/spec_helper.rb +2 -1
- metadata +98 -145
- data/README.rdoc +0 -3
data/Gemfile
CHANGED
@@ -14,6 +14,7 @@ gem "rails", ">=3.0.0"
|
|
14
14
|
|
15
15
|
gem 'phocoder-rb'
|
16
16
|
gem 'zencoder'
|
17
|
+
gem "mimetype-fu", "~> 0.1.2"
|
17
18
|
gem 'aws-s3', :require => 'aws/s3'
|
18
19
|
#gem "spawn", :git => "git://github.com/jagthedrummer/spawn.git"
|
19
20
|
gem "spawn", :git => 'git://github.com/tra/spawn', :branch => "edge"
|
@@ -26,9 +27,9 @@ gem "spawn", :git => 'git://github.com/tra/spawn', :branch => "edge"
|
|
26
27
|
|
27
28
|
group :development do
|
28
29
|
gem 'rspec-rails', '2.4.1'
|
29
|
-
gem "bundler"
|
30
|
-
gem "jeweler"
|
31
|
-
gem "rcov", ">= 0"
|
30
|
+
gem "bundler"
|
31
|
+
gem "jeweler"
|
32
|
+
#gem "rcov", ">= 0"
|
32
33
|
end
|
33
34
|
|
34
35
|
group :test do
|
@@ -37,9 +38,9 @@ group :test do
|
|
37
38
|
gem "sqlite3-ruby", :require => "sqlite3"
|
38
39
|
gem 'rspec', '2.4.0'
|
39
40
|
gem 'rspec-rails', '2.4.1'
|
40
|
-
gem "bundler"
|
41
|
-
gem "jeweler"
|
42
|
-
gem "rcov", ">= 0"
|
41
|
+
gem "bundler"
|
42
|
+
gem "jeweler"
|
43
|
+
#gem "rcov", ">= 0"
|
43
44
|
gem 'autotest', '4.4.4'
|
44
45
|
gem 'redgreen', '1.2.2'
|
45
46
|
gem "webmock"
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
PhocoderRails
|
2
|
+
================================
|
3
|
+
|
4
|
+
PhocoderRails is a rails engine that makes it incredibly easy to integrate your rails app
|
5
|
+
with the [Phocoder](http://www.phocoder.com/) image processing service.
|
6
|
+
|
7
|
+
## Installing
|
8
|
+
|
9
|
+
Add this to your Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "phocoder-rails"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then run:
|
16
|
+
|
17
|
+
```term
|
18
|
+
bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
Then you need to generate a config file and a migration for tracking job status.
|
22
|
+
|
23
|
+
```term
|
24
|
+
rails g phocoder_rails:setup
|
25
|
+
create db/migrate/xxxxxxxx_create_encodable_jobs.rb
|
26
|
+
create config/phocodable.yml
|
27
|
+
```
|
28
|
+
|
29
|
+
## Base Configuration
|
30
|
+
|
31
|
+
TBD
|
32
|
+
|
33
|
+
* Setting storage mode
|
34
|
+
* Setting processing mode (foreground / background processing)
|
35
|
+
* Other?
|
36
|
+
|
37
|
+
## Generating a new model & scaffolding
|
38
|
+
|
39
|
+
Letting PhocoderRails generate a new model and scaffold for you is probably the easiest way to get started
|
40
|
+
and to get a feel for how Phocoder works.
|
41
|
+
|
42
|
+
```term
|
43
|
+
rails g phocoder_rails:scaffold image_upload
|
44
|
+
create db/migrate/20120731022844_create_image_uploads.rb
|
45
|
+
create app/models/image_upload.rb
|
46
|
+
create app/models/image_upload_thumbnail.rb
|
47
|
+
create app/helpers/image_uploads_helper.rb
|
48
|
+
create app/controllers/image_uploads_controller.rb
|
49
|
+
create app/views/image_uploads
|
50
|
+
create app/views/image_uploads/_form.html.erb
|
51
|
+
create app/views/image_uploads/index.html.erb
|
52
|
+
create app/views/image_uploads/new.html.erb
|
53
|
+
create app/views/image_uploads/show.html.erb
|
54
|
+
route resources :image_uploads, :except=>[:edit,:update]
|
55
|
+
```
|
56
|
+
|
57
|
+
## Updating an existing model
|
58
|
+
|
59
|
+
First generate a migration that will add some extra columns to your table. You should red the migration
|
60
|
+
after it is generated to make sure that it makes sense within the context of your model.
|
61
|
+
|
62
|
+
```term
|
63
|
+
rails g phocoder_rails:model_update my_model
|
64
|
+
```
|
65
|
+
|
66
|
+
Then you should make sure that your form is set up for multi part encoding, and that you have a `file_field`
|
67
|
+
in your form named `file`.
|
68
|
+
|
69
|
+
```erb
|
70
|
+
<%= f.file_field :file %>
|
71
|
+
```
|
72
|
+
|
73
|
+
## Model Configuration
|
74
|
+
|
75
|
+
PhocoderRails allows you to easily set up your image processing in a simple declarative style. The
|
76
|
+
`acts_as_phocodable` method hooks phocoder-rails into your model and allows you to easily decalre multiple
|
77
|
+
thumbnails that will be generated any time a new model record is created. Thumbnails can include cropping,
|
78
|
+
framing, and annotations.
|
79
|
+
|
80
|
+
Here's an ImageUpload class that shows and example of how to use `acts_as_phocodable` :
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
class ImageUpload < ActiveRecord::Base
|
84
|
+
|
85
|
+
acts_as_phocodable :thumbnail_class => "ImageUploadThumbnail",
|
86
|
+
:thumbnails => [
|
87
|
+
{:label=>"small", :width=>100, :height=>100, :aspect_mode => 'crop'},
|
88
|
+
{:label=>"medium", :width=>400, :height=>400, :aspect_mode => 'preserve',
|
89
|
+
:frame=>{ :width=>20, :bottom=>50, :color=>'003' },
|
90
|
+
:annotations=>[
|
91
|
+
{:text=>"Annotation Testing",:pointsize=>30,:fill_color=>'fff',:gravity=>"South",:y=>10},
|
92
|
+
{:text=>"Howdy!",:pointsize=>10,:fill_color=>'ccc',:gravity=>"North",:y=>5}
|
93
|
+
]
|
94
|
+
}
|
95
|
+
]
|
96
|
+
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
This will result in two 'thumbnail' images being created every time a new image is uploaded. One will be
|
101
|
+
exactly 100x100 square, and the other one will be scaled proportionally to fit inside 400x400, with a 20
|
102
|
+
pixel border on top, left, and right, and a 50 pixel border on bottom, with text annotations added on top
|
103
|
+
and on the bottom of the image.
|
104
|
+
|
105
|
+
[Add images]
|
106
|
+
|
107
|
+
|
108
|
+
## Storage and Processing Modes
|
data/VERSION
CHANGED
data/app/models/encodable_job.rb
CHANGED
@@ -2,6 +2,65 @@ class EncodableJob < ActiveRecord::Base
|
|
2
2
|
|
3
3
|
belongs_to :encodable, :polymorphic=>true
|
4
4
|
|
5
|
+
scope :pending, :conditions => "phocoder_status != 'ready'"
|
6
|
+
|
7
|
+
def update_status
|
8
|
+
job_data = Phocoder::Job.details(phocoder_job_id).body
|
9
|
+
#puts job_data.to_json
|
10
|
+
puts " EncodableJob #{id} = #{job_data["aasm_state"]}"
|
11
|
+
if phocoder_input_id
|
12
|
+
job_data["inputs"].each do |input|
|
13
|
+
#puts "input = #{input.to_json}"
|
14
|
+
#puts "input id = #{input["id"]} my phocoder_input_id = #{phocoder_input_id}"
|
15
|
+
if input["id"] == phocoder_input_id
|
16
|
+
input.symbolize_keys!
|
17
|
+
params = {
|
18
|
+
:class => encodable_type,
|
19
|
+
:id => encodable_id,
|
20
|
+
:job => { :id => job_data["id"] },
|
21
|
+
:input => input
|
22
|
+
}
|
23
|
+
EncodableJob.update_from_phocoder(params)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
elsif phocoder_output_id
|
27
|
+
outputs = (job_data["thumbnails"] || []) +
|
28
|
+
(job_data["hdrs"] || []) +
|
29
|
+
(job_data["tone_mappings"] || []) +
|
30
|
+
(job_data["composites"] || []) +
|
31
|
+
(job_data["hdr_htmls"] || [])
|
32
|
+
outputs.each do |output|
|
33
|
+
if output["id"] == phocoder_output_id
|
34
|
+
output.symbolize_keys!
|
35
|
+
output[:url] = output[:base_url] + output[:filename]
|
36
|
+
params = {
|
37
|
+
:class => encodable_type,
|
38
|
+
:id => encodable_id,
|
39
|
+
:job => { :id => job_data["id"] },
|
40
|
+
:output => output
|
41
|
+
}
|
42
|
+
EncodableJob.update_from_phocoder(params)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
puts "+++++++++++++++"
|
47
|
+
# if job_data["aasm_state"] == "complete"
|
48
|
+
# self.phocoder_status = "ready"
|
49
|
+
# self.encodable.encodable_status = "ready"
|
50
|
+
# self.encodable.thumbnails.each do |t|
|
51
|
+
# t.encodable_status = "ready"
|
52
|
+
# end
|
53
|
+
# self.save
|
54
|
+
# self.encodable.save
|
55
|
+
# end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.update_pending_jobs
|
59
|
+
EncodableJob.pending.find_each do |e|
|
60
|
+
e.update_status
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
5
64
|
def self.update_from_phocoder(params)
|
6
65
|
Rails.logger.debug "tying to call update from phocoder for params = #{params.to_json}"
|
7
66
|
puts "tying to call update from phocoder for params = #{params.to_json}"
|
@@ -10,15 +69,17 @@ class EncodableJob < ActiveRecord::Base
|
|
10
69
|
puts "find_by_phocoder_job_id_and_phocoder_output_id_and_encodable_type #{params[:job][:id]} - #{params[:output][:id]} ,#{params[:class]}"
|
11
70
|
job = self.find_by_phocoder_job_id_and_phocoder_output_id_and_encodable_type params[:job][:id],params[:output][:id],params[:class]
|
12
71
|
|
13
|
-
|
14
|
-
Rails.logger.debug "the job = #{job}"
|
72
|
+
puts "the job = #{job.to_json}"
|
73
|
+
Rails.logger.debug "the job = #{job.to_json}"
|
15
74
|
img_params = params[:output]
|
16
75
|
begin
|
17
76
|
encodable = job.encodable
|
18
77
|
rescue NoMethodError => ex
|
78
|
+
puts "something went wrong..."
|
19
79
|
# here we try to fall back if we can't find an Encodable
|
20
80
|
encodable = params[:class].constantize.find params[:id]
|
21
81
|
end
|
82
|
+
puts "encodable = #{encodable.to_json}"
|
22
83
|
encodable.filename = File.basename(params[:output][:url]) if encodable.filename.blank?
|
23
84
|
if ActsAsPhocodable.storeage_mode == "local"
|
24
85
|
encodable.save_url(params[:output][:url])
|
@@ -921,10 +921,11 @@ module ActsAsPhocodable
|
|
921
921
|
cleanup
|
922
922
|
if new_file.is_a? File
|
923
923
|
self.filename = File.basename new_file.path
|
924
|
-
self.content_type = MIME::Types.type_for(self.filename).first.content_type
|
924
|
+
self.content_type = MIME::Types.type_for(self.filename).first.content_type || File.mime_type?(self.filename)
|
925
925
|
self.file_size = new_file.size
|
926
926
|
else
|
927
|
-
self.filename = new_file.original_filename
|
927
|
+
self.filename = new_file.original_filename || File.mime_type?(self.filename)
|
928
|
+
|
928
929
|
self.content_type = new_file.content_type
|
929
930
|
self.file_size = new_file.size
|
930
931
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :phocoder_rails do
|
2
|
+
desc "Update pending EncodableJobs"
|
3
|
+
task :update_pending_jobs => :environment do
|
4
|
+
e = EncodableJob.first
|
5
|
+
e.encodable # try to load phocoder config
|
6
|
+
e.encodable.class.read_phocodable_configuration
|
7
|
+
#puts "api key = #{Phocoder.api_key}"
|
8
|
+
#puts "Rails.env = #{Rails.env}"
|
9
|
+
puts "Updating #{EncodableJob.pending.count} EncodableJobs"
|
10
|
+
EncodableJob.update_pending_jobs
|
11
|
+
end
|
12
|
+
end
|
data/phocoder-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{phocoder-rails}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.42"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Jeremy Green}]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-04-23}
|
13
13
|
s.description = %q{Rails engine for easy integration with phocoder.com}
|
14
14
|
s.email = %q{jagthedrummer@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -105,6 +105,7 @@ Gem::Specification.new do |s|
|
|
105
105
|
"spec/dummy/db/migrate/20110523165213_add_parent_type_to_image_uploads.rb",
|
106
106
|
"spec/dummy/db/migrate/20110523165522_create_encodable_jobs.rb",
|
107
107
|
"spec/dummy/db/migrate/20111101024507_create_images.rb",
|
108
|
+
"spec/dummy/db/migrate/20120423030345_add_exif_data_to_image_uploads.rb",
|
108
109
|
"spec/dummy/db/schema.rb",
|
109
110
|
"spec/dummy/public/404.html",
|
110
111
|
"spec/dummy/public/422.html",
|
@@ -163,6 +164,7 @@ Gem::Specification.new do |s|
|
|
163
164
|
"spec/dummy/db/migrate/20110523165213_add_parent_type_to_image_uploads.rb",
|
164
165
|
"spec/dummy/db/migrate/20110523165522_create_encodable_jobs.rb",
|
165
166
|
"spec/dummy/db/migrate/20111101024507_create_images.rb",
|
167
|
+
"spec/dummy/db/migrate/20120423030345_add_exif_data_to_image_uploads.rb",
|
166
168
|
"spec/dummy/db/schema.rb",
|
167
169
|
"spec/engine_spec.rb",
|
168
170
|
"spec/helpers/phocoder_helper_spec.rb",
|
@@ -408,14 +408,14 @@ describe PhocoderHelper do #, :debug=>true
|
|
408
408
|
|
409
409
|
end # describe "video preview functions" do
|
410
410
|
|
411
|
-
describe "offline_phocoder_video_embed" do
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
end
|
411
|
+
# describe "offline_phocoder_video_embed" do
|
412
|
+
# it "should render a video tag" do
|
413
|
+
# vid = ImageUpload.new(:content_type=>'video/quicktime',:zencoder_status=>'ready',:id=>1,:filename=>"test.mov",:encodable_status=>"ready")
|
414
|
+
# vid.stub!(:thumbnail_for).and_return(vid)
|
415
|
+
# vid.video?.should be_true
|
416
|
+
# offline_phocoder_video_embed(vid,"small",{}).should match("video-js")
|
417
|
+
# end
|
418
|
+
#
|
419
|
+
# end
|
420
420
|
|
421
421
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
|
4
|
-
describe "Navigation" do
|
5
|
-
include Capybara
|
4
|
+
#describe "Navigation" do
|
5
|
+
#include Capybara
|
6
6
|
|
7
|
-
it "should be a valid app" do
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
7
|
+
#it "should be a valid app" do
|
8
|
+
#::Rails.application.should be_a(Dummy::Application)
|
9
|
+
#end
|
10
|
+
#end
|
@@ -47,7 +47,7 @@ describe ActsAsPhocodable do
|
|
47
47
|
before(:each) do
|
48
48
|
# @attr = {
|
49
49
|
# :file => ActionDispatch::Http::UploadedFile.new(
|
50
|
-
# :tempfile=> Rack::Test::UploadedFile.new(
|
50
|
+
# :tempfile=> Rack::Test::UploadedFile.new('/big_eye_tiny.jpg', 'image/jpeg'),
|
51
51
|
# :filename=>"big_eye_tiny.jpg"
|
52
52
|
# )
|
53
53
|
# }
|
@@ -599,6 +599,8 @@ describe ActsAsPhocodable do
|
|
599
599
|
|
600
600
|
iu.save_s3_file
|
601
601
|
# Now we should have a thumb
|
602
|
+
puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
603
|
+
puts iu.thumbnails.map{|t| t.thumbnail }.to_json
|
602
604
|
iu.thumbnails.size.should == 1
|
603
605
|
# Mock the AWS reqeust for deleting the file and it's thumbnail
|
604
606
|
AWS::S3::S3Object.should_receive(:delete).twice.and_return(nil)
|
@@ -5,22 +5,61 @@ include ActionDispatch::TestProcess
|
|
5
5
|
|
6
6
|
describe EncodableJob do
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
before(:each) do
|
9
|
+
ImageUpload.destroy_all
|
10
|
+
EncodableJob.destroy_all
|
11
|
+
@image_upload = ImageUpload.create(:phocoder_job_id=>1,:phocoder_input_id=>1,:phocoder_output_id=>1,
|
12
|
+
:zencoder_job_id=>1,:zencoder_input_id=>1,:zencoder_output_id=>1,
|
13
|
+
:file_size=>1,:width=>1,:height=>1,:filename=>"test.png",:content_type=>"image/png")
|
14
|
+
@image_upload2 = ImageUpload.create(:phocoder_job_id=>2,:phocoder_input_id=>2,:phocoder_output_id=>2,
|
15
|
+
:zencoder_job_id=>1,:zencoder_input_id=>1,:zencoder_output_id=>1,
|
16
|
+
:file_size=>1,:width=>1,:height=>1,:filename=>"test.png",:content_type=>"image/png")
|
17
|
+
@encodable_job = EncodableJob.create(:phocoder_job_id=>1,:phocoder_input_id=>1,:phocoder_output_id=>nil,
|
18
|
+
:zencoder_job_id=>nil,:zencoder_input_id=>nil,:zencoder_output_id=>nil,
|
19
|
+
:encodable=>@image_upload)
|
20
|
+
@encodable_job2 = EncodableJob.create(:phocoder_job_id=>2,:phocoder_input_id=>nil,:phocoder_output_id=>2,
|
21
|
+
:zencoder_job_id=>nil,:zencoder_input_id=>nil,:zencoder_output_id=>nil,
|
22
|
+
:encodable=>@image_upload2)
|
23
|
+
@job_params_json = %[{"aasm_state":"complete","api_key":"idYSHSxL98zxPab21q8y8VtL3Wti1lIR","created_at":"2012-08-07T04:41:09Z","end_load_1":0.0,"end_load_15":0.05,"end_load_5":0.01,"error_msg":null,"id":1,"lock_version":3,"pixels":276400,"processing_cores":2,"processing_ended_at":"2012-08-07T04:43:24Z","processing_host":"domU-12-31-39-18-21-1E","processing_started_at":"2012-08-07T04:43:23Z","queue_name":null,"start_load_1":0.0,"start_load_15":0.05,"start_load_5":0.01,"updated_at":"2012-08-07T04:43:24Z","user_id":1,"thumbnails":[{"aasm_state":"complete","analyze_ended_at":"2012-08-07T04:43:23Z","analyze_started_at":"2012-08-07T04:43:23Z","aspect_mode":"preserve","base_url":"s3://development.phocoder.com/image_thumbnails/6/","created_at":"2012-08-07T04:41:09Z","error_msg":null,"filename":"small_super_small_dsc_7428.jpg","format":"jpg","height":100,"id":349266,"job_id":1,"label":"small","lock_version":7,"output_content_type":"image/jpeg","output_file_size":19379,"output_height":67,"output_width":100,"quality":95,"resize_ended_at":"2012-08-07T04:43:23Z","resize_started_at":"2012-08-07T04:43:23Z","updated_at":"2012-08-07T04:43:23Z","upload_ended_at":"2012-08-07T04:43:23Z","upload_started_at":"2012-08-07T04:43:23Z","upscale":null,"user_id":null,"width":100},{"aasm_state":"complete","analyze_ended_at":"2012-08-07T04:43:24Z","analyze_started_at":"2012-08-07T04:43:24Z","aspect_mode":"preserve","base_url":"s3://development.phocoder.com/image_thumbnails/6/","created_at":"2012-08-07T04:41:09Z","error_msg":null,"filename":"medium_super_small_dsc_7428.jpg","format":"jpg","height":400,"id":349267,"job_id":1,"label":"medium","lock_version":7,"output_content_type":"image/jpeg","output_file_size":54356,"output_height":309,"output_width":400,"quality":95,"resize_ended_at":"2012-08-07T04:43:24Z","resize_started_at":"2012-08-07T04:43:23Z","updated_at":"2012-08-07T04:43:24Z","upload_ended_at":"2012-08-07T04:43:24Z","upload_started_at":"2012-08-07T04:43:24Z","upscale":null,"user_id":null,"width":400}],"inputs":[{"aasm_state":"complete","analyze_ended_at":"2012-08-07T04:43:23Z","analyze_started_at":"2012-08-07T04:43:23Z","bits_per_pixel":8,"camera_make":"NIKON CORPORATION","camera_model":"NIKON D300","content_type":"image/jpeg","created_at":"2012-08-07T04:41:09Z","download_ended_at":"2012-08-07T04:43:23Z","download_started_at":"2012-08-07T04:43:23Z","error_msg":null,"exposure_bias_value":"0","exposure_time":"0.016666666","f_number":"16.000000000","file_size":93974,"focal_length":"200.000000000","focal_length_in_35mm_film":"300","height":266,"id":1,"iso_speed_rating":"400","job_id":1,"lat":null,"lng":null,"lock_version":6,"orientation":1,"subsec_time":42,"taken_at":"2009-10-12T15:17:42Z","updated_at":"2012-08-07T04:43:23Z","url":"http://development.phocoder.com.s3.amazonaws.com/images/6/super_small_dsc_7428.jpg","user_id":1,"width":400}],"hdr_thumbnails":[]}]
|
24
|
+
@job_params_json2 = %[{"aasm_state":"complete","api_key":"idYSHSxL98zxPab21q8y8VtL3Wti1lIR","created_at":"2012-08-07T04:41:09Z","end_load_1":0.0,"end_load_15":0.05,"end_load_5":0.01,"error_msg":null,"id":2,"lock_version":3,"pixels":276400,"processing_cores":2,"processing_ended_at":"2012-08-07T04:43:24Z","processing_host":"domU-12-31-39-18-21-1E","processing_started_at":"2012-08-07T04:43:23Z","queue_name":null,"start_load_1":0.0,"start_load_15":0.05,"start_load_5":0.01,"updated_at":"2012-08-07T04:43:24Z","user_id":1,"thumbnails":[{"aasm_state":"complete","analyze_ended_at":"2012-08-07T04:43:23Z","analyze_started_at":"2012-08-07T04:43:23Z","aspect_mode":"preserve","base_url":"s3://development.phocoder.com/image_thumbnails/6/","created_at":"2012-08-07T04:41:09Z","error_msg":null,"filename":"small_super_small_dsc_7428.jpg","format":"jpg","height":100,"id":2,"job_id":1,"label":"small","lock_version":7,"output_content_type":"image/jpeg","output_file_size":19379,"output_height":67,"output_width":100,"quality":95,"resize_ended_at":"2012-08-07T04:43:23Z","resize_started_at":"2012-08-07T04:43:23Z","updated_at":"2012-08-07T04:43:23Z","upload_ended_at":"2012-08-07T04:43:23Z","upload_started_at":"2012-08-07T04:43:23Z","upscale":null,"user_id":null,"width":100},{"aasm_state":"complete","analyze_ended_at":"2012-08-07T04:43:24Z","analyze_started_at":"2012-08-07T04:43:24Z","aspect_mode":"preserve","base_url":"s3://development.phocoder.com/image_thumbnails/6/","created_at":"2012-08-07T04:41:09Z","error_msg":null,"filename":"medium_super_small_dsc_7428.jpg","format":"jpg","height":400,"id":349267,"job_id":1,"label":"medium","lock_version":7,"output_content_type":"image/jpeg","output_file_size":54356,"output_height":309,"output_width":400,"quality":95,"resize_ended_at":"2012-08-07T04:43:24Z","resize_started_at":"2012-08-07T04:43:23Z","updated_at":"2012-08-07T04:43:24Z","upload_ended_at":"2012-08-07T04:43:24Z","upload_started_at":"2012-08-07T04:43:24Z","upscale":null,"user_id":null,"width":400}],"inputs":[{"aasm_state":"complete","analyze_ended_at":"2012-08-07T04:43:23Z","analyze_started_at":"2012-08-07T04:43:23Z","bits_per_pixel":8,"camera_make":"NIKON CORPORATION","camera_model":"NIKON D300","content_type":"image/jpeg","created_at":"2012-08-07T04:41:09Z","download_ended_at":"2012-08-07T04:43:23Z","download_started_at":"2012-08-07T04:43:23Z","error_msg":null,"exposure_bias_value":"0","exposure_time":"0.016666666","f_number":"16.000000000","file_size":93974,"focal_length":"200.000000000","focal_length_in_35mm_film":"300","height":266,"id":2,"iso_speed_rating":"400","job_id":1,"lat":null,"lng":null,"lock_version":6,"orientation":1,"subsec_time":42,"taken_at":"2009-10-12T15:17:42Z","updated_at":"2012-08-07T04:43:23Z","url":"http://development.phocoder.com.s3.amazonaws.com/images/6/super_small_dsc_7428.jpg","user_id":1,"width":400}],"hdr_thumbnails":[]}]
|
25
|
+
end
|
26
|
+
|
27
|
+
after(:each) do
|
28
|
+
@image_upload.destroy
|
29
|
+
@encodable_job.destroy
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe "update_status" do
|
34
|
+
it "should update inputs" do
|
35
|
+
Phocoder::Job.should_receive(:details).and_return(double :body => JSON(@job_params_json) )
|
36
|
+
@encodable_job.update_status
|
37
|
+
@encodable_job.reload
|
38
|
+
@image_upload.reload
|
39
|
+
#@encodable_job.phocoder_status.should == "ready"
|
40
|
+
@image_upload.encodable_status.should == "ready"
|
17
41
|
end
|
18
42
|
|
19
|
-
|
20
|
-
|
21
|
-
|
43
|
+
it "should update outputs" do
|
44
|
+
puts "//////////////////////"
|
45
|
+
stub_request(:get, "http://production.webapeel.com/octolabs/themes/octolabs/images/octologo.png").
|
46
|
+
with(:headers => {'Accept'=>'*/*'}).
|
47
|
+
to_return(:status => 200, :body => webmock_file("octologo.png"), :headers => {})
|
48
|
+
Phocoder::Job.should_receive(:details).and_return(double :body => JSON(@job_params_json2) )
|
49
|
+
@encodable_job2.update_status
|
50
|
+
@encodable_job2.reload
|
51
|
+
@image_upload2.reload
|
52
|
+
#@encodable_job.phocoder_status.should == "ready"
|
53
|
+
@image_upload2.encodable_status.should == "ready"
|
22
54
|
end
|
23
55
|
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
describe "update_from_phocoder" do
|
62
|
+
|
24
63
|
it "should fupdate inputs" do
|
25
64
|
params = { :class=>"ImageUpload",
|
26
65
|
:id=>1,
|
@@ -64,20 +103,26 @@ describe EncodableJob do
|
|
64
103
|
end
|
65
104
|
|
66
105
|
|
67
|
-
|
68
|
-
it "should update
|
106
|
+
|
107
|
+
it "should update outputs" do
|
69
108
|
stub_request(:get, "http://production.webapeel.com/octolabs/themes/octolabs/images/octologo.png").
|
70
109
|
with(:headers => {'Accept'=>'*/*'}).
|
71
110
|
to_return(:status => 200, :body => webmock_file("octologo.png"), :headers => {})
|
72
|
-
params = {:class=>"ImageUpload"
|
111
|
+
params = {:class=>"ImageUpload",
|
112
|
+
:id=>2,
|
113
|
+
:job=>{:id => 2},
|
114
|
+
:output=>{:id=>2,:file_size=>2,:width=>2,:height=>2,:url=>"http://production.webapeel.com/octolabs/themes/octolabs/images/octologo.png"},
|
115
|
+
:format=>"json"
|
116
|
+
}
|
73
117
|
EncodableJob.update_from_phocoder(params);
|
74
118
|
|
75
|
-
@
|
76
|
-
@
|
77
|
-
@
|
119
|
+
@image_upload2.reload
|
120
|
+
@image_upload2.encodable_status.should == "ready"
|
121
|
+
@image_upload2.file_size.should == 2
|
78
122
|
end
|
79
123
|
|
124
|
+
|
80
125
|
end
|
81
|
-
|
126
|
+
|
82
127
|
|
83
128
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -41,6 +41,7 @@ RSpec.configure do |config|
|
|
41
41
|
|
42
42
|
config.fixture_path = "#{File.dirname(__FILE__)}/fixtures"
|
43
43
|
|
44
|
+
|
44
45
|
config.before(:all){
|
45
46
|
|
46
47
|
#change this if sqlite is unavailable
|
@@ -72,4 +73,4 @@ end
|
|
72
73
|
def webmock_file(f = nil)
|
73
74
|
f ||= "%s.xml" % @site.anchor
|
74
75
|
File.new webmock_filename(f)
|
75
|
-
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,173 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: phocoder-rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.43
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 42
|
10
|
-
version: 0.0.42
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jeremy Green
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rails
|
22
|
-
|
16
|
+
requirement: &72774960 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 7
|
28
|
-
segments:
|
29
|
-
- 3
|
30
|
-
- 0
|
31
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 3.0.0
|
33
|
-
prerelease: false
|
34
|
-
requirement: *id001
|
35
22
|
type: :runtime
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *72774960
|
25
|
+
- !ruby/object:Gem::Dependency
|
37
26
|
name: phocoder-rb
|
38
|
-
|
27
|
+
requirement: &72774570 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
47
|
-
prerelease: false
|
48
|
-
requirement: *id002
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
49
33
|
type: :runtime
|
50
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *72774570
|
36
|
+
- !ruby/object:Gem::Dependency
|
51
37
|
name: zencoder
|
52
|
-
|
38
|
+
requirement: &72774250 !ruby/object:Gem::Requirement
|
53
39
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
61
45
|
prerelease: false
|
62
|
-
|
46
|
+
version_requirements: *72774250
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mimetype-fu
|
49
|
+
requirement: &72752830 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.2
|
63
55
|
type: :runtime
|
64
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *72752830
|
58
|
+
- !ruby/object:Gem::Dependency
|
65
59
|
name: aws-s3
|
66
|
-
|
60
|
+
requirement: &72752530 !ruby/object:Gem::Requirement
|
67
61
|
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
75
|
-
prerelease: false
|
76
|
-
requirement: *id004
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
77
66
|
type: :runtime
|
78
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *72752530
|
69
|
+
- !ruby/object:Gem::Dependency
|
79
70
|
name: spawn
|
80
|
-
|
71
|
+
requirement: &72752230 !ruby/object:Gem::Requirement
|
81
72
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
segments:
|
87
|
-
- 0
|
88
|
-
version: "0"
|
89
|
-
prerelease: false
|
90
|
-
requirement: *id005
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
91
77
|
type: :runtime
|
92
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *72752230
|
80
|
+
- !ruby/object:Gem::Dependency
|
93
81
|
name: rspec-rails
|
94
|
-
|
82
|
+
requirement: &72751980 !ruby/object:Gem::Requirement
|
95
83
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
hash: 29
|
100
|
-
segments:
|
101
|
-
- 2
|
102
|
-
- 4
|
103
|
-
- 1
|
84
|
+
requirements:
|
85
|
+
- - =
|
86
|
+
- !ruby/object:Gem::Version
|
104
87
|
version: 2.4.1
|
105
|
-
prerelease: false
|
106
|
-
requirement: *id006
|
107
88
|
type: :development
|
108
|
-
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *72751980
|
91
|
+
- !ruby/object:Gem::Dependency
|
109
92
|
name: bundler
|
110
|
-
|
93
|
+
requirement: &72751710 !ruby/object:Gem::Requirement
|
111
94
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 1
|
118
|
-
- 0
|
119
|
-
- 0
|
120
|
-
version: 1.0.0
|
121
|
-
prerelease: false
|
122
|
-
requirement: *id007
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
123
99
|
type: :development
|
124
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *72751710
|
102
|
+
- !ruby/object:Gem::Dependency
|
125
103
|
name: jeweler
|
126
|
-
|
104
|
+
requirement: &72751400 !ruby/object:Gem::Requirement
|
127
105
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
segments:
|
133
|
-
- 1
|
134
|
-
- 5
|
135
|
-
- 1
|
136
|
-
version: 1.5.1
|
137
|
-
prerelease: false
|
138
|
-
requirement: *id008
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
139
110
|
type: :development
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: rcov
|
142
|
-
version_requirements: &id009 !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
|
-
requirements:
|
145
|
-
- - ">="
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
hash: 3
|
148
|
-
segments:
|
149
|
-
- 0
|
150
|
-
version: "0"
|
151
111
|
prerelease: false
|
152
|
-
|
153
|
-
type: :development
|
112
|
+
version_requirements: *72751400
|
154
113
|
description: Rails engine for easy integration with phocoder.com
|
155
114
|
email: jagthedrummer@gmail.com
|
156
115
|
executables: []
|
157
|
-
|
158
116
|
extensions: []
|
159
|
-
|
160
|
-
extra_rdoc_files:
|
117
|
+
extra_rdoc_files:
|
161
118
|
- LICENSE.txt
|
162
|
-
- README.
|
163
|
-
files:
|
119
|
+
- README.md
|
120
|
+
files:
|
164
121
|
- .autotest
|
165
122
|
- .document
|
166
123
|
- .rspec
|
167
124
|
- Gemfile
|
168
125
|
- LICENSE.txt
|
169
126
|
- MIT-LICENSE
|
170
|
-
- README.
|
127
|
+
- README.md
|
171
128
|
- Rakefile
|
172
129
|
- VERSION
|
173
130
|
- app/controllers/phocoder_controller.rb
|
@@ -198,6 +155,7 @@ files:
|
|
198
155
|
- lib/phocoder_rails/acts_as_phocodable.rb
|
199
156
|
- lib/phocoder_rails/engine.rb
|
200
157
|
- lib/phocoder_rails/errors.rb
|
158
|
+
- lib/tasks/phocoder_rails/phocoder_rails.rake
|
201
159
|
- phocoder-rails.gemspec
|
202
160
|
- public/images/building.gif
|
203
161
|
- public/images/error.png
|
@@ -278,39 +236,34 @@ files:
|
|
278
236
|
- spec/routing/phocoder_routing_spec.rb
|
279
237
|
- spec/spec_helper.rb
|
280
238
|
homepage: http://github.com/jagthedrummer/phocoder-rails
|
281
|
-
licenses:
|
239
|
+
licenses:
|
282
240
|
- MIT
|
283
241
|
post_install_message:
|
284
242
|
rdoc_options: []
|
285
|
-
|
286
|
-
require_paths:
|
243
|
+
require_paths:
|
287
244
|
- lib
|
288
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
245
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
289
246
|
none: false
|
290
|
-
requirements:
|
291
|
-
- -
|
292
|
-
- !ruby/object:Gem::Version
|
293
|
-
|
294
|
-
segments:
|
247
|
+
requirements:
|
248
|
+
- - ! '>='
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
segments:
|
295
252
|
- 0
|
296
|
-
|
297
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
|
+
hash: -916334765
|
254
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
255
|
none: false
|
299
|
-
requirements:
|
300
|
-
- -
|
301
|
-
- !ruby/object:Gem::Version
|
302
|
-
|
303
|
-
segments:
|
304
|
-
- 0
|
305
|
-
version: "0"
|
256
|
+
requirements:
|
257
|
+
- - ! '>='
|
258
|
+
- !ruby/object:Gem::Version
|
259
|
+
version: '0'
|
306
260
|
requirements: []
|
307
|
-
|
308
261
|
rubyforge_project:
|
309
|
-
rubygems_version: 1.8.
|
262
|
+
rubygems_version: 1.8.7
|
310
263
|
signing_key:
|
311
264
|
specification_version: 3
|
312
265
|
summary: Rails engine for easy integration with phocoder.com
|
313
|
-
test_files:
|
266
|
+
test_files:
|
314
267
|
- spec/controllers/phocoder_controller_spec.rb
|
315
268
|
- spec/dummy/app/controllers/application_controller.rb
|
316
269
|
- spec/dummy/app/controllers/images_controller.rb
|
data/README.rdoc
DELETED