rmagick_captcha 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d9ab979f6a82a80bf2be6dd2478e56de72b6c516
4
+ data.tar.gz: 60e51a1256538606303b8c0eca11b99bac1c5cbf
5
+ SHA512:
6
+ metadata.gz: 0cc28e16036efa8817f8ab8cacc879ec943765180514da4230b1f471c5f667c171132886d3696eb2048ff53701d5f101f6583ef6f99fa0d9ac2b07697e770f45
7
+ data.tar.gz: 1d41200a6e82e77823106d7c8e3d39379e4c220f0d2e0ccc45716d6866b1d3d37dcadb512369434bcb11ed954506bf97545005b3be24839af1f0633e529e64ea
data/MIT-LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2011 Artem Rufanov
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2011 Artem Rufanov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README CHANGED
@@ -1,89 +1,89 @@
1
- RMagickCaptcha
2
- ===================
3
-
4
- RMagickCaptcha is a gem that implements captcha for using in Rails application.
5
- The gem provides functionality to create a captcha image and validate user's input.
6
-
7
- * The gem allows multiple captchas at the same page
8
- * The gem supports I18n and provides locale resource
9
- * The gem provides rmagick_captcha controller controller to generate images
10
- * The gem allows ...
11
-
12
-
13
- Quick Start
14
- =======
15
- In your Gemfile:
16
-
17
- gem "rmagick_captcha", ">= 0.6.2"
18
-
19
-
20
- In your model:
21
-
22
- # Server create captcha_key, user input into captcha_text
23
- has_rmagick_captcha :captcha
24
- validate :validate_rmagick_captcha
25
-
26
-
27
- In your controller:
28
-
29
- download_rmagick_catcha :show
30
-
31
- def new
32
- @user = User.new
33
- session[:user_captcha] = @user.reset_captcha_key
34
- end
35
-
36
- def create
37
- @user = User.new(params[:user])
38
- @user.captcha_key = session[:user_captcha]
39
- @user.save
40
- if @user.errors.empty?
41
- session[:user_captcha] = nil
42
- redirect_back_or_default('/welcome')
43
- flash[:notice] = "Thanks for signing up!"
44
- else
45
- session[:user_captcha] = @user.reset_captcha_key
46
- render :action => 'new'
47
- end
48
- end
49
-
50
- In your views:
51
-
52
- <% form_for @user, :url => users_path,
53
- :html => {:id => "user_form", :class => "html-form" } do |f| %>
54
- <fieldset>
55
- <ul>
56
- <li>
57
- <%= rmagick_captcha_tag(:controller => "user", :id => "user_captcha") %>
58
- <%= f.text_field :captcha_text, :maxlength => 16%>
59
- <%= f.error_message_on :captcha_text %>
60
- </li>
61
- </ul>
62
- <%= f.submit "Submit"%>
63
- </fieldset>
64
- <% end %>
65
-
66
- In your routes.rb:
67
-
68
- match 'user(/show)' => 'user#show', :as => :captcha
69
-
70
-
71
- If you wish:
72
-
73
- -Run ruby script/rails generate rmagick_captcha to gen resources such as locale files.
74
- -Use config/initiaizers to configure options for this gem
75
-
76
-
77
-
78
- Installation
79
- =======
80
-
81
- * Type 'gem install --local rmagick_captcha' with root account if you have installed RubyGems.
82
-
83
-
84
- Example
85
- =======
86
-
87
- Example goes here.
88
-
89
- Copyright (c) 2011 arufanov, released under the MIT license.
1
+ RMagickCaptcha
2
+ ===================
3
+
4
+ RMagickCaptcha is a gem that implements captcha for using in Rails application.
5
+ The gem provides functionality to create a captcha image and validate user's input.
6
+
7
+ * The gem allows multiple captchas at the same page
8
+ * The gem supports I18n and provides locale resource
9
+ * The gem provides rmagick_captcha controller controller to generate images
10
+ * The gem allows ...
11
+
12
+
13
+ Quick Start
14
+ =======
15
+ In your Gemfile:
16
+
17
+ gem "rmagick_captcha", ">= 0.6.2"
18
+
19
+
20
+ In your model:
21
+
22
+ # Server create captcha_key, user input into captcha_text
23
+ has_rmagick_captcha :captcha
24
+ validate :validate_rmagick_captcha
25
+
26
+
27
+ In your controller:
28
+
29
+ download_rmagick_catcha :show
30
+
31
+ def new
32
+ @user = User.new
33
+ session[:user_captcha] = @user.reset_captcha_key
34
+ end
35
+
36
+ def create
37
+ @user = User.new(params[:user])
38
+ @user.captcha_key = session[:user_captcha]
39
+ @user.save
40
+ if @user.errors.empty?
41
+ session[:user_captcha] = nil
42
+ redirect_back_or_default('/welcome')
43
+ flash[:notice] = "Thanks for signing up!"
44
+ else
45
+ session[:user_captcha] = @user.reset_captcha_key
46
+ render :action => 'new'
47
+ end
48
+ end
49
+
50
+ In your views:
51
+
52
+ <% form_for @user, :url => users_path,
53
+ :html => {:id => "user_form", :class => "html-form" } do |f| %>
54
+ <fieldset>
55
+ <ul>
56
+ <li>
57
+ <%= rmagick_captcha_tag(:controller => "user", :id => "user_captcha") %>
58
+ <%= f.text_field :captcha_text, :maxlength => 16%>
59
+ <%= f.error_message_on :captcha_text %>
60
+ </li>
61
+ </ul>
62
+ <%= f.submit "Submit"%>
63
+ </fieldset>
64
+ <% end %>
65
+
66
+ In your routes.rb:
67
+
68
+ match 'user(/show)' => 'user#show', :as => :captcha
69
+
70
+
71
+ If you wish:
72
+
73
+ -Run ruby script/rails generate rmagick_captcha to gen resources such as locale files.
74
+ -Use config/initiaizers to configure options for this gem
75
+
76
+
77
+
78
+ Installation
79
+ =======
80
+
81
+ * Type 'gem install --local rmagick_captcha' with root account if you have installed RubyGems.
82
+
83
+
84
+ Example
85
+ =======
86
+
87
+ Example goes here.
88
+
89
+ Copyright (c) 2011 arufanov, released under the MIT license.
data/Rakefile CHANGED
@@ -1,23 +1,23 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- desc 'Default: run unit tests.'
6
- task :default => :test
7
-
8
- desc 'Test the rmagick_captcha plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
14
- end
15
-
16
- desc 'Generate documentation for the rmagick_capthca plugin.'
17
- Rake::RDocTask.new(:rdoc) do |rdoc|
18
- rdoc.rdoc_dir = 'rdoc'
19
- rdoc.title = 'RMagickCaptcha'
20
- rdoc.options << '--line-numbers' << '--inline-source'
21
- rdoc.rdoc_files.include('README')
22
- rdoc.rdoc_files.include('lib/**/*.rb')
23
- end
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the rmagick_captcha plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the rmagick_capthca plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'RMagickCaptcha'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/changelog CHANGED
@@ -1,22 +1,22 @@
1
- Introduction:
2
- To see the latest list of the change log please visit the Change Log page at www.majoron.com.
3
-
4
- Legend:
5
- Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
- then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
- Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
- And then follow a short description of the bug.
9
-
10
- Example:
11
- For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
- that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
- 380 number at bug tracking system. And bug requires STLPort support implementation.
14
-
15
- Version 0.6
16
- -----------
17
- 0.6 { Bug Report } [ RMagickCaptcha ] / X / Add font family as configuration option
18
- 0.6 { Bug Report } [ RMagickCaptcha ] / X / Send empty image if captcha key is not inside session
19
-
20
- Version 0.5
21
- -----------
22
- 0.5 { Bug Report } [ RMagickCaptcha ] / X / Changelog, roadmap, knownbugs have been created
1
+ Introduction:
2
+ To see the latest list of the change log please visit the Change Log page at www.majoron.com.
3
+
4
+ Legend:
5
+ Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
+ then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
+ Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
+ And then follow a short description of the bug.
9
+
10
+ Example:
11
+ For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
+ that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
+ 380 number at bug tracking system. And bug requires STLPort support implementation.
14
+
15
+ Version 0.6
16
+ -----------
17
+ 0.6 { Bug Report } [ RMagickCaptcha ] / X / Add font family as configuration option
18
+ 0.6 { Bug Report } [ RMagickCaptcha ] / X / Send empty image if captcha key is not inside session
19
+
20
+ Version 0.5
21
+ -----------
22
+ 0.5 { Bug Report } [ RMagickCaptcha ] / X / Changelog, roadmap, knownbugs have been created
data/init.rb CHANGED
@@ -1,2 +1,2 @@
1
- # Include hook code here
2
- require 'rmagick_captcha'
1
+ # Include hook code here
2
+ require 'rmagick_captcha'
data/install.rb CHANGED
@@ -1 +1 @@
1
- # Install hook code here
1
+ # Install hook code here
data/knownbugs CHANGED
@@ -1,21 +1,21 @@
1
- Introduction:
2
- To see the latest list of the known bugs please visit the Known bugs page at www.majoron.com.
3
-
4
- Legend:
5
- Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
- then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
- Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
- And then follow a short description of the bug.
9
-
10
- Example:
11
- For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
- that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
- 380 number at bug tracking system. And bug requires STLPort support implementation.
14
-
15
- Version 0.6
16
- -----------
17
- 0.5 { Bug Report } [ RMagickCaptcha ] / X / There isn't known bugs
18
-
19
- Version 0.5
20
- -----------
21
- 0.5 { Bug Report } [ RMagickCaptcha ] / X / There isn't known bugs
1
+ Introduction:
2
+ To see the latest list of the known bugs please visit the Known bugs page at www.majoron.com.
3
+
4
+ Legend:
5
+ Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
+ then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
+ Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
+ And then follow a short description of the bug.
9
+
10
+ Example:
11
+ For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
+ that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
+ 380 number at bug tracking system. And bug requires STLPort support implementation.
14
+
15
+ Version 0.6
16
+ -----------
17
+ 0.5 { Bug Report } [ RMagickCaptcha ] / X / There isn't known bugs
18
+
19
+ Version 0.5
20
+ -----------
21
+ 0.5 { Bug Report } [ RMagickCaptcha ] / X / There isn't known bugs
@@ -1,2 +1,2 @@
1
- Description:
2
- The rmagick_captcha generator copy locale files to config/localses.
1
+ Description:
2
+ The rmagick_captcha generator copy locale files to config/localses.
@@ -1,13 +1,13 @@
1
- module RmagickCaptcha
2
- module Generators
3
- class RmagickCaptchaGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- def generate_rmagick_captcha
7
- copy_file "rmagick_captcha_controller.rb", "app/controllers/rmagick_captcha_controller.rb"
8
- copy_file "en_rmagick_captcha.yml", "config/locales/en_rmagick_captcha.yml"
9
- copy_file "ru_rmagick_captcha.yml", "config/locales/ru_rmagick_captcha.yml"
10
- end
11
- end
12
- end
13
- end
1
+ module RmagickCaptcha
2
+ module Generators
3
+ class RmagickCaptchaGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def generate_rmagick_captcha
7
+ copy_file "rmagick_captcha_controller.rb", "app/controllers/rmagick_captcha_controller.rb"
8
+ copy_file "en_rmagick_captcha.yml", "config/locales/en_rmagick_captcha.yml"
9
+ copy_file "ru_rmagick_captcha.yml", "config/locales/ru_rmagick_captcha.yml"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,19 +1,19 @@
1
- en:
2
- activeview:
3
- columns:
4
- address_type:
5
- name: "Name"
6
- code: "Code"
7
- about: "About"
8
- enabled: "Enabled"
9
- created_at: "Created"
10
- flashes:
11
- address_type:
12
- notices:
13
- created: "An address type was successfully created."
14
- updated: "Address type was successfully updated."
15
- deleted: "Address type was successfully deleted."
16
- messages:
17
- address_type:
18
- new: "Create new address type"
19
- edit: "Editing address type"
1
+ en:
2
+ activeview:
3
+ columns:
4
+ address_type:
5
+ name: "Name"
6
+ code: "Code"
7
+ about: "About"
8
+ enabled: "Enabled"
9
+ created_at: "Created"
10
+ flashes:
11
+ address_type:
12
+ notices:
13
+ created: "An address type was successfully created."
14
+ updated: "Address type was successfully updated."
15
+ deleted: "Address type was successfully deleted."
16
+ messages:
17
+ address_type:
18
+ new: "Create new address type"
19
+ edit: "Editing address type"
@@ -1,4 +1,4 @@
1
- class RmagickCaptchaController
2
- # ::Rails.logger.error("...")
3
- download_rmagick_catcha :show
4
- end
1
+ class RmagickCaptchaController
2
+ # ::Rails.logger.error("...")
3
+ download_rmagick_catcha :show
4
+ end
@@ -1,19 +1,19 @@
1
- en:
2
- activeview:
3
- columns:
4
- address_type:
5
- name: "Name"
6
- code: "Code"
7
- about: "About"
8
- enabled: "Enabled"
9
- created_at: "Created"
10
- flashes:
11
- address_type:
12
- notices:
13
- created: "An address type was successfully created."
14
- updated: "Address type was successfully updated."
15
- deleted: "Address type was successfully deleted."
16
- messages:
17
- address_type:
18
- new: "Create new address type"
19
- edit: "Editing address type"
1
+ en:
2
+ activeview:
3
+ columns:
4
+ address_type:
5
+ name: "Name"
6
+ code: "Code"
7
+ about: "About"
8
+ enabled: "Enabled"
9
+ created_at: "Created"
10
+ flashes:
11
+ address_type:
12
+ notices:
13
+ created: "An address type was successfully created."
14
+ updated: "Address type was successfully updated."
15
+ deleted: "Address type was successfully deleted."
16
+ messages:
17
+ address_type:
18
+ new: "Create new address type"
19
+ edit: "Editing address type"
@@ -1,20 +1,20 @@
1
- #
2
- module RmagickCaptcha
3
- module ControllerAdditions
4
- # ::Rails.logger.error("...")
5
-
6
- module ClassMethods
7
- def download_rmagick_catcha(*symbols)
8
- symbols.each do |sym|
9
- define_method("#{sym}") do
10
- key = session[params[:id]]
11
- # Get current captcha key and send back
12
- image = key.nil? ? "" : ::RmagickCaptcha::RmagickBackend.get_captcha_image(key)
13
- send_data(image, :filename => "captcha.png", :type => "image/png", :disposition => 'inline')
14
- end
15
- end
16
- end
17
- end
18
-
19
- end
1
+ #
2
+ module RmagickCaptcha
3
+ module ControllerAdditions
4
+ # ::Rails.logger.error("...")
5
+
6
+ module ClassMethods
7
+ def download_rmagick_catcha(*symbols)
8
+ symbols.each do |sym|
9
+ define_method("#{sym}") do
10
+ key = session[params[:id]]
11
+ # Get current captcha key and send back
12
+ image = key.nil? ? "" : ::RmagickCaptcha::RmagickBackend.get_captcha_image(key)
13
+ send_data(image, :filename => "captcha.png", :type => "image/png", :disposition => 'inline')
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ end
20
20
  end
