mathcha 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,13 @@
2
2
 
3
3
  Mathcha is a horribly-named, arithmetic-based, text-driven captcha. Why you ask? For very few good reasons:
4
4
 
5
- - I had never written a plugin.
6
- - I wanted to play with a few bits of technology I hadn't touched:
7
- -- git, github, gemcutter, gem packaging, jeweler
8
- - I really like Recaptcha it's just that I've seen a few folk using simple math problems; I prefer it.
9
- - I need this functionality across a few applications I've been working on.
5
+ * I had never written a plugin.
6
+ * I wanted to play with a few bits of technology I hadn't touched:
7
+ * git
8
+ * github
9
+ * gemcutter, gem packaging, jeweler
10
+ * I really like Recaptcha it's just that I've seen a few folk using simple math problems; I prefer it.
11
+ * I need this functionality across a few applications I've been working on.
10
12
 
11
13
  ## Note
12
14
 
@@ -24,11 +26,14 @@ Next, modify your config/environment.rb to reference the mathcha gem:
24
26
 
25
27
  `config.gem "mathcha", :source => "http://gemcutter.org"`
26
28
 
27
- ## Example
29
+ ## Usage
28
30
 
29
- * In your view: <%= mathcha_tag %>
30
- * In your controller: if (verify_mathcha(params))
31
- * More soon.
31
+ In your view (this will dump the proper input and a hidden key field)
32
32
 
33
+ `<%= mathcha_tag %>`
34
+
35
+ In your controller
36
+
37
+ `if (verify_mathcha(params))`
33
38
 
34
39
  Copyright (c) 2009 Cory Wilkerson, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.4
1
+ 0.5.5
@@ -35,20 +35,27 @@ module Mathcha
35
35
  # * The default session key for this thing is :solv, I'd suggest you leave it be.
36
36
  # * Only one mathcha can exist at a time, for now.
37
37
  def mathcha_tag(options={})
38
- options.reverse_merge!({:seed_one => 300, :seed_two => 100})
38
+ solv_key = Time.now.to_i
39
+ seed_one = options[:one] || 300
40
+ seed_two = options[:two] || 100
39
41
 
40
- solv_key = Time.now.to_i
41
- result, eq = nil, nil
42
+ result = nil
42
43
 
43
44
  while result.nil? or !result.is_a?(Integer) or result < 0
44
- result, eq, eq_slick = generate_solv(SOLV_OPS[rand(SOLV_OPS.size)], options[:seed_one], options[:seed_two])
45
+ result, eq, eq_slick = generate_solv(SOLV_OPS[rand(SOLV_OPS.size)], seed_one, seed_two)
45
46
  end
46
47
 
48
+ # Here we bury away the equation.
47
49
  session[:solv] = [solv_key, eval(eq)]
48
50
 
51
+ if options[:html]
52
+ html_options = options[:html].inject([]){|dump, pair| dump << "#{pair[0]}=\"#{pair[1]}\""}
53
+ html_options.join(" ")
54
+ end
55
+
49
56
  html = ''
50
57
  html << %{#{eq_slick.titlecase} = <input type="text" name="solv" />\n}
51
- html << %{<input type="hidden" name="solv_key" value="#{solv_key}" />\n}
58
+ html << %{<input type="hidden" name="solv_key" value="#{solv_key}" #{html_options} />\n}
52
59
  html
53
60
  end
54
61
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mathcha}
8
- s.version = "0.5.4"
8
+ s.version = "0.5.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cory Wilkerson"]
12
- s.date = %q{2009-10-16}
12
+ s.date = %q{2009-10-17}
13
13
  s.description = %q{Quick little arithmetic plain-text captcha}
14
14
  s.email = %q{coryjwilkerson@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
25
25
  "lib/mathcha/mathcha_helper.rb",
26
26
  "lib/mathcha/mathcha_verify.rb",
27
27
  "mathcha.gemspec",
28
- "pkg/mathcha-0.5.3.gem",
29
28
  "rails/init.rb",
30
29
  "tasks/mathcha_tasks.rake",
31
30
  "test/mathcha_test.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mathcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Wilkerson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-16 00:00:00 -05:00
12
+ date: 2009-10-17 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -40,7 +40,6 @@ files:
40
40
  - lib/mathcha/mathcha_helper.rb
41
41
  - lib/mathcha/mathcha_verify.rb
42
42
  - mathcha.gemspec
43
- - pkg/mathcha-0.5.3.gem
44
43
  - rails/init.rb
45
44
  - tasks/mathcha_tasks.rake
46
45
  - test/mathcha_test.rb
Binary file