mathcha 0.4.4 → 0.4.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/VERSION +1 -1
- data/lib/mathcha/mathcha_helper.rb +9 -12
- data/pkg/mathcha-0.4.4.gem +0 -0
- metadata +2 -2
- data/mathcha.gemspec +0 -59
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.5
|
@@ -34,14 +34,18 @@ module Mathcha
|
|
34
34
|
# * Only one mathcha can exist at a time, for now.
|
35
35
|
def mathcha_tag(options={})
|
36
36
|
options.reverse_merge!({:seed_one => 80, :seed_two => 10})
|
37
|
+
|
38
|
+
solv_key = Time.now.to_i
|
39
|
+
result, eq = nil, nil
|
37
40
|
|
38
|
-
|
39
|
-
|
41
|
+
while result.nil? or !result.is_a?(Integer) or result < 0
|
42
|
+
result, eq = generate_solv(SOLV_OPS[rand(SOLV_OPS.size)], 80, 10)
|
43
|
+
end
|
40
44
|
|
41
|
-
session[:solv] = [solv_key, eval(
|
45
|
+
session[:solv] = [solv_key, eval(eq)]
|
42
46
|
|
43
47
|
html = ''
|
44
|
-
html << %{#{
|
48
|
+
html << %{#{eq} = <input type="text" name="solv" />\n}
|
45
49
|
html << %{<input type="hidden" name="solv_key" value="#{solv_key}" />\n}
|
46
50
|
html
|
47
51
|
end
|
@@ -54,14 +58,7 @@ module Mathcha
|
|
54
58
|
sol = eval(eq = "#{op1.to_f} #{op} #{op2.to_f}")
|
55
59
|
sol = (sol == sol.floor) ? sol.to_i : sol
|
56
60
|
|
57
|
-
|
58
|
-
when op == DIV
|
59
|
-
generate_solv(op, seed1, seed2) if (!sol.is_a?(Integer)) or (sol < 0)
|
60
|
-
when op == SUB
|
61
|
-
generate_solv(op, seed1, seed2) if sol < 0
|
62
|
-
end
|
63
|
-
|
64
|
-
return eq
|
61
|
+
return [sol, eq]
|
65
62
|
end
|
66
63
|
|
67
64
|
private :generate_solv
|
Binary file
|
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.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cory Wilkerson
|
@@ -30,13 +30,13 @@ files:
|
|
30
30
|
- lib/mathcha.rb
|
31
31
|
- lib/mathcha/mathcha_helper.rb
|
32
32
|
- lib/mathcha/mathcha_verify.rb
|
33
|
-
- mathcha.gemspec
|
34
33
|
- pkg/mathcha-0.0.0.gem
|
35
34
|
- pkg/mathcha-0.2.0.gem
|
36
35
|
- pkg/mathcha-0.4.0.gem
|
37
36
|
- pkg/mathcha-0.4.1.gem
|
38
37
|
- pkg/mathcha-0.4.2.gem
|
39
38
|
- pkg/mathcha-0.4.3.gem
|
39
|
+
- pkg/mathcha-0.4.4.gem
|
40
40
|
- rails/init.rb
|
41
41
|
- tasks/mathcha_tasks.rake
|
42
42
|
- test/mathcha_test.rb
|
data/mathcha.gemspec
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{mathcha}
|
8
|
-
s.version = "0.4.4"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Cory Wilkerson"]
|
12
|
-
s.date = %q{2009-10-16}
|
13
|
-
s.description = %q{Quick little arithmetic plain-text captcha}
|
14
|
-
s.email = %q{coryjwilkerson@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
"MIT-LICENSE",
|
20
|
-
"README",
|
21
|
-
"Rakefile",
|
22
|
-
"VERSION",
|
23
|
-
"install.rb",
|
24
|
-
"lib/mathcha.rb",
|
25
|
-
"lib/mathcha/mathcha_helper.rb",
|
26
|
-
"lib/mathcha/mathcha_verify.rb",
|
27
|
-
"mathcha.gemspec",
|
28
|
-
"pkg/mathcha-0.0.0.gem",
|
29
|
-
"pkg/mathcha-0.2.0.gem",
|
30
|
-
"pkg/mathcha-0.4.0.gem",
|
31
|
-
"pkg/mathcha-0.4.1.gem",
|
32
|
-
"pkg/mathcha-0.4.2.gem",
|
33
|
-
"pkg/mathcha-0.4.3.gem",
|
34
|
-
"rails/init.rb",
|
35
|
-
"tasks/mathcha_tasks.rake",
|
36
|
-
"test/mathcha_test.rb",
|
37
|
-
"test/test_helper.rb",
|
38
|
-
"uninstall.rb"
|
39
|
-
]
|
40
|
-
s.homepage = %q{http://github.com/corywilkerson/mathcha}
|
41
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
-
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.3.5}
|
44
|
-
s.summary = %q{Quick little arithmetic plain-text captcha}
|
45
|
-
s.test_files = [
|
46
|
-
"test/mathcha_test.rb",
|
47
|
-
"test/test_helper.rb"
|
48
|
-
]
|
49
|
-
|
50
|
-
if s.respond_to? :specification_version then
|
51
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
-
s.specification_version = 3
|
53
|
-
|
54
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
55
|
-
else
|
56
|
-
end
|
57
|
-
else
|
58
|
-
end
|
59
|
-
end
|