lib/simple_captcha.rb in glebtv-simple_captcha-0.2.1 vs lib/simple_captcha.rb in glebtv-simple_captcha-0.3.1

- old
+ new

@@ -5,31 +5,49 @@ autoload :ImageHelpers, 'simple_captcha/image' autoload :ViewHelper, 'simple_captcha/view' autoload :ControllerHelpers, 'simple_captcha/controller' - autoload :FormBuilder, 'simple_captcha/form_builder' - autoload :CustomFormBuilder, 'simple_captcha/formtastic' - - if defined?(Mongoid) - require 'simple_captcha/mongoid' - autoload :ModelHelpers, 'simple_captcha/mongoid' - autoload :SimpleCaptchaData, 'simple_captcha/simple_captcha_data_mongoid' + autoload :FormBuilder, 'simple_captcha/hooks/form_builder' + + if Object.const_defined?("Formtastic") + require "simple_captcha/hooks/formtastic" + end + + if Object.const_defined?("SimpleForm") + require "simple_captcha/hooks/simple_form" + end + + if Object.const_defined?("Mongoid") + autoload :SimpleCaptchaData, 'simple_captcha/storage/mongoid' else + autoload :SimpleCaptchaData, 'simple_captcha/storage/active_record' autoload :ModelHelpers, 'simple_captcha/active_record' - autoload :SimpleCaptchaData, 'simple_captcha/simple_captcha_data_ar' end + autoload :Middleware, 'simple_captcha/middleware' mattr_accessor :image_size @@image_size = "100x28" mattr_accessor :length @@length = 5 + # 'embosed_silver', + # 'simply_red', + # 'simply_green', + # 'simply_blue', + # 'distorted_black', + # 'all_black', + # 'charcoal_grey', + # 'almost_invisible' + # 'random' + mattr_accessor :image_style + @@image_style = 'simply_blue' + mattr_accessor :image_color - @@image_color = '#0089d1' + @@image_color = nil # 'low', 'medium', 'high', 'random' mattr_accessor :distortion @@distortion = 'low' @@ -38,9 +56,16 @@ @@image_magick_path = '' # tmp directory mattr_accessor :tmp_path @@tmp_path = nil + + mattr_accessor :pointsize + @@pointsize = 30 + + def self.add_image_style(name, params = []) + SimpleCaptcha::ImageHelpers.image_styles.update(name.to_s => params) + end def self.setup yield self end end