Skip to content

Commit

Permalink
Convert to gem
Browse files Browse the repository at this point in the history
  • Loading branch information
pwim committed Nov 22, 2011
1 parent 87e8270 commit f89dd5c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in sanitize_attributes.gemspec
gemspec
3 changes: 2 additions & 1 deletion Rakefile
@@ -1,6 +1,7 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'bundler/gem_tasks'

desc 'Default: run unit tests.'
task :default => :test
Expand Down Expand Up @@ -31,4 +32,4 @@ rescue LoadError
task :rcov do
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
end
end
end
2 changes: 1 addition & 1 deletion init.rb
@@ -1,2 +1,2 @@
require 'sanitize_attributes'
ActiveRecord::Base.class_eval { extend SanitizeAttributes }
SanitizeAttributes.hook!
12 changes: 11 additions & 1 deletion lib/sanitize_attributes.rb
Expand Up @@ -7,8 +7,18 @@ module SanitizeAttributes

class << self
attr_accessor :default_sanitization_method

def hook!
ActiveSupport.on_load(:active_record) { extend SanitizeAttributes }
end
end

# Thrown when sanitize! is called without a defined sanitization method at the class or global level
class NoSanitizationMethodDefined < StandardError ; end
end

if defined?(Rails)
class Railtie < Rails::Railtie
initializer("sanitize_attirbutes") { SanitizeAttributes.hook! }
end
end
end
3 changes: 3 additions & 0 deletions lib/sanitize_attributes/version.rb
@@ -0,0 +1,3 @@
module SanitizeAttributes
VERSION = "0.0.1"
end
26 changes: 26 additions & 0 deletions sanitize_attributes.gemspec
@@ -0,0 +1,26 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "sanitize_attributes/version"

Gem::Specification.new do |s|
s.name = "sanitize_attributes"
s.version = SanitizeAttributes::VERSION
s.authors = ["Dev Purkayastha", "Paul McMahon"]
s.email = ["dev@forgreatjustice.net"]
s.homepage = "https://github.com/devp/sanitize_attributes"
s.summary = %q{This is a simple plugin for ActiveRecord models to define sanitizable attributes.}
s.description = %q{This is a simple plugin for ActiveRecord models to define sanitizable attributes. When an object is saved, those attributes will be run through whatever filter you’ve defined. You can define a default filter for all sanitizations.}

s.rubyforge_project = "sanitize_attributes"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency 'rails', '>= 3.0.0'
s.add_development_dependency 'rake'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'thoughtbot-shoulda'
s.add_development_dependency 'mocha'
end
4 changes: 2 additions & 2 deletions test/test_helper.rb
Expand Up @@ -2,12 +2,12 @@
require 'set'
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
gem 'thoughtbot-shoulda'
require 'shoulda'
gem 'mocha'
require 'mocha'

$:.unshift "#{File.dirname(__FILE__)}/../lib"

require "#{File.dirname(__FILE__)}/../init"
require "#{File.dirname(__FILE__)}/../init"

0 comments on commit f89dd5c

Please sign in to comment.