Permalink
Browse files

Merge pull request #14 from korin/tmp-path

tmp path should be configurable
  • Loading branch information...
2 parents 4a16e31 + 93014ee commit 580b73f9c7c32fd1ca30e5095ac48ff23fe389a4 @galetahub galetahub committed Jan 24, 2012
Showing with 12 additions and 1 deletion.
  1. +7 −0 README.rdoc
  2. +4 −0 lib/simple_captcha.rb
  3. +1 −1 lib/simple_captcha/image.rb
View
@@ -166,6 +166,13 @@ You can provide the path where image_magick is installed as well:
sc.image_magick_path = '/usr/bin' # you can check this from console by running: which convert
end
+You can provide the path where should be stored tmp files.
+It's usefull when you dont have acces to /tmp (default directory)
+
+ SimpleCaptcha.setup do |sc|
+ sc.tmp_path = '/tmp' # or somewhere in project eg. Rails.root.join('tmp/simple_captcha').to_s, make shure directory exists
+ end
+
===How to change the CSS for SimpleCaptcha DOM elements?
You can change the CSS of the SimpleCaptcha DOM elements as per your need in this file.
View
@@ -40,6 +40,10 @@ module SimpleCaptcha
mattr_accessor :image_magick_path
@@image_magick_path = ''
+ # tmp directory
+ mattr_accessor :tmp_path
+ @@tmp_path = nil
+
def self.add_image_style(name, params = [])
SimpleCaptcha::ImageHelpers.image_styles.update(name.to_s => params)
end
@@ -68,7 +68,7 @@ def generate_simple_captcha_image(simple_captcha_key) #:nodoc
params << "-pointsize 22"
params << "-implode 0.2"
- dst = RUBY_VERSION < '1.9' ? Tempfile.new('simple_captcha.jpg') : Tempfile.new(['simple_captcha', '.jpg'])
+ dst = Tempfile.new(RUBY_VERSION < '1.9' ? 'simple_captcha.jpg' : ['simple_captcha', '.jpg'], SimpleCaptcha.tmp_path)
dst.binmode
params << "label:#{text} '#{File.expand_path(dst.path)}'"

0 comments on commit 580b73f

Please sign in to comment.