asciiptcha 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +20 -0
- data/README.md +71 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/asciiptcha.gemspec +79 -0
- data/lib/asciiptcha.rb +25 -0
- data/lib/asciiptcha/configuration.rb +21 -0
- data/lib/asciiptcha/controller_helpers.rb +26 -0
- data/lib/asciiptcha/encryption_key_not_set.rb +2 -0
- data/lib/asciiptcha/operations.rb +25 -0
- data/lib/asciiptcha/railtie.rb +20 -0
- data/lib/asciiptcha/view_helpers.rb +30 -0
- data/lib/initializers/asciiptcha.rb +13 -0
- data/lib/tasks/INIT.readme +9 -0
- data/lib/tasks/tasks.rake +20 -0
- data/locales/cs.yml +2 -0
- data/test/helper.rb +18 -0
- data/test/test_asciiptcha.rb +7 -0
- metadata +192 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "activesupport", ">= 3.0.0"
|
4
|
+
gem 'artii'
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.8.3"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.6)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
artii (2.0.1)
|
8
|
+
git (1.2.5)
|
9
|
+
i18n (0.6.0)
|
10
|
+
jeweler (1.8.3)
|
11
|
+
bundler (~> 1.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rake
|
14
|
+
rdoc
|
15
|
+
json (1.7.3)
|
16
|
+
multi_json (1.3.6)
|
17
|
+
rake (0.9.2.2)
|
18
|
+
rcov (1.0.0)
|
19
|
+
rdoc (3.12)
|
20
|
+
json (~> 1.4)
|
21
|
+
shoulda (3.0.1)
|
22
|
+
shoulda-context (~> 1.0.0)
|
23
|
+
shoulda-matchers (~> 1.0.0)
|
24
|
+
shoulda-context (1.0.0)
|
25
|
+
shoulda-matchers (1.0.0)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
activesupport (>= 3.0.0)
|
32
|
+
artii
|
33
|
+
bundler (~> 1.0.0)
|
34
|
+
jeweler (~> 1.8.3)
|
35
|
+
rcov
|
36
|
+
rdoc (~> 3.12)
|
37
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Pavel Sorejs
|
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.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
asciiptcha
|
2
|
+
==========
|
3
|
+
|
4
|
+
Small gem to generate and verify captcha based on ASCII Art in Rails3
|
5
|
+
|
6
|
+
Requirements
|
7
|
+
------------
|
8
|
+
|
9
|
+
### Ruby and Rails
|
10
|
+
|
11
|
+
Asciiptcha requires Ruby version **>= 1.8.7** and Rails version **>= 3.0**
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
Asciiptcha is distributed as a gem, which is how it should be used in your app.
|
17
|
+
|
18
|
+
Include the gem in your Gemfile:
|
19
|
+
|
20
|
+
gem "asciiptcha"
|
21
|
+
|
22
|
+
After installation run rake task to generate initializer (including random encryption key)
|
23
|
+
|
24
|
+
rake asciiptcha:init
|
25
|
+
|
26
|
+
Quick Start
|
27
|
+
-----------
|
28
|
+
|
29
|
+
In your view, inside the form add following code:
|
30
|
+
|
31
|
+
<%= asciiptcha_generate %>
|
32
|
+
|
33
|
+
In the controller you can then write something like this:
|
34
|
+
|
35
|
+
if asciiptcha_verify
|
36
|
+
# Do something for successfull verification
|
37
|
+
end
|
38
|
+
|
39
|
+
Usage
|
40
|
+
-----
|
41
|
+
|
42
|
+
To change default ids of capctha fields, use following:
|
43
|
+
|
44
|
+
<%= asciiptcha_generate('some_different_id' %>
|
45
|
+
|
46
|
+
and
|
47
|
+
|
48
|
+
if asciiptcha_verify('some_different_id')
|
49
|
+
# Do something for successfull verification
|
50
|
+
end
|
51
|
+
|
52
|
+
This way, you can have more than one capctha on single site.
|
53
|
+
|
54
|
+
|
55
|
+
Contributing to asciiptcha
|
56
|
+
-----
|
57
|
+
|
58
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
59
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
60
|
+
* Fork the project.
|
61
|
+
* Start a feature/bugfix branch.
|
62
|
+
* Commit and push until you are happy with your contribution.
|
63
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
64
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
65
|
+
|
66
|
+
Copyright
|
67
|
+
-----
|
68
|
+
|
69
|
+
Copyright (c) 2012 Pavel Sorejs. See LICENSE.txt for
|
70
|
+
further details.
|
71
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "asciiptcha"
|
18
|
+
gem.homepage = "http://github.com/pavels/asciiptcha"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Generates and verifies ascii art captcha."
|
21
|
+
gem.description = "Generates and verifies ascii art captcha."
|
22
|
+
gem.email = "sorejs@gmail.com"
|
23
|
+
gem.authors = ["Pavel Sorejs"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rdoc/task'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "asciiptcha #{version}"
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/asciiptcha.gemspec
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
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{asciiptcha}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Pavel Sorejs"]
|
12
|
+
s.date = %q{2012-06-13}
|
13
|
+
s.description = %q{Generates and verifies ascii art captcha.}
|
14
|
+
s.email = %q{sorejs@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"asciiptcha.gemspec",
|
28
|
+
"lib/asciiptcha.rb",
|
29
|
+
"lib/asciiptcha/configuration.rb",
|
30
|
+
"lib/asciiptcha/controller_helpers.rb",
|
31
|
+
"lib/asciiptcha/encryption_key_not_set.rb",
|
32
|
+
"lib/asciiptcha/operations.rb",
|
33
|
+
"lib/asciiptcha/railtie.rb",
|
34
|
+
"lib/asciiptcha/view_helpers.rb",
|
35
|
+
"lib/initializers/asciiptcha.rb",
|
36
|
+
"lib/tasks/INIT.readme",
|
37
|
+
"lib/tasks/tasks.rake",
|
38
|
+
"locales/cs.yml",
|
39
|
+
"test/helper.rb",
|
40
|
+
"test/test_asciiptcha.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://github.com/pavels/asciiptcha}
|
43
|
+
s.licenses = ["MIT"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = %q{1.3.7}
|
46
|
+
s.summary = %q{Generates and verifies ascii art captcha.}
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
|
54
|
+
s.add_runtime_dependency(%q<artii>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
57
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
58
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
59
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
62
|
+
s.add_dependency(%q<artii>, [">= 0"])
|
63
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
67
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
68
|
+
end
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
71
|
+
s.add_dependency(%q<artii>, [">= 0"])
|
72
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
73
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
74
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
75
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
76
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/lib/asciiptcha.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'artii'
|
2
|
+
require 'sha1'
|
3
|
+
require 'asciiptcha/operations'
|
4
|
+
require 'asciiptcha/configuration'
|
5
|
+
require 'asciiptcha/encryption_key_not_set'
|
6
|
+
require 'asciiptcha/railtie' if defined?(Rails)
|
7
|
+
|
8
|
+
module Asciiptcha
|
9
|
+
class << self
|
10
|
+
# Modify Asciiptcha configuration
|
11
|
+
# Example:
|
12
|
+
# Asciiptcha.configure do |config|
|
13
|
+
# config.captcha_length = 6
|
14
|
+
# end
|
15
|
+
def configure
|
16
|
+
yield configuration
|
17
|
+
end
|
18
|
+
|
19
|
+
# Accessor for Asciiptcha::Configuration
|
20
|
+
def configuration
|
21
|
+
@configuration ||= Configuration.new
|
22
|
+
end
|
23
|
+
alias :config :configuration
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Asciiptcha::Configuration
|
2
|
+
|
3
|
+
#Encryption key - used for encrypting captcha key in forms
|
4
|
+
# !!! MUST BE VALID RANDOM AES 256 KEY !!!
|
5
|
+
attr_accessor :encryption_key
|
6
|
+
|
7
|
+
#Captcha length - number of characters in captcha
|
8
|
+
attr_accessor :captcha_length
|
9
|
+
|
10
|
+
#Available fonts - allowed fonts for captcha
|
11
|
+
#For list see artii -l command for list of available fonts
|
12
|
+
#or http://www.figlet.org/examples.html
|
13
|
+
attr_accessor :available_fonts
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@encryption_key = nil
|
17
|
+
@captcha_length = 8
|
18
|
+
@available_fonts = [ 'basic', 'banner4','colossal' ]
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Asciiptcha
|
2
|
+
module ControllerHelpers
|
3
|
+
|
4
|
+
def asciiptcha_verify(field_id = nil)
|
5
|
+
if Asciiptcha.config.encryption_key.nil?
|
6
|
+
raise EncryptionKeyNotSet, "Encryption key is not set"
|
7
|
+
end
|
8
|
+
field_id ||= 'asciiptcha_input'
|
9
|
+
code_field_id = field_id+"_code"
|
10
|
+
if params[field_id].nil? || params[field_id].length < 1 || params[code_field_id].nil? || params[code_field_id].length < 1
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
decrypted_code = Asciiptcha::aes_decrypt(params[code_field_id],Asciiptcha.config.encryption_key)
|
16
|
+
rescue
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
if decrypted_code == params[field_id]
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Asciiptcha
|
2
|
+
|
3
|
+
protected
|
4
|
+
|
5
|
+
def self.generate_random_code(length)
|
6
|
+
s = ""
|
7
|
+
length.times { s << (i = Kernel.rand(35); i += ((i < 10) ? 48 : 87 )).chr }
|
8
|
+
return s
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.aes_decrypt(encrypted_data, key)
|
12
|
+
aes = OpenSSL::Cipher::Cipher.new('AES-256-ECB')
|
13
|
+
aes.decrypt
|
14
|
+
aes.key = Array(key).pack('H*')
|
15
|
+
aes.update(Array(encrypted_data).pack('H*')) + aes.final
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.aes_encrypt(data, key)
|
19
|
+
aes = OpenSSL::Cipher::Cipher.new('AES-256-ECB')
|
20
|
+
aes.encrypt
|
21
|
+
aes.key = Array(key).pack('H*')
|
22
|
+
(aes.update(data) + aes.final).unpack('H*')
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'asciiptcha/view_helpers'
|
2
|
+
require 'asciiptcha/controller_helpers'
|
3
|
+
|
4
|
+
module Asciiptcha
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer "asciiptcha.helpers" do
|
7
|
+
ActionView::Base.send :include, ViewHelpers
|
8
|
+
ActionController::Base.send :include, ControllerHelpers
|
9
|
+
end
|
10
|
+
|
11
|
+
initializer 'rails-i18n' do |app|
|
12
|
+
I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../../locales'), '*.yml')]
|
13
|
+
I18n.load_path.flatten!
|
14
|
+
end
|
15
|
+
|
16
|
+
rake_tasks do
|
17
|
+
Dir[File.join(File.dirname(__FILE__),'/../tasks/*.rake')].each { |f| load f }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Asciiptcha
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
def asciiptcha_generate(field_id = nil)
|
5
|
+
if Asciiptcha.config.encryption_key.nil?
|
6
|
+
raise EncryptionKeyNotSet, "Encryption key is not set"
|
7
|
+
end
|
8
|
+
|
9
|
+
font = Asciiptcha.config.available_fonts[Kernel.rand(Asciiptcha.config.available_fonts.length)]
|
10
|
+
a = Artii::Base.new :font => font
|
11
|
+
code = Asciiptcha::generate_random_code(Asciiptcha.config.captcha_length)
|
12
|
+
|
13
|
+
field_id ||= 'asciiptcha_input'
|
14
|
+
|
15
|
+
encrypted_code = Asciiptcha::aes_encrypt(code,Asciiptcha.config.encryption_key)
|
16
|
+
|
17
|
+
html_output = ""
|
18
|
+
html_output << "<div class=\"asciiptcha-block\">"
|
19
|
+
html_output << "<pre>"
|
20
|
+
html_output << a.asciify(code)
|
21
|
+
html_output << "</pre>"
|
22
|
+
html_output << (hidden_field_tag field_id+"_code", encrypted_code)
|
23
|
+
html_output << (text_field_tag field_id, nil, :placeholder => I18n.t(".asciiptcha_input_placeholder"))
|
24
|
+
html_output << "</div>"
|
25
|
+
|
26
|
+
return raw html_output
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Asciiptcha.configure do |config|
|
2
|
+
#Encryption key - used for encrypting captcha key in forms
|
3
|
+
config.encryption_key = '%encryption_key%'
|
4
|
+
|
5
|
+
#Captcha length - number of characters in captcha
|
6
|
+
# config.captcha_length = 8
|
7
|
+
|
8
|
+
#Available fonts - allowed fonts for captcha
|
9
|
+
#For list see artii -l command for list of available fonts
|
10
|
+
#or http://www.figlet.org/examples.html
|
11
|
+
# config.available_fonts = [ 'alligator2', 'banner4','colossal' ]
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
_______ _______ _______ ___ ___ _______ _______ _______ __ __ _______
|
2
|
+
| _ || || || | | | | || || || | | || _ |
|
3
|
+
| |_| || _____|| || | | | | _ ||_ _|| || |_| || |_| |
|
4
|
+
| || |_____ | || | | | | |_| | | | | || || |
|
5
|
+
| ||_____ || _|| | | | | ___| | | | _|| || |
|
6
|
+
| _ | _____| || |_ | | | | | | | | | |_ | _ || _ |
|
7
|
+
|__| |__||_______||_______||___| |___| |___| |___| |_______||__| |__||__| |__|
|
8
|
+
|
9
|
+
Initialization completed
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "ftools"
|
2
|
+
namespace :asciiptcha do
|
3
|
+
task :init => :environment do
|
4
|
+
init_dst = Rails.root.join('config/initializers/asciiptcha.rb')
|
5
|
+
init_src = File.dirname(__FILE__) + "/../initializers/asciiptcha.rb"
|
6
|
+
|
7
|
+
cipher = OpenSSL::Cipher::Cipher.new('aes-256-ecb')
|
8
|
+
cipher_password = cipher.random_key.unpack('H*').to_s
|
9
|
+
|
10
|
+
init_file = File.read(init_src)
|
11
|
+
init_file.gsub!("%encryption_key%",cipher_password)
|
12
|
+
if !File.exists?(init_dst)
|
13
|
+
File.open(init_dst, 'w') {|f| f.write(init_file) }
|
14
|
+
else
|
15
|
+
puts "Initializer file exists. Not overwriting."
|
16
|
+
end
|
17
|
+
puts File.read(File.dirname(__FILE__) + "/INIT.readme")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/locales/cs.yml
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'asciiptcha'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: asciiptcha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pavel Sorejs
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-06-13 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 7
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
version: 3.0.0
|
34
|
+
name: activesupport
|
35
|
+
requirement: *id001
|
36
|
+
type: :runtime
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
name: artii
|
49
|
+
requirement: *id002
|
50
|
+
type: :runtime
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
name: shoulda
|
63
|
+
requirement: *id003
|
64
|
+
type: :development
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 31
|
73
|
+
segments:
|
74
|
+
- 3
|
75
|
+
- 12
|
76
|
+
version: "3.12"
|
77
|
+
name: rdoc
|
78
|
+
requirement: *id004
|
79
|
+
type: :development
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 23
|
88
|
+
segments:
|
89
|
+
- 1
|
90
|
+
- 0
|
91
|
+
- 0
|
92
|
+
version: 1.0.0
|
93
|
+
name: bundler
|
94
|
+
requirement: *id005
|
95
|
+
type: :development
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 49
|
104
|
+
segments:
|
105
|
+
- 1
|
106
|
+
- 8
|
107
|
+
- 3
|
108
|
+
version: 1.8.3
|
109
|
+
name: jeweler
|
110
|
+
requirement: *id006
|
111
|
+
type: :development
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
name: rcov
|
124
|
+
requirement: *id007
|
125
|
+
type: :development
|
126
|
+
description: Generates and verifies ascii art captcha.
|
127
|
+
email: sorejs@gmail.com
|
128
|
+
executables: []
|
129
|
+
|
130
|
+
extensions: []
|
131
|
+
|
132
|
+
extra_rdoc_files:
|
133
|
+
- LICENSE.txt
|
134
|
+
- README.md
|
135
|
+
files:
|
136
|
+
- .document
|
137
|
+
- Gemfile
|
138
|
+
- Gemfile.lock
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- VERSION
|
143
|
+
- asciiptcha.gemspec
|
144
|
+
- lib/asciiptcha.rb
|
145
|
+
- lib/asciiptcha/configuration.rb
|
146
|
+
- lib/asciiptcha/controller_helpers.rb
|
147
|
+
- lib/asciiptcha/encryption_key_not_set.rb
|
148
|
+
- lib/asciiptcha/operations.rb
|
149
|
+
- lib/asciiptcha/railtie.rb
|
150
|
+
- lib/asciiptcha/view_helpers.rb
|
151
|
+
- lib/initializers/asciiptcha.rb
|
152
|
+
- lib/tasks/INIT.readme
|
153
|
+
- lib/tasks/tasks.rake
|
154
|
+
- locales/cs.yml
|
155
|
+
- test/helper.rb
|
156
|
+
- test/test_asciiptcha.rb
|
157
|
+
has_rdoc: true
|
158
|
+
homepage: http://github.com/pavels/asciiptcha
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
hash: 3
|
172
|
+
segments:
|
173
|
+
- 0
|
174
|
+
version: "0"
|
175
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
hash: 3
|
181
|
+
segments:
|
182
|
+
- 0
|
183
|
+
version: "0"
|
184
|
+
requirements: []
|
185
|
+
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 1.3.7
|
188
|
+
signing_key:
|
189
|
+
specification_version: 3
|
190
|
+
summary: Generates and verifies ascii art captcha.
|
191
|
+
test_files: []
|
192
|
+
|