@@ -1,52 +1,52 @@
1
- #
2
- module RmagickCaptcha
3
- module ModelAdditions
4
- # ::Rails.logger.error("...")
5
-
6
- module ClassMethods
7
- def has_rmagick_captcha(*symbols)
8
- symbols.each do |sym|
9
- define_method("#{sym}_key") do
10
- @attributes["#{sym}_key"]
11
- end
12
- define_method("#{sym}_key=") do |val|
13
- @attributes["#{sym}_key"]=val
14
- end
15
- define_method("#{sym}_text") do
16
- @attributes["#{sym}_text"]
17
- end
18
- define_method("#{sym}_text=") do |val|
19
- @attributes["#{sym}_text"]=val
20
- end
21
-
22
- #
23
- define_method("validate_rmagick_#{sym}") do
24
- text = @attributes["#{sym}_text"]
25
- key = @attributes["#{sym}_key"]
26
- if ::Rails.env != 'test' && text != key
27
- self.errors.add(:"#{sym}_text")
28
- false
29
- end
30
- end
31
-
32
- #
33
- # First parameter should be options hash
34
- define_method("reset_#{sym}_key") do |*argv|
35
- result = ""
36
- parameter1 = argv.first || Hash.new
37
- options = ::RmagickCaptcha.options.merge(parameter1)
38
- options[:captcha_key_len].times do
39
- size = ::RmagickCaptcha.options[:random_chars].size;
40
- result << ::RmagickCaptcha.options[:random_chars][rand(size)]
41
- end
42
- @attributes["#{sym}_key"] = result
43
- @attributes["#{sym}_text"] = nil
44
- result
45
- end
46
- end
47
- end
48
- end
49
-
50
-
51
- end
1
+ #
2
+ module RmagickCaptcha
3
+ module ModelAdditions
4
+ # ::Rails.logger.error("...")
5
+
6
+ module ClassMethods
7
+ def has_rmagick_captcha(*symbols)
8
+ symbols.each do |sym|
9
+ define_method("#{sym}_key") do
10
+ @attributes["#{sym}_key"]
11
+ end
12
+ define_method("#{sym}_key=") do |val|
13
+ @attributes["#{sym}_key"]=val
14
+ end
15
+ define_method("#{sym}_text") do
16
+ @attributes["#{sym}_text"]
17
+ end
18
+ define_method("#{sym}_text=") do |val|
19
+ @attributes["#{sym}_text"]=val
20
+ end
21
+
22
+ #
23
+ define_method("validate_rmagick_#{sym}") do
24
+ text = @attributes["#{sym}_text"]
25
+ key = @attributes["#{sym}_key"]
26
+ if ::Rails.env != 'test' && text != key
27
+ self.errors.add(:"#{sym}_text")
28
+ false
29
+ end
30
+ end
31
+
32
+ #
33
+ # First parameter should be options hash
34
+ define_method("reset_#{sym}_key") do |*argv|
35
+ result = ""
36
+ parameter1 = argv.first || Hash.new
37
+ options = ::RmagickCaptcha.options.merge(parameter1)
38
+ options[:captcha_key_len].times do
39
+ size = ::RmagickCaptcha.options[:random_chars].size;
40
+ result << ::RmagickCaptcha.options[:random_chars][rand(size)]
41
+ end
42
+ @attributes["#{sym}_key"] = result
43
+ @attributes["#{sym}_text"] = nil
44
+ result
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+
51
+ end
52
52
  end
