rails_imager 0.0.29 → 0.0.30
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.
- checksums.yaml +4 -4
- data/app/controllers/rails_imager/images_controller.rb +2 -4
- data/lib/rails_imager.rb +4 -0
- data/lib/rails_imager/cache_handler.rb +26 -0
- data/lib/rails_imager/version.rb +1 -1
- data/lib/tasks/rails_imager_tasks.rake +14 -4
- data/spec/cache_handler_spec.rb +14 -0
- data/spec/dummy/log/test.log +90 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 335f5f841ec8b9052baf5ba8a97990046214fb2e
|
4
|
+
data.tar.gz: 19744bcd2fdc998b758e7cfa632248e336f52de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cef0ac04a1d2936b3c4a77a9bc139286ff6cb59e62f80dd6aa2846e87b2befbefb7d2fda46a91dd5c73899d595d4d71e3b1fa654e57b7992b18ac430341ba632
|
7
|
+
data.tar.gz: cc19ffa85d34a6dd2e5a6de1c29f06649659b08181df94b1d92c0adbb2e68396e3c3e39c86b741edeed1120c8d4b8a38ed013492907ee1f61f70394efa9ebbf6
|
@@ -101,10 +101,7 @@ private
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def cache_directory
|
104
|
-
|
105
|
-
cache_path = "#{Dir.tmpdir}/rails-imager-cache"
|
106
|
-
Dir.mkdir(cache_path) unless Dir.exist?(cache_path)
|
107
|
-
return cache_path
|
104
|
+
RailsImager.cache_handler.path
|
108
105
|
end
|
109
106
|
|
110
107
|
def should_generate_cache?
|
@@ -126,6 +123,7 @@ private
|
|
126
123
|
@image.format = "png"
|
127
124
|
apply_image_changes
|
128
125
|
@image.write(@cache_path)
|
126
|
+
@image.destroy!
|
129
127
|
end
|
130
128
|
|
131
129
|
#Create a new image-object based on the given image-object and the parameters.
|
data/lib/rails_imager.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
class RailsImager::CacheHandler
|
2
|
+
def initialize(args = {})
|
3
|
+
@args = args
|
4
|
+
end
|
5
|
+
|
6
|
+
def path
|
7
|
+
unless @path
|
8
|
+
require "tmpdir"
|
9
|
+
@path = "#{Dir.tmpdir}/rails-imager-cache"
|
10
|
+
Dir.mkdir(@path) unless Dir.exist?(@path)
|
11
|
+
end
|
12
|
+
|
13
|
+
return @path
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear(args = {})
|
17
|
+
Dir.foreach(path) do |file|
|
18
|
+
next if file == "." || file == ".."
|
19
|
+
next unless file.end_with?(".png")
|
20
|
+
|
21
|
+
full_path = "#{path}/#{file}"
|
22
|
+
File.unlink(full_path)
|
23
|
+
yield full_path if block_given?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/rails_imager/version.rb
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
namespace :rails_imager do
|
2
|
+
desc "Explaining what the task does"
|
3
|
+
task clear_cache: :environment do
|
4
|
+
puts "Beginning to clear cache"
|
5
|
+
|
6
|
+
count = 0
|
7
|
+
RailsImager.cache_handler.clear do |full_path|
|
8
|
+
puts "Deleted #{full_path}"
|
9
|
+
count += 1
|
10
|
+
end
|
11
|
+
|
12
|
+
puts "Cleared #{count} files"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsImager::CacheHandler do
|
4
|
+
it 'works' do
|
5
|
+
File.open("#{RailsImager.cache_handler.path}/test.png", "w").close
|
6
|
+
|
7
|
+
files = []
|
8
|
+
RailsImager.cache_handler.clear do |file|
|
9
|
+
files << file
|
10
|
+
end
|
11
|
+
|
12
|
+
expect(files).to include "#{RailsImager.cache_handler.path}/test.png"
|
13
|
+
end
|
14
|
+
end
|
data/spec/dummy/log/test.log
CHANGED
@@ -11808,3 +11808,93 @@ Processing by RailsImager::ImagesController#show as HTML
|
|
11808
11808
|
Sent file /tmp/rails-imager-cache/cdb14e91faa664e5555fd4bf048f485b.png (0.0ms)
|
11809
11809
|
Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
|
11810
11810
|
[1m[35m (0.0ms)[0m rollback transaction
|
11811
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11812
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11813
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11814
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11815
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11816
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11817
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11818
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11819
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11820
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11821
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11822
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11823
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11824
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11825
|
+
Parameters: {"image"=>{"maxwidth"=>"200"}, "id"=>"test.png"}
|
11826
|
+
Sent file /tmp/rails-imager-cache/98c9a4c721daf05bde343cdf5f8e2a83.png (0.1ms)
|
11827
|
+
Completed 200 OK in 36ms (ActiveRecord: 0.0ms)
|
11828
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11829
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11830
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11831
|
+
Parameters: {"image"=>{"smartsize"=>"400"}, "id"=>"test.png"}
|
11832
|
+
Sent file /tmp/rails-imager-cache/a1d5e5791060350da8196efcf19e6d3c.png (0.1ms)
|
11833
|
+
Completed 200 OK in 82ms (ActiveRecord: 0.0ms)
|
11834
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11835
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11836
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11837
|
+
Parameters: {"image"=>{"smartsize"=>"640", "rounded_corners"=>"15", "border"=>"1", "border_color"=>"black"}, "id"=>"test.png"}
|
11838
|
+
Sent file /tmp/rails-imager-cache/cf61b86225ee9b620f73b5fe0e6af0b4.png (0.1ms)
|
11839
|
+
Completed 200 OK in 199ms (ActiveRecord: 0.0ms)
|
11840
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11841
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11842
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11843
|
+
Parameters: {"image"=>{"smartsize"=>"350"}, "id"=>"test.png"}
|
11844
|
+
Sent file /tmp/rails-imager-cache/3a04c3c926cd0bed2df232261ed539d0.png (0.1ms)
|
11845
|
+
Completed 200 OK in 65ms (ActiveRecord: 0.0ms)
|
11846
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11847
|
+
Parameters: {"image"=>{"smartsize"=>"350"}, "id"=>"test.png"}
|
11848
|
+
Rendered text template (0.0ms)
|
11849
|
+
Completed 304 Not Modified in 4ms (Views: 4.0ms | ActiveRecord: 0.0ms)
|
11850
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11851
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11852
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11853
|
+
Parameters: {"image"=>{"width"=>"640", "height"=>"480"}, "id"=>"test.png"}
|
11854
|
+
Sent file /tmp/rails-imager-cache/3b24cae006ac63b391b4e16561d0c176.png (0.1ms)
|
11855
|
+
Completed 200 OK in 126ms (ActiveRecord: 0.0ms)
|
11856
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11857
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11858
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11859
|
+
Parameters: {"image"=>{"width"=>"640", "height"=>"480"}, "id"=>"test_æ_%C3%B8_å.png"}
|
11860
|
+
Sent file /tmp/rails-imager-cache/38575c34bde0655cda92b47d2763aec5.png (0.1ms)
|
11861
|
+
Completed 200 OK in 127ms (ActiveRecord: 0.0ms)
|
11862
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11863
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11864
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11865
|
+
Parameters: {"image"=>{"maxheight"=>"200"}, "id"=>"test.png"}
|
11866
|
+
Sent file /tmp/rails-imager-cache/d21ceb31c3fa4da3d50efe25436e51fe.png (0.0ms)
|
11867
|
+
Completed 200 OK in 27ms (ActiveRecord: 0.0ms)
|
11868
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11869
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11870
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11871
|
+
Parameters: {"image"=>{"smartsize"=>"400", "force"=>true}, "id"=>"test.png"}
|
11872
|
+
Sent file /tmp/rails-imager-cache/a1d5e5791060350da8196efcf19e6d3c.png (0.1ms)
|
11873
|
+
Completed 200 OK in 79ms (ActiveRecord: 0.0ms)
|
11874
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11875
|
+
Parameters: {"image"=>{"smartsize"=>"400"}, "id"=>"test.png"}
|
11876
|
+
Sent file /tmp/rails-imager-cache/a1d5e5791060350da8196efcf19e6d3c.png (0.0ms)
|
11877
|
+
Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
|
11878
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11879
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11880
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11881
|
+
Parameters: {"image"=>{"smartsize"=>"200", "rounded_corners"=>"8"}, "id"=>"test.png"}
|
11882
|
+
Sent file /tmp/rails-imager-cache/68a968398cfa1d0cd84dd5a794089554.png (0.1ms)
|
11883
|
+
Completed 200 OK in 38ms (ActiveRecord: 0.0ms)
|
11884
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11885
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11886
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11887
|
+
Parameters: {"image"=>{"smartsize"=>"200"}, "id"=>"test.png"}
|
11888
|
+
Sent file /tmp/rails-imager-cache/cdb14e91faa664e5555fd4bf048f485b.png (0.0ms)
|
11889
|
+
Completed 200 OK in 30ms (ActiveRecord: 0.0ms)
|
11890
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11891
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11892
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11893
|
+
Parameters: {"image"=>{"smartsize"=>"200"}, "id"=>"/../config.ru"}
|
11894
|
+
Completed 500 Internal Server Error in 0ms (ActiveRecord: 0.0ms)
|
11895
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11896
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
11897
|
+
Processing by RailsImager::ImagesController#show as HTML
|
11898
|
+
Parameters: {"image"=>{"invalid_param"=>"kasper"}, "id"=>"test.png"}
|
11899
|
+
Completed 500 Internal Server Error in 0ms (ActiveRecord: 0.0ms)
|
11900
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_imager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -183,10 +183,12 @@ files:
|
|
183
183
|
- app/views/layouts/rails_imager/application.html.erb
|
184
184
|
- config/routes.rb
|
185
185
|
- lib/rails_imager.rb
|
186
|
+
- lib/rails_imager/cache_handler.rb
|
186
187
|
- lib/rails_imager/config.rb
|
187
188
|
- lib/rails_imager/engine.rb
|
188
189
|
- lib/rails_imager/version.rb
|
189
190
|
- lib/tasks/rails_imager_tasks.rake
|
191
|
+
- spec/cache_handler_spec.rb
|
190
192
|
- spec/controllers/rails_imager/images_controller_spec.rb
|
191
193
|
- spec/dummy/README.rdoc
|
192
194
|
- spec/dummy/Rakefile
|
@@ -335,5 +337,6 @@ test_files:
|
|
335
337
|
- spec/dummy/config/locales/en.yml
|
336
338
|
- spec/dummy/config/database.yml
|
337
339
|
- spec/dummy/config/routes.rb
|
340
|
+
- spec/cache_handler_spec.rb
|
338
341
|
- spec/spec_helper.rb
|
339
342
|
- spec/helpers/rails_imager/images_helper_spec.rb
|