rack-recaptcha 0.1.0 → 0.1.1

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.
@@ -0,0 +1,95 @@
1
+ # rack-recaptcha
2
+
3
+ Drop this Rack middleware in your web application to enable CAPTCHA verification via Recaptcha API.
4
+
5
+ ## How to Use
6
+
7
+ ### Configuration
8
+
9
+ First, install the library with:
10
+ [sudo] gem install rack-recaptcha
11
+
12
+ You have to require 'rack-recaptcha' in your gemfile.
13
+
14
+ ## Gemfile
15
+ gem 'rack-recaptcha', :require => 'rack/recaptcha'
16
+
17
+
18
+ Available options for `Rack::Recaptcha` middleware are:
19
+
20
+ * :public_key -- your ReCaptcha API public key *(required)*
21
+ * :private_key -- your ReCaptcha API private key *(required)*
22
+ * :login_path -- where user goes to login or access the recaptcha
23
+
24
+
25
+ Now configure your app to use the middleware. This might be different across each web framework.
26
+
27
+ #### Sinatra
28
+
29
+ use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET', :login_path => 'PATH'
30
+ helpers Rack::Recaptcha::Helpers
31
+
32
+ #### Padrino
33
+
34
+ ## app/app.rb
35
+ use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET', :login_path => 'PATH'
36
+ helpers Rack::Recaptcha::Helpers
37
+
38
+
39
+ #### Rails
40
+
41
+ ## environment.rb:
42
+ config.middleware.use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET', :login_path => 'PATH'
43
+
44
+ ## application_controller.rb
45
+ include Rack::Recaptcha::Helpers
46
+
47
+ ### Helpers
48
+
49
+ The `Rack::Recaptcha::Helpers` module (for Sinatra, Rails, Padrino) adds these methods to your app:
50
+
51
+ * `recaptcha_tag(type,options={})` -- generates the appropriate recaptcha scripts. must be included in a form_tag
52
+ - recaptcha\_tag(:challenge) => generates a recaptcha script
53
+ - recaptcha\_tag(:ajax) => generates an ajax recaptcha script
54
+ - if passed in a :display option, you can further alter the recaptcha\_tag
55
+ - recaptcha\_tag(:ajax, :display => {:theme => 'white'}) - recaptcha tag in white theme.
56
+ - recaptcha\_tag(:noscript) => generates a recaptcha noscript
57
+ - you can also pass in :public\_key manually as well.
58
+ - recaptcha\_tag(:challenge,:public\_key => 'PUBLIC')
59
+
60
+ * `verified?` -- returns whether or not the verification passed.
61
+
62
+ #### Example
63
+
64
+ In Padrino, here's how you would use the helpers.
65
+
66
+ ## new.haml
67
+ - form_tag '/login', :class => 'some_form', :method => 'post' do
68
+ = text_field_tag :email
69
+ = password_field_tag :password
70
+ = recaptcha_tag(:challenge)
71
+ = submit_tag "Submit"
72
+
73
+ ## sessions.rb
74
+ post :create, :map => '/login' do
75
+ if verified?
76
+ "passed!"
77
+ else
78
+ "failed!"
79
+ end
80
+ end
81
+
82
+
83
+ == Note on Patches/Pull Requests
84
+
85
+ * Fork the project.
86
+ * Make your feature addition or bug fix.
87
+ * Add tests for it. This is important so I don't break it in a
88
+ future version unintentionally.
89
+ * Commit, do not mess with rakefile, version, or history.
90
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
91
+ * Send me a pull request. Bonus points for topic branches.
92
+
93
+ == Copyright
94
+
95
+ Copyright (c) 2010 Arthur Chiu. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,3 +1,11 @@
1
+ require 'json'
2
+
3
+ RECAPTCHA_API_URL = 'http://api.recaptcha.net'
4
+ RECAPTCHA_API_SECURE_URL = 'https://api-secure.recaptcha.net'
5
+ RECAPTCHA_VERIFY_URL = 'http://api-verify.recaptcha.net/verify'
6
+
7
+ require File.expand_path(File.join(File.dirname(__FILE__),'recaptcha','helpers'))
8
+
1
9
  module Rack
