yandex_captcha 0.4.3.1 → 0.4.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/app/controllers/yandex_captcha/application_controller.rb +0 -1
- data/app/controllers/yandex_captcha/captcha_controller.rb +1 -1
- data/lib/yandex_captcha/engine.rb +2 -5
- data/lib/yandex_captcha/helpers/base.rb +25 -0
- data/lib/yandex_captcha/helpers/rails.rb +0 -1
- data/lib/yandex_captcha/helpers/sinatra.rb +0 -1
- data/lib/yandex_captcha/sinatra.rb +1 -0
- data/lib/yandex_captcha/version.rb +1 -1
- data/lib/yandex_captcha.rb +2 -0
- data/test/{yandex_cleanweb_test.rb → yandex_captcha_test.rb} +0 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe8fbc6198a6875f892a9e1f5f89a18322027d39
|
4
|
+
data.tar.gz: be090633fc2c299407adedfa06eb8813587724b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 597c3dbc4ef6714854d8499f772d2371170b3573e78d60dd77ee7d1eb66e87e03dfb5f95668d1fc22d905756f0e6aeb79ccdc84675104ba32edf7dc8ac6e018c
|
7
|
+
data.tar.gz: 4c8a9aac908039065b28754547a320c0365cc24a3631fb2da76a54d36b6fbcea3128cfc2ca2403a9a76879883baddd79a0e5f64d284cb91dd909bbeca7aba8ab
|
data/README.md
CHANGED
@@ -60,14 +60,28 @@ end
|
|
60
60
|
#### Code
|
61
61
|
|
62
62
|
```erb
|
63
|
-
|
64
|
-
<%= captcha_tags ajax:true %>
|
65
|
-
|
63
|
+
<form action="/path" method="POST">
|
64
|
+
<%= captcha_tags ajax:true %>
|
65
|
+
<input type="submit" value="Submit" />
|
66
|
+
</form>
|
67
|
+
|
68
|
+
or
|
69
|
+
|
70
|
+
<%= form_tag some_response_path do %>
|
71
|
+
<%= captcha_tags ajax:true %>
|
72
|
+
<%= submit_tag 'Submit' %>
|
73
|
+
<% end %>
|
66
74
|
```
|
67
75
|
|
68
76
|
### In Controllers
|
69
77
|
|
70
78
|
```ruby
|
79
|
+
# Rails / Sinatra / or if you included helpers
|
80
|
+
if valid_captcha?(params[:captcha_response_id], params[:captcha_response_field])
|
81
|
+
# some
|
82
|
+
end
|
83
|
+
|
84
|
+
# Long way
|
71
85
|
if YandexCaptcha::Verify.valid_captcha?(params[:captcha_response_id], params[:captcha_response_field])
|
72
86
|
# some
|
73
87
|
end
|
@@ -76,6 +90,10 @@ end
|
|
76
90
|
### Other examples
|
77
91
|
|
78
92
|
```ruby
|
93
|
+
# Helpers
|
94
|
+
spam?("just phrase")
|
95
|
+
=> false
|
96
|
+
|
79
97
|
# Methods
|
80
98
|
YandexCaptcha::Verify.spam?("just phrase")
|
81
99
|
=> false
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module YandexCaptcha
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
isolate_namespace YandexCaptcha
|
4
|
-
engine_name 'yandex_captcha'
|
5
4
|
|
6
5
|
if Rails.version >= '3.1'
|
7
6
|
initializer :assets do |app|
|
@@ -10,10 +9,8 @@ module YandexCaptcha
|
|
10
9
|
end
|
11
10
|
|
12
11
|
initializer "setup config" do
|
13
|
-
|
14
|
-
|
15
|
-
ActionController::Base.send(:include, ::YandexCaptcha::Verify)
|
16
|
-
end
|
12
|
+
ActionView::Base.send(:include, ::YandexCaptcha::Helpers::Rails)
|
13
|
+
ActionController::Base.send(:include, ::YandexCaptcha::Helpers::Base)
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module YandexCaptcha
|
2
|
+
module Helpers
|
3
|
+
module Base
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
def spam? *args
|
11
|
+
YandexCaptcha::Verify.spam? *args
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_captcha *args
|
15
|
+
YandexCaptcha::Verify.get_captcha *args
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid_captcha? *args
|
19
|
+
YandexCaptcha::Verify.valid_captcha? *args
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/yandex_captcha.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'yandex_captcha/configuration'
|
2
2
|
require 'yandex_captcha/verify'
|
3
|
+
require 'yandex_captcha/helpers/base'
|
3
4
|
|
4
5
|
module YandexCaptcha
|
6
|
+
module Helpers ; end
|
5
7
|
class NoApiKeyException < Exception; end
|
6
8
|
class BadResponseException < Exception; end
|
7
9
|
class YandexCaptchaError < StandardError; end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yandex_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.3.
|
4
|
+
version: 0.4.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Merkulov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/yandex_captcha.rb
|
108
108
|
- lib/yandex_captcha/configuration.rb
|
109
109
|
- lib/yandex_captcha/engine.rb
|
110
|
+
- lib/yandex_captcha/helpers/base.rb
|
110
111
|
- lib/yandex_captcha/helpers/rails.rb
|
111
112
|
- lib/yandex_captcha/helpers/sinatra.rb
|
112
113
|
- lib/yandex_captcha/rails.rb
|
@@ -114,7 +115,7 @@ files:
|
|
114
115
|
- lib/yandex_captcha/verify.rb
|
115
116
|
- lib/yandex_captcha/version.rb
|
116
117
|
- test/test_helper.rb
|
117
|
-
- test/
|
118
|
+
- test/yandex_captcha_test.rb
|
118
119
|
- yandex_captcha.gemspec
|
119
120
|
homepage: https://github.com/merqlove/yandex-captcha
|
120
121
|
licenses: []
|
@@ -141,4 +142,4 @@ specification_version: 4
|
|
141
142
|
summary: Ruby wrapper for Yandex.Cleanweb spam detector
|
142
143
|
test_files:
|
143
144
|
- test/test_helper.rb
|
144
|
-
- test/
|
145
|
+
- test/yandex_captcha_test.rb
|