Permalink
Browse files

serious refactoring

  • Loading branch information...
filiptepper committed May 23, 2012
1 parent 8b0ef3f commit d4ec96f2d0e7283f3c196e90d005b41dc62e76de
View
@@ -1,14 +0,0 @@
-require "dragonfly"
-
-$app = Dragonfly::App[:thumbnails].configure_with(:imagemagick)
-
-class Thumbnails
- def initialize(app)
- @app = app
- end
-
- def call(env)
- response = @app.fetch_file("../image.jpg").thumb("100x100")
- response.to_response(env)
- end
-end
View
@@ -1,12 +0,0 @@
-require "mini_magick"
-
-class Thumbnails
- def call(env)
- image = MiniMagick::Image.open("../image.jpg")
- image.resize("100x100")
-
- [200, {"Content-Type" => "image/jpeg"}, [
- image.to_blob
- ]]
- end
-end
View
@@ -1 +0,0 @@
-rvm jruby-1.6.7.2@thumbnails --create
View
@@ -1,8 +0,0 @@
-source :rubygems
-
-gem "dragonfly", :require => false
-gem "image_voodoo", :require => false
-gem "mini_magick", :require => false
-
-gem "rack"
-gem "puma", :require => false
View
@@ -1,25 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- dragonfly (0.9.12)
- rack
- image_voodoo (0.8.2)
- mini_magick (3.4)
- subexec (~> 0.2.1)
- puma (1.3.1)
- rack (~> 1.2)
- puma (1.3.1-java)
- rack (~> 1.2)
- rack (1.4.1)
- subexec (0.2.2)
-
-PLATFORMS
- java
- ruby
-
-DEPENDENCIES
- dragonfly
- image_voodoo
- mini_magick
- puma
- rack
View
@@ -1,4 +0,0 @@
-Servers:
-
- rackup -s puma config.mini_magick.ru
- rackup -s puma config.image_voodoo.ru
@@ -1,5 +0,0 @@
-require "bundler/setup"
-
-require "../common.rb/dragonfly.rb"
-
-run Thumbnails.new($app)
@@ -1,12 +0,0 @@
-require "bundler/setup"
-require "image_voodoo"
-
-class Thumbnails
- def call(env)
- [200, {"Content-Type" => "image/jpeg"}, [
- ImageVoodoo.with_image("../image.jpg").thumbnail(100).bytes("jpg")
- ]]
- end
-end
-
-run Thumbnails.new
@@ -1,5 +0,0 @@
-require "bundler/setup"
-
-require "../common.rb/mini_magick.rb"
-
-run Thumbnails.new
File renamed without changes.
File renamed without changes.
View
@@ -1 +0,0 @@
-rvm rbx-head@thumbnails --create
View
@@ -1,8 +0,0 @@
-source :rubygems
-
-gem "dragonfly", :require => false
-gem "mini_magick", :require => false
-
-gem "rack"
-
-gem "puma", :require => false
View
@@ -1,23 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- dragonfly (0.9.12)
- rack
- mini_magick (3.4)
- subexec (~> 0.2.1)
- puma (1.3.1)
- rack (~> 1.2)
- puma (1.3.1-java)
- rack (~> 1.2)
- rack (1.4.1)
- subexec (0.2.2)
-
-PLATFORMS
- java
- ruby
-
-DEPENDENCIES
- dragonfly
- mini_magick
- puma
- rack
View
@@ -1,3 +0,0 @@
-Servers:
-
- rackup -s puma config.mini_magick.ru
View
@@ -1,5 +0,0 @@
-require "bundler/setup"
-
-require "../common.rb/dragonfly.rb"
-
-run Thumbnails.new($app)
@@ -1,5 +0,0 @@
-require "bundler/setup"
-
-require "../common.rb/mini_magick.rb"
-
-run Thumbnails.new
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem "eventmachine", :require => false
+gem "eventmachine_httpserver", :require => false
@@ -0,0 +1,12 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ eventmachine (0.12.10)
+ eventmachine_httpserver (0.2.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ eventmachine
+ eventmachine_httpserver
@@ -1,5 +1,5 @@
require "bundler/setup"
-require "mini_magick"
+
require "eventmachine"
require "evma_httpserver"
@@ -15,12 +15,16 @@ def process_http_request
response = EventMachine::DelegatedHttpResponse.new(self)
operation = proc do
- image = MiniMagick::Image.open("../image.jpg")
- image.resize "100x100"
+ command = "gm convert -size 100x100 ..//image.jpg -resize 100x100 JPG:-"
+ image = ""
+ IO.popen(command) do |result|
+ while part = result.read(1024)
+ image << part
+ end
+ end
response.status = 200
- response.content_type "image/jpeg"
- response.content = image.to_blob
+ response.content = image
end
callback = proc do |res|
@@ -32,5 +36,5 @@ def process_http_request
end
EM.run {
- EM.start_server '0.0.0.0', 9292, MyHttpServer
+ EM.start_server "0.0.0.0", 9292, MyHttpServer
}
View
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem "goliath", :require => false
View
@@ -0,0 +1,42 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ async-rack (0.5.1)
+ rack (~> 1.1)
+ em-synchrony (1.0.1)
+ eventmachine (>= 1.0.0.beta.1)
+ eventmachine (1.0.0.beta.4)
+ eventmachine (1.0.0.beta.4-java)
+ goliath (0.9.4)
+ async-rack
+ em-synchrony (>= 1.0.0)
+ eventmachine (>= 1.0.0.beta.3)
+ http_parser.rb
+ http_router (~> 0.9.0)
+ log4r
+ multi_json
+ rack (>= 1.2.2)
+ rack-contrib
+ rack-respond_to
+ http_parser.rb (0.5.3)
+ http_parser.rb (0.5.3-java)
+ http_router (0.9.7)
+ rack (>= 1.0.0)
+ url_mount (~> 0.2.1)
+ log4r (1.1.10)
+ multi_json (1.3.5)
+ rack (1.4.1)
+ rack-accept-media-types (0.9)
+ rack-contrib (1.1.0)
+ rack (>= 0.9.1)
+ rack-respond_to (0.9.8)
+ rack-accept-media-types (>= 0.6)
+ url_mount (0.2.1)
+ rack
+
+PLATFORMS
+ java
+ ruby
+
+DEPENDENCIES
+ goliath
View
@@ -0,0 +1,22 @@
+require "bundler/setup"
+
+if defined?(Rubinius)
+ p "a"
+ Fiber = Rubinius::Fiber
+end
+
+require "goliath"
+
+class Thumbnails < Goliath::API
+ def response(env)
+ command = "gm convert -size 100x100 ..//image.jpg -resize 100x100 JPG:-"
+ image = ""
+ IO.popen(command) do |result|
+ while part = result.read(1024)
+ image << part
+ end
+ end
+
+ [200, {}, image]
+ end
+end
View
@@ -1 +0,0 @@
-rvm 1.9.3-p194@thumbnails --create
View
@@ -1,9 +0,0 @@
-source :rubygems
-
-gem "dragonfly", :require => false
-gem "mini_magick", :require => false
-
-gem "eventmachine", :require => false
-gem "eventmachine_httpserver", :require => false
-gem "puma", :require => false
-gem "unicorn", :require => false
View
@@ -1,30 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- dragonfly (0.9.12)
- rack
- eventmachine (0.12.10)
- eventmachine_httpserver (0.2.1)
- kgio (2.7.4)
- mini_magick (3.4)
- subexec (~> 0.2.1)
- puma (1.3.1)
- rack (~> 1.2)
- rack (1.4.1)
- raindrops (0.9.0)
- subexec (0.2.2)
- unicorn (4.3.1)
- kgio (~> 2.6)
- rack
- raindrops (~> 0.7)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- dragonfly
- eventmachine
- eventmachine_httpserver
- mini_magick
- puma
- unicorn
View
@@ -1,7 +0,0 @@
-Servers:
-
- ruby eventmachine.mini_magick.rb
- rackup -s puma config.dragonfly.rb
- rackup -s puma config.mini_magick.rb
- unicorn -c unicorn.rb -p 9292 config.mini_magick.ru
- unicorn -c unicorn.rb -p 9292 config.dragonfly.ru
View
@@ -1,5 +0,0 @@
-require "bundler/setup"
-
-require "../common.rb/dragonfly.rb"
-
-run Thumbnails.new($app)
@@ -1,5 +0,0 @@
-require "bundler/setup"
-
-require "../common.rb/mini_magick.rb"
-
-run Thumbnails.new
View
@@ -1,2 +0,0 @@
-worker_processes 2
-preload_app true

0 comments on commit d4ec96f

Please sign in to comment.