Module: ConciseRuCaptcha
- Defined in:
- lib/concise_rucaptcha.rb,
lib/concise_rucaptcha/cache.rb,
lib/concise_rucaptcha/engine.rb,
lib/concise_rucaptcha/version.rb,
lib/concise_rucaptcha/view_helpers.rb,
lib/concise_rucaptcha/configuration.rb,
lib/concise_rucaptcha/controller_helpers.rb,
app/controllers/concise_ru_captcha/concise_captcha_controller.rb,
ext/concise_rucaptcha/concise_rucaptcha.c
Defined Under Namespace
Modules: ControllerHelpers, ViewHelpers
Classes: ConciseCaptchaController, Configuration, Engine
Constant Summary
collapse
- VERSION =
'2.0.1'
Class Method Summary
collapse
Class Method Details
.cache ⇒ Object
5
6
7
8
9
|
# File 'lib/concise_rucaptcha/cache.rb', line 5
def cache
return @cache if defined? @cache
@cache = ActiveSupport::Cache.lookup_store(ConciseRuCaptcha.config.cache_store)
@cache
end
|
.check_cache_store! ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/concise_rucaptcha.rb', line 37
def check_cache_store!
cache_store = ConciseRuCaptcha.config.cache_store
store_name = cache_store.is_a?(Array) ? cache_store.first : cache_store
if [:memory_store, :null_store, :file_store].include?(store_name)
ConciseRuCaptcha.config.cache_store = [:file_store, Rails.root.join('tmp/cache/concise_rucaptcha/session')]
puts "
RuCaptcha's cache_store requirements are stored across processes and machines,
such as :mem_cache_store, :redis_store, or other distributed storage.
But your current set is #{cache_store}, it has changed to :file_store for working.
NOTE: :file_store is still not a good way, it only works with single server case.
Please make config file `config/initializers/concise_rucaptcha.rb` to setup `cache_store`.
More infomation please read GitHub RuCaptcha README file.
https://github.com/liuzhenangel/concise_rucaptcha
"
end
end
|
.config ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/concise_rucaptcha.rb', line 14
def config
return @config if defined?(@config)
@config = Configuration.new
@config.style = :colorful
@config.expires_in = 2.minutes
if Rails.application
@config.cache_store = Rails.application.config.cache_store
else
@config.cache_store = :mem_cache_store
end
@config.cache_store
@config
end
|
28
29
30
|
# File 'lib/concise_rucaptcha.rb', line 28
def configure(&block)
config.instance_exec(&block)
end
|
.create ⇒ Object
192
|
# File 'ext/concise_rucaptcha/concise_rucaptcha.c', line 192
VALUE create(VALUE self, VALUE style);
|
.generate ⇒ Object
32
33
34
35
|
# File 'lib/concise_rucaptcha.rb', line 32
def generate()
style = config.style == :colorful ? 1 : 0
self.create(style)
end
|