yandex_captcha 0.4.3.1 → 0.4.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8bfb7505a2114b720360721d2a5e81a9bfdf0a2
4
- data.tar.gz: 982bdd9d04c3ea6f697404bbaed5680bf91e5484
3
+ metadata.gz: fe8fbc6198a6875f892a9e1f5f89a18322027d39
4
+ data.tar.gz: be090633fc2c299407adedfa06eb8813587724b2
5
5
  SHA512:
6
- metadata.gz: 4cde01cbaf9648ec509839e43a8792e6ed7ae5d91c3d10f05fd93593afe188005124c681c12914b071fbcaaa76d04f5622ab642e136ee8688defa5edcc235d43
7
- data.tar.gz: 720f1b250f37bf0d44b07b0f236ba45b66a6d360c8c21688cdf22f0890a489fea2036f2e480638b72717260dca3612c9d6dd3a2293ac4bbdd9dbb74f1f634730
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
- <%= captcha_tags %>
64
- <%= captcha_tags ajax:true %>
65
- <%= captcha_tags noscript:true %>
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,6 +1,5 @@
1
1
  module YandexCaptcha
2
2
  class ApplicationController < ActionController::Base
3
- layout false
4
3
  protect_from_forgery
5
4
  end
6
5
  end
@@ -2,7 +2,7 @@ module YandexCaptcha
2
2
  class CaptchaController < YandexCaptcha::ApplicationController
3
3
  respond_to :json
4
4
  def show
5
- respond_with YandexCaptcha::Verify.get_captcha
5
+ respond_with get_captcha
6
6
  end
7
7
  end
8
8
  end
@@ -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
- begin
14
- ActionView::Base.send(:include, ::YandexCaptcha::Helpers::Rails)
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
@@ -1,7 +1,6 @@
1
1
  module YandexCaptcha
2
2
  module Helpers
3
3
  module Rails
4
-
5
4
  def captcha_tags(options = {})
6
5
 
7
6
  error = options[:error] ||= ((defined? flash) ? flash[:captcha_error] : "")
@@ -1,7 +1,6 @@
1
1
  module YandexCaptcha
2
2
  module Helpers
3
3
  module Sinatra
4
-
5
4
  def captcha_tags(options = {})
6
5
  template = settings.captcha_ajax_template.to_s.to_sym
7
6
  if options[:ajax]
@@ -14,6 +14,7 @@ module YandexCaptcha
14
14
  end
15
15
 
16
16
  app.helpers Helpers::Sinatra
17
+ app.helpers Helpers::Base
17
18
  end
18
19
  end
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module YandexCaptcha
2
- VERSION = "0.4.3.1"
2
+ VERSION = "0.4.3.3"
3
3
  end
@@ -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
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.1
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-04 00:00:00.000000000 Z
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/yandex_cleanweb_test.rb
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/yandex_cleanweb_test.rb
145
+ - test/yandex_captcha_test.rb