@@ -1,69 +1,70 @@
1
- require 'RMagick'
2
-
3
- module RmagickCaptcha
4
- module RmagickBackend
5
- # ::Rails.logger.error("...")
6
-
7
-
8
- def self.get_captcha_image (key, options = {})
9
- options = ::RmagickCaptcha.options.merge(options)
10
- canvas = ::Magick::Image.new(options[:gc_width], options[:gc_height],
11
- Magick::HatchFill.new('white','lightcyan2'))
12
-
13
-
14
- gc = ::Magick::Draw.new
15
- draw_text(key, gc, options)
16
-
17
- gc.push
18
- gc.fill('blue')
19
- gc.fill_opacity(0.3)
20
- gc.bezier(0,options[:gc_height],rand(40),rand(30),rand(options[:gc_width]),
21
- 1,options[:gc_width],options[:gc_height])
22
- gc.pop
23
-
24
- gc.push
25
- gc.fill('green')
26
- gc.fill_opacity(0.4)
27
- gc.bezier(0,0,rand(10),rand(40)+20,rand(40)+20,rand(40)+20,options[:gc_width],0)
28
- gc.pop
29
-
30
- gc.draw(canvas)
31
-
32
- canvas.format= options[:img_format]
33
- return canvas.to_blob()
34
- end
35
-
36
- private
37
-
38
- def self.draw_text(text, gc, options)
39
- gc.push
40
- gc.stroke_width=2
41
- gc.stroke(random_color(options))
42
- gc.font_family= options[:font_family]
43
- gc.font_stretch = Magick::UltraExpandedStretch
44
- gc.font_style = Magick::NormalStyle
45
- gc.font_weight = Magick::NormalWeight
46
- gc.gravity = Magick::WestGravity
47
- idx = 25
48
- text.each_char do | sym |
49
- gc.skewx( random_mod( rand(7) + 1 ) )
50
- gc.skewy( random_mod( rand(5) + 1 ) )
51
- gc.pointsize=rand(10)+30
52
- gc.fill(random_color(options))
53
- gc.text(idx,0,sym)
54
- idx+=25
55
- end
56
- gc.pop
57
- end
58
-
59
- def self.random_color(options = {})
60
- options[:random_colors][rand(options[:random_colors].size)]
61
- end
62
-
63
- def self.random_mod(val)
64
- return (rand(50) > 25 ? 1:-1)*val
65
- end
66
-
67
-
68
- end
69
- end
1
+ require 'rmagick'
2
+ require 'RMagick' unless defined?(Magick)
3
+
4
+ module RmagickCaptcha
5
+ module RmagickBackend
6
+ # ::Rails.logger.error("...")
7
+
8
+
9
+ def self.get_captcha_image (key, options = {})
10
+ options = ::RmagickCaptcha.options.merge(options)
11
+ canvas = ::Magick::Image.new(options[:gc_width], options[:gc_height],
12
+ Magick::HatchFill.new('white','lightcyan2'))
13
+
14
+
15
+ gc = ::Magick::Draw.new
16
+ draw_text(key, gc, options)
17
+
18
+ gc.push
19
+ gc.fill('blue')
20
+ gc.fill_opacity(0.3)
21
+ gc.bezier(0,options[:gc_height],rand(40),rand(30),rand(options[:gc_width]),
22
+ 1,options[:gc_width],options[:gc_height])
23
+ gc.pop
24
+
25
+ gc.push
26
+ gc.fill('green')
27
+ gc.fill_opacity(0.4)
28
+ gc.bezier(0,0,rand(10),rand(40)+20,rand(40)+20,rand(40)+20,options[:gc_width],0)
29
+ gc.pop
30
+
31
+ gc.draw(canvas)
32
+
33
+ canvas.format= options[:img_format]
34
+ return canvas.to_blob()
35
+ end
36
+
37
+ private
38
+
39
+ def self.draw_text(text, gc, options)
40
+ gc.push
41
+ gc.stroke_width=2
42
+ gc.stroke(random_color(options))
43
+ gc.font_family= options[:font_family]
44
+ gc.font_stretch = Magick::UltraExpandedStretch
45
+ gc.font_style = Magick::NormalStyle
46
+ gc.font_weight = Magick::NormalWeight
47
+ gc.gravity = Magick::WestGravity
48
+ idx = 25
49
+ text.each_char do | sym |
50
+ gc.skewx( random_mod( rand(7) + 1 ) )
51
+ gc.skewy( random_mod( rand(5) + 1 ) )
52
+ gc.pointsize=rand(10)+30
53
+ gc.fill(random_color(options))
54
+ gc.text(idx,0,sym)
55
+ idx+=25
56
+ end
57
+ gc.pop
58
+ end
59
+
60
+ def self.random_color(options = {})
61
+ options[:random_colors][rand(options[:random_colors].size)]
62
+ end
63
+
64
+ def self.random_mod(val)
65
+ return (rand(50) > 25 ? 1:-1)*val
66
+ end
67
+
68
+
69
+ end
70
+ end
@@ -1,14 +1,14 @@
1
- #
2
- module RmagickCaptcha
3
- module ViewAdditions
4
- # ::Rails.logger.error("...")
5
-
6
- #
7
- #
8
- def rmagick_captcha_tag(options = {})
9
- options = ::RmagickCaptcha.options.merge(options)
10
- image_tag("/#{options[:controller]}/#{options[:action]}?id=#{options[:id]}")
11
- end
12
-
13
- end
1
+ #
2
+ module RmagickCaptcha
3
+ module ViewAdditions
4
+ # ::Rails.logger.error("...")
5
+
6
+ #
7
+ #
8
+ def rmagick_captcha_tag(options = {})
9
+ options = ::RmagickCaptcha.options.merge(options)
10
+ image_tag("/#{options[:controller]}/#{options[:action]}?id=#{options[:id]}")
11
+ end
12
+
13
+ end
14
14
  end
