aritcaptcha 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/aritcaptcha.gemspec +1 -1
- data/lib/aritcaptcha/aritcaptcha_helper.rb +5 -1
- data/lib/aritcaptcha/calculation.rb +6 -1
- data/spec/aritcaptcha_helper_spec.rb +11 -11
- data/spec/aritcaptcha_spec.rb +19 -19
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.12.0
|
data/aritcaptcha.gemspec
CHANGED
@@ -14,7 +14,11 @@ module Aritcaptcha
|
|
14
14
|
number2 = options[:two] || 50
|
15
15
|
operation = options[:op] || OPERATIONS[rand(OPERATIONS.size)]
|
16
16
|
|
17
|
-
|
17
|
+
result = nil
|
18
|
+
|
19
|
+
while result.nil? or !result.is_a?(Integer) or result < 0
|
20
|
+
equation, result = Aritcaptcha::Calculation.generate_calculation number1, number2, operation
|
21
|
+
end
|
18
22
|
|
19
23
|
session[:equation] = [equation_key, eval(equation)]
|
20
24
|
|
@@ -7,6 +7,9 @@ module Aritcaptcha
|
|
7
7
|
number2 = rand(number2)
|
8
8
|
equation = "#{number1} #{operation} #{number2}"
|
9
9
|
|
10
|
+
# Division by zero
|
11
|
+
return [nil, nil] if operation == "/" and number2.zero?
|
12
|
+
|
10
13
|
result = eval("#{number1.to_f} #{operation} #{number2.to_f}")
|
11
14
|
|
12
15
|
[equation, result]
|
@@ -14,4 +17,6 @@ module Aritcaptcha
|
|
14
17
|
|
15
18
|
end
|
16
19
|
|
17
|
-
end
|
20
|
+
end
|
21
|
+
|
22
|
+
puts Aritcaptcha::Calculation.generate_calculation(10, 0, "/")
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "AritcaptchaHelper" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
1
|
+
# require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
#
|
3
|
+
# describe "AritcaptchaHelper" do
|
4
|
+
# before :each do
|
5
|
+
# @helper = Aritcaptcha::AritcaptchaHelper
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
# it "should accept two numbers and the operator as argument" do
|
9
|
+
# puts Aritcaptcha::AritcaptchaHelper.aritcaptcha_tag :html => { :one => "10", :two => "10", :operation => "+" }
|
10
|
+
# end
|
11
|
+
# end
|
data/spec/aritcaptcha_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Aritcaptcha" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
1
|
+
# require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
#
|
3
|
+
# describe "Aritcaptcha" do
|
4
|
+
# it "should return the correct sum of its arguments" do
|
5
|
+
# Aritcaptcha::Calculation.generate_calculation(10, 10, "+").should == ["10 + 10", 20]
|
6
|
+
# end
|
7
|
+
# #
|
8
|
+
# # it "should return the subtraction of its arguments" do
|
9
|
+
# # Captcha::Aritcaptcha.generate_calculation(20, 10, "-").should == ["20 - 10", 10]
|
10
|
+
# # end
|
11
|
+
# #
|
12
|
+
# # it "should return the division of its arguments" do
|
13
|
+
# # Captcha::Aritcaptcha.generate_calculation(10, 2, "/").should == ["10 / 2", 5]
|
14
|
+
# # end
|
15
|
+
# #
|
16
|
+
# # it "should return the multiplicationof its arguments" do
|
17
|
+
# # Captcha::Aritcaptcha.generate_calculation(10, 10, "*").should == ["10 * 10", 100]
|
18
|
+
# # end
|
19
|
+
# end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aritcaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 12
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.12.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Guilherme Nascimento
|