Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #14 from korin/tmp-path

tmp path should be configurable
  • Loading branch information...
commit 580b73f9c7c32fd1ca30e5095ac48ff23fe389a4 2 parents 4a16e31 + 93014ee
@galetahub galetahub authored
View
7 README.rdoc
@@ -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
4 lib/simple_captcha.rb
@@ -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
View
2  lib/simple_captcha/image.rb
@@ -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)}'"
Please sign in to comment.
Something went wrong with that request. Please try again.