@@ -1,47 +1,47 @@
1
- # Include
2
- require 'rubygems'
3
- require 'active_support'
4
- require 'rmagick_captcha/model_additions'
5
- require 'rmagick_captcha/controller_additions'
6
- require 'rmagick_captcha/view_additions'
7
- # require backends
8
- require 'rmagick_captcha/rmagick_backend'
9
-
10
- # = Rails breadcrumbs
11
- #
12
- module RmagickCaptcha
13
- # ::Rails.logger.error("...")
14
-
15
- # default options that can be overridden on the global level
16
- @@options = {
17
- :controller => "rmagick_captcha", #
18
- :action => "show", #
19
- :id => "id", #
20
- :captcha_key_len => 4, #
21
- :case_sensitive => true, #
22
- :random_chars => "ABCDEFGHJKLMNPQRSTUVWXYZ" + "0123456789", #
23
- :random_colors => ["red", "blue", "green", "gray", "pink"], #
24
- :img_format => "png", #
25
- :gc_width => 200, #
26
- :gc_height => 100, #
27
- :font_family => "times", #
28
- }
29
- mattr_reader :options
30
-
31
- def self.enable_activerecord
32
- ActiveRecord::Base.send :include, RmagickCaptcha::ModelAdditions
33
- ActiveRecord::Base.send :extend, RmagickCaptcha::ModelAdditions::ClassMethods
34
- end
35
-
36
- def self.enable_actionpack
37
- ActionController::Base.send :include, RmagickCaptcha::ControllerAdditions
38
- ActionController::Base.send :extend, RmagickCaptcha::ControllerAdditions::ClassMethods
39
- ActionView::Base.send :include, RmagickCaptcha::ViewAdditions
40
- end
41
-
42
- end
43
-
44
- if defined? Rails
45
- RmagickCaptcha.enable_activerecord if defined? ActiveRecord
46
- RmagickCaptcha.enable_actionpack if defined? ActionController
47
- end
1
+ # Include
2
+ require 'rubygems'
3
+ require 'active_support'
4
+ require 'rmagick_captcha/model_additions'
5
+ require 'rmagick_captcha/controller_additions'
6
+ require 'rmagick_captcha/view_additions'
7
+ # require backends
8
+ require 'rmagick_captcha/rmagick_backend'
9
+
10
+ # = Rails breadcrumbs
11
+ #
12
+ module RmagickCaptcha
13
+ # ::Rails.logger.error("...")
14
+
15
+ # default options that can be overridden on the global level
16
+ @@options = {
17
+ :controller => "rmagick_captcha", #
18
+ :action => "show", #
19
+ :id => "id", #
20
+ :captcha_key_len => 4, #
21
+ :case_sensitive => true, #
22
+ :random_chars => "ABCDEFGHJKLMNPQRSTUVWXYZ" + "0123456789", #
23
+ :random_colors => ["red", "blue", "green", "gray", "pink"], #
24
+ :img_format => "png", #
25
+ :gc_width => 200, #
26
+ :gc_height => 100, #
27
+ :font_family => "times", #
28
+ }
29
+ mattr_reader :options
30
+
31
+ def self.enable_activerecord
32
+ ActiveRecord::Base.send :include, RmagickCaptcha::ModelAdditions
33
+ ActiveRecord::Base.send :extend, RmagickCaptcha::ModelAdditions::ClassMethods
34
+ end
35
+
36
+ def self.enable_actionpack
37
+ ActionController::Base.send :include, RmagickCaptcha::ControllerAdditions
38
+ ActionController::Base.send :extend, RmagickCaptcha::ControllerAdditions::ClassMethods
39
+ ActionView::Base.send :include, RmagickCaptcha::ViewAdditions
40
+ end
41
+
42
+ end
43
+
44
+ if defined? Rails
45
+ RmagickCaptcha.enable_activerecord if defined? ActiveRecord
46
+ RmagickCaptcha.enable_actionpack if defined? ActionController
47
+ end
@@ -1,17 +1,17 @@
1
- require 'date'
2
- Gem::Specification.new do |s|
3
- s.name = %q{rmagick_captcha}
4
- s.version = "0.6.2"
5
- s.date = Date.today.to_s
6
- s.summary = %q{RMagickCaptcha is a gem that implements captcha for using in Rails application.}
7
- s.description = %q{RMagickCaptcha is a gem that implements captcha for using in Rails application.}
8
- s.author = %q{Artem Rufanov}
9
- s.email = %q{developers@majoron.com}
10
- s.homepage = %q{http://www.majoron.com/project/rbundle/rmagick_captcha}
11
- s.files = Dir.glob('**/*') - Dir.glob('distrib/**/*') - Dir.glob('lib/api/**/*') - Dir.glob('doc/*.xpr')
12
- s.bindir = 'bin'
13
- s.executables = Dir.glob('bin/*').collect {|f| File.basename(f)}
14
- s.require_paths << 'doc' << 'examples' << 'lib' << 'test'
15
- s.has_rdoc = true
16
- s.required_ruby_version = '>= 1.8.7'
17
- end
1
+ require 'date'
2
+ Gem::Specification.new do |s|
3
+ s.name = %q{rmagick_captcha}
4
+ s.version = "0.6.3"
5
+ s.date = Date.today.to_s
6
+ s.summary = %q{RMagickCaptcha is a gem that implements captcha for using in Rails application.}
7
+ s.description = %q{RMagickCaptcha is a gem that implements captcha for using in Rails application.}
8
+ s.author = %q{Artem Rufanov}
9
+ s.email = %q{developers@majoron.com}
10
+ s.homepage = %q{http://www.majoron.com/project/rbundle/rmagick_captcha}
11
+ s.files = Dir.glob('**/*') - Dir.glob('distrib/**/*') - Dir.glob('lib/api/**/*') - Dir.glob('doc/*.xpr')
12
+ s.bindir = 'bin'
13
+ s.executables = Dir.glob('bin/*').collect {|f| File.basename(f)}
14
+ s.require_paths << 'doc' << 'examples' << 'lib' << 'test'
15
+ s.has_rdoc = true
16
+ s.required_ruby_version = '>= 1.8.7'
17
+ end
data/roadmap CHANGED
@@ -1,20 +1,20 @@
1
- Introduction:
2
- To see the latest list of the roadmap please visit the Roadmap page at www.majoron.com.
3
-
4
- Legend:
5
- Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
- then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
- Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
- And then follow a short description of the bug.
9
-
10
- Example:
11
- For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
- that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
- 380 number at bug tracking system. And bug requires STLPort support implementation.
14
-
15
- Version 0.5
16
- -----------
17
- 0.5 { Feature Request } [ RMagickCaptcha ] / X / Add tests
18
- 0.5 { Feature Request } [ RMagickCaptcha ] / X / Add Add backend with a predefined images (and sound?)
19
- 0.5 { Feature Request } [ RMagickCaptcha ] / X / Add visual effects (3d, grey and etc)
20
-
1
+ Introduction:
2
+ To see the latest list of the roadmap please visit the Roadmap page at www.majoron.com.
3
+
4
+ Legend:
5
+ Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
+ then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
+ Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
+ And then follow a short description of the bug.
9
+
10
+ Example:
11
+ For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
+ that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
+ 380 number at bug tracking system. And bug requires STLPort support implementation.
14
+
15
+ Version 0.5
16
+ -----------
17
+ 0.5 { Feature Request } [ RMagickCaptcha ] / X / Add tests
18
+ 0.5 { Feature Request } [ RMagickCaptcha ] / X / Add Add backend with a predefined images (and sound?)
19
+ 0.5 { Feature Request } [ RMagickCaptcha ] / X / Add visual effects (3d, grey and etc)
20
+
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe RmagickCaptcha::ControllerAdditions do
4
- it "should define controller additions" do
5
- ::RmagickCaptcha::ControllerAdditions.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe RmagickCaptcha::ControllerAdditions do
4
+ it "should define controller additions" do
5
+ ::RmagickCaptcha::ControllerAdditions.should be
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe RmagickCaptcha::ModelAdditions do
4
- it "should define model additions" do
5
- ::RmagickCaptcha::ModelAdditions.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe RmagickCaptcha::ModelAdditions do
4
+ it "should define model additions" do
5
+ ::RmagickCaptcha::ModelAdditions.should be
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe RmagickCaptcha::ModelAdditions do
4
- it "should define model additions" do
5
- ::RmagickCaptcha::ModelAdditions.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe RmagickCaptcha::ModelAdditions do
4
+ it "should define model additions" do
5
+ ::RmagickCaptcha::ModelAdditions.should be
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe RmagickCaptcha::ViewAdditions do
4
- it "should define view additions" do
5
- ::RmagickCaptcha::ViewAdditions.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe RmagickCaptcha::ViewAdditions do
4
+ it "should define view additions" do
5
+ ::RmagickCaptcha::ViewAdditions.should be
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe RmagickCaptcha do
4
- it "should define rails" do
5
- ::Rails::VERSION::MAJOR.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe RmagickCaptcha do
4
+ it "should define rails" do
5
+ ::Rails::VERSION::MAJOR.should be
6
+ end
7
+ end
data/spec/spec.opts CHANGED
@@ -1,2 +1,2 @@
1
- --color
2
- --backtrace
1
+ --color
2
+ --backtrace
data/spec/spec_helper.rb CHANGED
@@ -1,24 +1,24 @@
1
- $:.unshift File.dirname(__FILE__)
2
- $:.unshift File.join(File.dirname(__FILE__), '../lib')
3
- $:.unshift File.join(File.dirname(__FILE__), '../app/controllers')
4
-
5
- ENV["RAILS_ENV"] = "test"
6
- require 'rubygems'
7
- require 'rspec'
8
- require 'action_controller'
9
- require 'rmagick_captcha'
10
-
11
- module Rails
12
- module VERSION
13
- MAJOR = 3
14
- end
15
- end unless defined? Rails
16
-
17
- # RailsBreadcrumbs.root = './'
18
- RAILS_ROOT = './' unless defined?(RAILS_ROOT)
19
- RAILS_ENV = 'test' unless defined?(RAILS_ENV)
20
-
21
- RSpec.configure do |config|
22
- config.mock_with :rspec
23
- end
24
-
1
+ $:.unshift File.dirname(__FILE__)
2
+ $:.unshift File.join(File.dirname(__FILE__), '../lib')
3
+ $:.unshift File.join(File.dirname(__FILE__), '../app/controllers')
4
+
5
+ ENV["RAILS_ENV"] = "test"
6
+ require 'rubygems'
7
+ require 'rspec'
8
+ require 'action_controller'
9
+ require 'rmagick_captcha'
10
+
11
+ module Rails
12
+ module VERSION
13
+ MAJOR = 3
14
+ end
15
+ end unless defined? Rails
16
+
17
+ # RailsBreadcrumbs.root = './'
18
+ RAILS_ROOT = './' unless defined?(RAILS_ROOT)
19
+ RAILS_ENV = 'test' unless defined?(RAILS_ENV)
20
+
21
+ RSpec.configure do |config|
22
+ config.mock_with :rspec
23
+ end
24
+
@@ -1,4 +1,4 @@
1
- # desc "Explaining what the task does"
2
- # task :captcha_validateable do
3
- # # Task goes here
4
- # end
1
+ # desc "Explaining what the task does"
2
+ # task :captcha_validateable do
3
+ # # Task goes here
4
+ # end
data/uninstall.rb CHANGED
@@ -1 +1 @@
1
- # Uninstall hook code here
1
+ # Uninstall hook code here
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmagick_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
5
- prerelease:
4
+ version: 0.6.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Artem Rufanov
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-10-16 00:00:00.000000000Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: RMagickCaptcha is a gem that implements captcha for using in Rails application.
15
14
  email: developers@majoron.com
@@ -17,23 +16,23 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
19
+ - MIT-LICENSE
20
+ - README
21
+ - Rakefile
20
22
  - changelog
21
23
  - init.rb
22
24
  - install.rb
23
25
  - knownbugs
26
+ - lib/generators/rmagick_captcha/USAGE
24
27
  - lib/generators/rmagick_captcha/rmagick_captcha_generator.rb
25
28
  - lib/generators/rmagick_captcha/templates/en_rmagick_captcha.yml
26
29
  - lib/generators/rmagick_captcha/templates/rmagick_captcha_controller.rb
27
30
  - lib/generators/rmagick_captcha/templates/ru_rmagick_captcha.yml
28
- - lib/generators/rmagick_captcha/USAGE
31
+ - lib/rmagick_captcha.rb
29
32
  - lib/rmagick_captcha/controller_additions.rb
30
33
  - lib/rmagick_captcha/model_additions.rb
31
34
  - lib/rmagick_captcha/rmagick_backend.rb
32
35
  - lib/rmagick_captcha/view_additions.rb
33
- - lib/rmagick_captcha.rb
34
- - MIT-LICENSE
35
- - Rakefile
36
- - README
37
36
  - rmagick_captcha.gemspec
38
37
  - roadmap
39
38
  - spec/lib/rmagick_captcha/controller_additions_spec.rb
@@ -47,6 +46,7 @@ files:
47
46
  - uninstall.rb
48
47
  homepage: http://www.majoron.com/project/rbundle/rmagick_captcha
49
48
  licenses: []
49
+ metadata: {}
50
50
  post_install_message:
51
51
  rdoc_options: []
52
52
  require_paths:
@@ -56,21 +56,19 @@ require_paths:
56
56
  - lib
57
57
  - test
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
- none: false
60
59
  requirements:
61
- - - ! '>='
60
+ - - ">="
62
61
  - !ruby/object:Gem::Version
63
62
  version: 1.8.7
64
63
  required_rubygems_version: !ruby/object:Gem::Requirement
65
- none: false
66
64
  requirements:
67
- - - ! '>='
65
+ - - ">="
68
66
  - !ruby/object:Gem::Version
69
67
  version: '0'
70
68
  requirements: []
71
69
  rubyforge_project:
72
- rubygems_version: 1.8.10
70
+ rubygems_version: 2.2.2
73
71
  signing_key:
74
- specification_version: 3
72
+ specification_version: 4
75
73
  summary: RMagickCaptcha is a gem that implements captcha for using in Rails application.
76
74
  test_files: []