aritcaptcha 1.2.0 → 1.3.0

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 CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
data/aritcaptcha.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aritcaptcha}
8
- s.version = "1.2.0"
8
+ s.version = "1.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Guilherme Nascimento"]
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "aritcaptcha.gemspec",
27
27
  "lib/aritcaptcha.rb",
28
+ "lib/aritcaptcha/aritcaptcha_helper.rb",
28
29
  "lib/aritcaptcha/calculation.rb",
29
30
  "spec/aritcaptcha_helper_spec.rb",
30
31
  "spec/aritcaptcha_spec.rb",
@@ -0,0 +1,28 @@
1
+ module Aritcaptcha
2
+
3
+ class AritcaptchaHelper
4
+ ADD = '+'
5
+ SUB = '-'
6
+ DIV = '/'
7
+ MUL = '*'
8
+
9
+ OPERATIONS = [ADD, SUB, DIV, MUL]
10
+
11
+ def aritcaptcha_tag(options={})
12
+ number1 = options[:one] || 50
13
+ number2 = options[:two] || 50
14
+ operation = options[:op] || OPERATIONS[rand(OPERATIONS.size)]
15
+
16
+ equation, result = Aritcaptcha::Calculation.generate_calculation number1, number2, operation
17
+
18
+ html_options = options[:html].inject([]){|dump, pair| dump << "#{pair[0]}=\"#{pair[1]}\""}
19
+ html_options.join(" ")
20
+ puts html_options
21
+
22
+
23
+ html = "#{equation} = <input type='text' name='equation' #{html_options} />"
24
+ html
25
+ end
26
+ end
27
+
28
+ end
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: 31
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 1.2.0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Guilherme Nascimento
@@ -52,6 +52,7 @@ files:
52
52
  - VERSION
53
53
  - aritcaptcha.gemspec
54
54
  - lib/aritcaptcha.rb
55
+ - lib/aritcaptcha/aritcaptcha_helper.rb
55
56
  - lib/aritcaptcha/calculation.rb
56
57
  - spec/aritcaptcha_helper_spec.rb
57
58
  - spec/aritcaptcha_spec.rb