kaptcha 0.0.3 → 0.0.3.5
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.
- data/lib/core/kaptcha.rb +23 -15
- metadata +3 -2
data/lib/core/kaptcha.rb
CHANGED
@@ -21,7 +21,6 @@ module Captcha
|
|
21
21
|
|
22
22
|
# def __captcha__
|
23
23
|
# title = self.human_captcha_desc
|
24
|
-
|
25
24
|
# end
|
26
25
|
|
27
26
|
|
@@ -35,6 +34,29 @@ module Captcha
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def initialize(params={}, &block)
|
37
|
+
initialize_kaptcha params
|
38
|
+
super(params, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def validate
|
42
|
+
unless captcha_form_result == captcha_code
|
43
|
+
initialize_kaptcha
|
44
|
+
return errors.add(:captcha_code, 'Пожалуйста, проверьте контрольный вопрос.')
|
45
|
+
end
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
def captcha_desc
|
50
|
+
@@captcha_desc ||= raise 'Error occurred.'
|
51
|
+
end
|
52
|
+
|
53
|
+
def human_captcha_desc
|
54
|
+
@@human_captcha_desc ||= raise 'Error occurred.'
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def initialize_kaptcha(params=nil)
|
38
60
|
begin
|
39
61
|
captcha_a = params[:captcha_code].split[0].to_i
|
40
62
|
rescue NoMethodError
|
@@ -66,20 +88,6 @@ module Captcha
|
|
66
88
|
@@human_captcha_desc = "Скажите, сколько будет #{captcha_a} #{@@human_captcha_operation} #{captcha_b} ?"
|
67
89
|
|
68
90
|
@@captcha_code = captcha_a.send(captcha_operation, captcha_b)
|
69
|
-
super(params, &block)
|
70
|
-
end
|
71
|
-
|
72
|
-
def validate
|
73
|
-
return errors.add(:captcha_code, 'Пожалуйста, проверьте контрольный вопрос.') unless captcha_form_result == captcha_code
|
74
|
-
true
|
75
|
-
end
|
76
|
-
|
77
|
-
def captcha_desc
|
78
|
-
@@captcha_desc ||= raise 'Error occurred.'
|
79
|
-
end
|
80
|
-
|
81
|
-
def human_captcha_desc
|
82
|
-
@@human_captcha_desc ||= raise 'Error occurred.'
|
83
91
|
end
|
84
92
|
|
85
93
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 73
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 3
|
10
|
-
|
10
|
+
- 5
|
11
|
+
version: 0.0.3.5
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Bogdan Kulbida
|