Skip to content

Commit

Permalink
Update for mongoid 3 / new formtastic
Browse files Browse the repository at this point in the history
  • Loading branch information
glebtv committed Nov 15, 2012
1 parent 84dd680 commit d182c67
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ spec/dummy/vendor/bundle/
spec/dummy/app/helpers/manage
spec/dummy/config/database.yml
spec/dummy/log/development.log
.idea
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in gemspec
gemspec
6 changes: 4 additions & 2 deletions README.rdoc
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=SimpleCaptcha

This is a fork of wolcanus's fork of SimpleCaptcha to support Mongoid 3 and new formtastic.

This is a fork of galetahub SimpleCaptcha to support Mongoid.
Its implementation requires
adding up a single line in views and in controllers/models.
Expand All @@ -25,11 +27,11 @@ backward compatibility with previous versions of Rails.

==Installation

gem "wolcanus-simple_captcha", :require => "simple_captcha"
gem "glebtv-simple_captcha", :require => "simple_captcha"

or

gem 'wolcanus-simple_captcha', :require => 'simple_captcha', :git => 'git://github.com/wolcanus/simple-captcha.git'
gem 'glebtv-simple_captcha', :require => 'simple_captcha', :git => 'git://github.com/glebtv/simple-captcha.git'

==Setup

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rdoc/task'

desc 'Default: run unit tests.'
task :default => :test
Expand Down
Binary file added glebtv-simple_captcha-0.1.6.gem
Binary file not shown.
10 changes: 2 additions & 8 deletions lib/simple_captcha/engine.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ class Engine < ::Rails::Engine
ActionView::Base.send(:include, SimpleCaptcha::ViewHelper)
ActionView::Helpers::FormBuilder.send(:include, SimpleCaptcha::FormBuilder)

if Object.const_defined?("Formtastic")
if Formtastic.const_defined?("Helpers")
Formtastic::Helpers::FormHelper.builder = SimpleCaptcha::CustomFormBuilder
else
Formtastic::SemanticFormHelper.builder = SimpleCaptcha::CustomFormBuilder
end
if Object.const_defined?("Formtastic") && Formtastic.const_defined?("Inputs")
require "simple_captcha/formtastic"
end
end

config.app_middleware.use SimpleCaptcha::Middleware
end
end


17 changes: 10 additions & 7 deletions lib/simple_captcha/formtastic.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module SimpleCaptcha
class CustomFormBuilder < Formtastic::SemanticFormBuilder
require "formtastic"

private
class SimpleCaptchaInput
include ::Formtastic::Inputs::Base
include ::Formtastic::Inputs::Base::Stringish

def simple_captcha_input(method, options)
options.update :object => sanitized_object_name
self.send(:show_simple_captcha, options)
def to_html
input_wrapping do
input_html_options.update :object => method
label_html << builder.show_simple_captcha(input_html_options)
# label_html << builder.text_field(method, input_html_options)
end
end
end
end
18 changes: 9 additions & 9 deletions simple_captcha.gemspec
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ $:.push File.expand_path("../lib", __FILE__)
require "simple_captcha/version"

Gem::Specification.new do |s|
s.name = "wolcanus-simple_captcha"
s.name = "glebtv-simple_captcha"
s.version = SimpleCaptcha::VERSION.dup
s.platform = Gem::Platform::RUBY
s.summary = "A fork of galetahub SimpleCaptcha for mongoid support."
s.description = "SimpleCaptcha is available to be used with Rails 3 or above and also it provides the backward compatibility with previous versions of Rails."
s.platform = Gem::Platform::RUBY
s.summary = "A fork of a wolcanus fork of galetahub SimpleCaptcha for mongoid support."
s.description = "."
s.authors = ["Weverton do Couto Timoteo"]
s.email = "weverton@wolcan.us"
s.homepage = "http://github.com/wolcanus/simple-captcha"
s.homepage = "http://github.com/glebtv/simple-captcha"

s.add_dependency("mongoid", ["~> 3.0.0"])
s.files = Dir["{lib}/**/*"] + ["Rakefile", "README.rdoc"]

s.files = Dir["{lib}/**/*"] + %w(Rakefile README.rdoc)
s.test_files = Dir["{test}/**/*"]
s.extra_rdoc_files = ["README.rdoc"]
s.require_paths = ["lib"]
s.extra_rdoc_files = %w(README.rdoc)
s.require_paths = %w(lib)
end

0 comments on commit d182c67

Please sign in to comment.