2
10
  class Recaptcha
3
11
  attr_reader :options
@@ -32,4 +40,4 @@ module Rack
32
40
  end
33
41
 
34
42
  end
35
- end
43
+ end
@@ -0,0 +1,67 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rack-recaptcha}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Arthur Chiu"]
12
+ s.date = %q{2010-04-22}
13
+ s.description = %q{Rack middleware Captcha verification using Recaptcha API.}
14
+ s.email = %q{mr.arthur.chiu@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/rack/recaptcha.rb",
27
+ "lib/rack/recaptcha/helpers.rb",
28
+ "rack-recaptcha.gemspec",
29
+ "test.watchr",
30
+ "test/helpers_test.rb",
31
+ "test/recaptcha_test.rb",
32
+ "test/teststrap.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/achiu/rack-recaptcha}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.6}
38
+ s.summary = %q{Rack middleware for Recaptcha}
39
+ s.test_files = [
40
+ "test/helpers_test.rb",
41
+ "test/recaptcha_test.rb",
42
+ "test/teststrap.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<json>, [">= 0"])
51
+ s.add_development_dependency(%q<riot>, [">= 0"])
52
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
53
+ s.add_development_dependency(%q<rr>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<json>, [">= 0"])
56
+ s.add_dependency(%q<riot>, [">= 0"])
57
+ s.add_dependency(%q<rack-test>, [">= 0"])
58
+ s.add_dependency(%q<rr>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<json>, [">= 0"])
62
+ s.add_dependency(%q<riot>, [">= 0"])
63
+ s.add_dependency(%q<rack-test>, [">= 0"])
64
+ s.add_dependency(%q<rr>, [">= 0"])
65
+ end
66
+ end
67
+
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'teststrap'))
2
- require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','rack-recaptcha','helpers'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','rack','recaptcha','helpers'))
3
3
  require 'riot/rr'
4
4
 
5
5
  class Helper
@@ -7,7 +7,7 @@ require 'rack/builder'
7
7
  require 'rr'
8
8
  require 'riot'
9
9
  require 'riot/rr'
10
- require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','rack-recaptcha'))
10
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','rack','recaptcha'))
11
11
 
12
12
  PUBLIC_KEY = '0'*40
13
13
  PRIVATE_KEY = 'X'*40
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arthur Chiu
@@ -73,17 +73,17 @@ extensions: []
73
73
 
74
74
  extra_rdoc_files:
75
75
  - LICENSE
76
- - README.rdoc
76
+ - README.md
77
77
  files:
78
78
  - .document
79
79
  - .gitignore
80
80
  - LICENSE
81
- - README.rdoc
81
+ - README.md
82
82
  - Rakefile
83
83
  - VERSION
84
- - lib/rack-recaptcha.rb
85
- - lib/rack-recaptcha/helpers.rb
86
- - lib/rack-recaptcha/recaptcha.rb
84
+ - lib/rack/recaptcha.rb
85
+ - lib/rack/recaptcha/helpers.rb
86
+ - rack-recaptcha.gemspec
87
87
  - test.watchr
88
88
  - test/helpers_test.rb
89
89
  - test/recaptcha_test.rb
@@ -1,17 +0,0 @@
1
- = rack-recaptcha
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 Arthur. See LICENSE for details.
@@ -1,9 +0,0 @@
1
- require 'json'
2
-
3
- RECAPTCHA_API_URL = 'http://api.recaptcha.net'
4
- RECAPTCHA_API_SECURE_URL = 'https://api-secure.recaptcha.net'
5
- RECAPTCHA_VERIFY_URL = 'http://api-verify.recaptcha.net/verify'
6
-
7
-
8
- require File.expand_path(File.join(File.dirname(__FILE__),'rack-recaptcha','recaptcha'))
9
- require File.expand_path(File.join(File.dirname(__FILE__),'rack-recaptcha','helpers'))