griddleware 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/griddleware.gemspec +139 -0
- data/lib/griddleware/browser_helper.rb +11 -0
- data/lib/griddleware/grid_image.rb +32 -0
- data/lib/griddleware.rb +2 -0
- data/test/fixtures/baboon.jpg +0 -0
- data/test/helper.rb +52 -0
- data/test/rails_helper.rb +4 -0
- data/test/rails_root/README +243 -0
- data/test/rails_root/Rakefile +10 -0
- data/test/rails_root/app/controllers/application_controller.rb +10 -0
- data/test/rails_root/app/controllers/documents_controller.rb +18 -0
- data/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails_root/app/models/document.rb +16 -0
- data/test/rails_root/app/views/documents/index.html.erb +5 -0
- data/test/rails_root/config/boot.rb +110 -0
- data/test/rails_root/config/database.yml +22 -0
- data/test/rails_root/config/environment.rb +46 -0
- data/test/rails_root/config/environments/development.rb +23 -0
- data/test/rails_root/config/environments/production.rb +28 -0
- data/test/rails_root/config/environments/test.rb +28 -0
- data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_root/config/initializers/griddle.rb +4 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/new_rails_defaults.rb +21 -0
- data/test/rails_root/config/initializers/session_store.rb +15 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +46 -0
- data/test/rails_root/db/development.sqlite3 +0 -0
- data/test/rails_root/db/seeds.rb +7 -0
- data/test/rails_root/db/test.sqlite3 +0 -0
- data/test/rails_root/doc/README_FOR_APP +2 -0
- data/test/rails_root/log/development.log +41 -0
- data/test/rails_root/log/production.log +0 -0
- data/test/rails_root/log/server.log +0 -0
- data/test/rails_root/log/test.log +246 -0
- data/test/rails_root/public/404.html +30 -0
- data/test/rails_root/public/422.html +30 -0
- data/test/rails_root/public/500.html +30 -0
- data/test/rails_root/public/_index.html +275 -0
- data/test/rails_root/public/favicon.ico +0 -0
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/javascripts/application.js +2 -0
- data/test/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails_root/public/javascripts/dragdrop.js +973 -0
- data/test/rails_root/public/javascripts/effects.js +1128 -0
- data/test/rails_root/public/javascripts/prototype.js +4320 -0
- data/test/rails_root/public/robots.txt +5 -0
- data/test/rails_root/script/about +4 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/script/dbconsole +3 -0
- data/test/rails_root/script/destroy +3 -0
- data/test/rails_root/script/generate +3 -0
- data/test/rails_root/script/performance/benchmarker +3 -0
- data/test/rails_root/script/performance/profiler +3 -0
- data/test/rails_root/script/plugin +3 -0
- data/test/rails_root/script/runner +3 -0
- data/test/rails_root/script/server +3 -0
- data/test/rails_root/test/fixtures/baboon.jpg +0 -0
- data/test/rails_root/test/fixtures/fox.jpg +0 -0
- data/test/rails_root/test/fixtures/sample.pdf +0 -0
- data/test/rails_root/test/integration/grid_image_test.rb +47 -0
- data/test/rails_root/test/performance/browsing_test.rb +9 -0
- data/test/rails_root/test/test_helper.rb +39 -0
- data/test/test_griddleware.rb +38 -0
- metadata +181 -0
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class GridImageTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
context "on GET to /grid/document/:id/:name/:style" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@document = Document.new
|
9
|
+
@dir = Rails.root + "test/fixtures/"
|
10
|
+
@file = File.new(@dir + "baboon.jpg", 'rb')
|
11
|
+
@document.image = @file
|
12
|
+
@document.save_attached_files
|
13
|
+
end
|
14
|
+
|
15
|
+
should "return the image" do
|
16
|
+
get @document.image.url
|
17
|
+
assert_equal @document.image.file.read, response.body
|
18
|
+
end
|
19
|
+
|
20
|
+
style_expectations.each do |style|
|
21
|
+
|
22
|
+
should "return the image for #{style[0]}" do
|
23
|
+
style_attachment = @document.image.send(style[0])
|
24
|
+
get style_attachment.url
|
25
|
+
assert_equal style_attachment.file.read, response.body
|
26
|
+
end
|
27
|
+
|
28
|
+
should "response body is the correct size for #{style[0]}" do
|
29
|
+
temp = Tempfile.new "#{style[0]}.jpg"
|
30
|
+
style_attachment = @document.image.send(style[0])
|
31
|
+
|
32
|
+
get style_attachment.url
|
33
|
+
|
34
|
+
file_path = File.dirname(temp.path) + '/' + style_attachment.file_name
|
35
|
+
File.open(file_path, 'w') do |f|
|
36
|
+
f.write response.body
|
37
|
+
end
|
38
|
+
cmd = %Q[identify -format "%[fx:w] x %[fx:h]" #{file_path}]
|
39
|
+
|
40
|
+
assert_equal style[1], `#{cmd}`.chomp
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
+
require 'test_help'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
class ActiveSupport::TestCase
|
7
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
8
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
9
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
10
|
+
# between every test method. Fewer database queries means faster tests.
|
11
|
+
#
|
12
|
+
# Read Mike Clark's excellent walkthrough at
|
13
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
14
|
+
#
|
15
|
+
# Every Active Record database supports transactions except MyISAM tables
|
16
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
17
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
18
|
+
# is recommended.
|
19
|
+
#
|
20
|
+
# The only drawback to using transactional fixtures is when you actually
|
21
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
22
|
+
# any transactions started in your code will be automatically rolled back.
|
23
|
+
self.use_transactional_fixtures = true
|
24
|
+
|
25
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
26
|
+
# would need people(:david). If you don't want to migrate your existing
|
27
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
28
|
+
# instantiated fixtures translates to a database query per test method),
|
29
|
+
# then set this back to true.
|
30
|
+
self.use_instantiated_fixtures = false
|
31
|
+
|
32
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
33
|
+
#
|
34
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
35
|
+
# -- they do not yet inherit this setting
|
36
|
+
fixtures :all
|
37
|
+
|
38
|
+
# Add more helper methods to be used by all tests here...
|
39
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestGriddleware < Test::Unit::TestCase
|
4
|
+
all_models
|
5
|
+
|
6
|
+
context "A document with a Griddle::Attachment" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@document = Document.new
|
10
|
+
dir = File.dirname(__FILE__) + '/fixtures/'
|
11
|
+
@file = File.new(dir + "baboon.jpg", 'rb')
|
12
|
+
@document.image = @file
|
13
|
+
@document.save_attached_files
|
14
|
+
end
|
15
|
+
|
16
|
+
should "have a url method" do
|
17
|
+
assert @document.image.respond_to? :url
|
18
|
+
end
|
19
|
+
|
20
|
+
should "default to url returning the grid_key" do
|
21
|
+
assert_equal "/grid/documents/#{@document.id}/image/baboon.jpg", @document.image.url
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with styles" do
|
25
|
+
|
26
|
+
style_expectations.each do |style|
|
27
|
+
|
28
|
+
should "return a url for style #{style[0]}" do
|
29
|
+
assert_equal "/grid/documents/#{@document.id}/image/#{style[0]}/baboon.jpg", @document.image.send(style[0]).url
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: griddleware
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- meanmarcus
|
13
|
+
- Matt Mongeau
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-03-15 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: griddle
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: 0.1.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: thoughtbot-shoulda
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
version_requirements: *id002
|
47
|
+
description: Rack middleware to assists in serving of GridFileSystem files
|
48
|
+
email: conradmr@gmail.com
|
49
|
+
executables: []
|
50
|
+
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
extra_rdoc_files:
|
54
|
+
- LICENSE
|
55
|
+
- README.rdoc
|
56
|
+
files:
|
57
|
+
- .document
|
58
|
+
- .gitignore
|
59
|
+
- LICENSE
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- VERSION
|
63
|
+
- griddleware.gemspec
|
64
|
+
- lib/griddleware.rb
|
65
|
+
- lib/griddleware/browser_helper.rb
|
66
|
+
- lib/griddleware/grid_image.rb
|
67
|
+
- test/fixtures/baboon.jpg
|
68
|
+
- test/helper.rb
|
69
|
+
- test/rails_helper.rb
|
70
|
+
- test/rails_root/README
|
71
|
+
- test/rails_root/Rakefile
|
72
|
+
- test/rails_root/app/controllers/application_controller.rb
|
73
|
+
- test/rails_root/app/controllers/documents_controller.rb
|
74
|
+
- test/rails_root/app/helpers/application_helper.rb
|
75
|
+
- test/rails_root/app/models/document.rb
|
76
|
+
- test/rails_root/app/views/documents/index.html.erb
|
77
|
+
- test/rails_root/config/boot.rb
|
78
|
+
- test/rails_root/config/database.yml
|
79
|
+
- test/rails_root/config/environment.rb
|
80
|
+
- test/rails_root/config/environments/development.rb
|
81
|
+
- test/rails_root/config/environments/production.rb
|
82
|
+
- test/rails_root/config/environments/test.rb
|
83
|
+
- test/rails_root/config/initializers/backtrace_silencers.rb
|
84
|
+
- test/rails_root/config/initializers/griddle.rb
|
85
|
+
- test/rails_root/config/initializers/inflections.rb
|
86
|
+
- test/rails_root/config/initializers/mime_types.rb
|
87
|
+
- test/rails_root/config/initializers/new_rails_defaults.rb
|
88
|
+
- test/rails_root/config/initializers/session_store.rb
|
89
|
+
- test/rails_root/config/locales/en.yml
|
90
|
+
- test/rails_root/config/routes.rb
|
91
|
+
- test/rails_root/db/development.sqlite3
|
92
|
+
- test/rails_root/db/seeds.rb
|
93
|
+
- test/rails_root/db/test.sqlite3
|
94
|
+
- test/rails_root/doc/README_FOR_APP
|
95
|
+
- test/rails_root/log/development.log
|
96
|
+
- test/rails_root/log/production.log
|
97
|
+
- test/rails_root/log/server.log
|
98
|
+
- test/rails_root/log/test.log
|
99
|
+
- test/rails_root/public/404.html
|
100
|
+
- test/rails_root/public/422.html
|
101
|
+
- test/rails_root/public/500.html
|
102
|
+
- test/rails_root/public/_index.html
|
103
|
+
- test/rails_root/public/favicon.ico
|
104
|
+
- test/rails_root/public/images/rails.png
|
105
|
+
- test/rails_root/public/javascripts/application.js
|
106
|
+
- test/rails_root/public/javascripts/controls.js
|
107
|
+
- test/rails_root/public/javascripts/dragdrop.js
|
108
|
+
- test/rails_root/public/javascripts/effects.js
|
109
|
+
- test/rails_root/public/javascripts/prototype.js
|
110
|
+
- test/rails_root/public/robots.txt
|
111
|
+
- test/rails_root/script/about
|
112
|
+
- test/rails_root/script/console
|
113
|
+
- test/rails_root/script/dbconsole
|
114
|
+
- test/rails_root/script/destroy
|
115
|
+
- test/rails_root/script/generate
|
116
|
+
- test/rails_root/script/performance/benchmarker
|
117
|
+
- test/rails_root/script/performance/profiler
|
118
|
+
- test/rails_root/script/plugin
|
119
|
+
- test/rails_root/script/runner
|
120
|
+
- test/rails_root/script/server
|
121
|
+
- test/rails_root/test/fixtures/baboon.jpg
|
122
|
+
- test/rails_root/test/fixtures/fox.jpg
|
123
|
+
- test/rails_root/test/fixtures/sample.pdf
|
124
|
+
- test/rails_root/test/integration/grid_image_test.rb
|
125
|
+
- test/rails_root/test/performance/browsing_test.rb
|
126
|
+
- test/rails_root/test/test_helper.rb
|
127
|
+
- test/test_griddleware.rb
|
128
|
+
has_rdoc: true
|
129
|
+
homepage: http://github.com/meanmarcus/griddleware
|
130
|
+
licenses: []
|
131
|
+
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options:
|
134
|
+
- --charset=UTF-8
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
version: "0"
|
151
|
+
requirements: []
|
152
|
+
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 1.3.6
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: Rack middleware to assists in serving of GridFileSystem files
|
158
|
+
test_files:
|
159
|
+
- test/helper.rb
|
160
|
+
- test/rails_helper.rb
|
161
|
+
- test/rails_root/app/controllers/application_controller.rb
|
162
|
+
- test/rails_root/app/controllers/documents_controller.rb
|
163
|
+
- test/rails_root/app/helpers/application_helper.rb
|
164
|
+
- test/rails_root/app/models/document.rb
|
165
|
+
- test/rails_root/config/boot.rb
|
166
|
+
- test/rails_root/config/environment.rb
|
167
|
+
- test/rails_root/config/environments/development.rb
|
168
|
+
- test/rails_root/config/environments/production.rb
|
169
|
+
- test/rails_root/config/environments/test.rb
|
170
|
+
- test/rails_root/config/initializers/backtrace_silencers.rb
|
171
|
+
- test/rails_root/config/initializers/griddle.rb
|
172
|
+
- test/rails_root/config/initializers/inflections.rb
|
173
|
+
- test/rails_root/config/initializers/mime_types.rb
|
174
|
+
- test/rails_root/config/initializers/new_rails_defaults.rb
|
175
|
+
- test/rails_root/config/initializers/session_store.rb
|
176
|
+
- test/rails_root/config/routes.rb
|
177
|
+
- test/rails_root/db/seeds.rb
|
178
|
+
- test/rails_root/test/integration/grid_image_test.rb
|
179
|
+
- test/rails_root/test/performance/browsing_test.rb
|
180
|
+
- test/rails_root/test/test_helper.rb
|
181
|
+
- test/test_griddleware.rb
|