robworley-stripper 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ == 2.0.3 released 2009-06-13
2
+
3
+ * Add check to see if it's even an ActiveRecord column, and not something that has been duck-typed in (which throws a warning that Object#type has been deprecated). (ealdent)
4
+
5
+ == 2.0.2 released 2009-01-14
6
+
7
+ * Change package structure.
8
+
9
+ == 2.0.0 released 2009-01-05
10
+
11
+ * Rails 2.2.2 compatible.
12
+
13
+ == 2008-08-28
14
+
15
+ * Don't set to NULL if the stripped value is the same as the column's default.
16
+
17
+ * Binary columns being stripped.
18
+
19
+ == 2008-01-03
20
+
21
+ * False incorrectly interpreted as empty.
22
+
23
+ == 2007-11-28
24
+
25
+ * Workaround to ensure plugin is only ever loaded once.
26
+
27
+ == 2007-11-06
28
+
29
+ * Initial revision.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Simon Harris
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.
@@ -0,0 +1,36 @@
1
+ = Stripper
2
+
3
+ Stripper is a Ruby on Rails plugin that removes leading and trailing blanks from attribute values in your models.
4
+
5
+ Leading and trailing spaces on attribute values can be a problem. They're almost never wanted nor intended. In fact,
6
+ Oracle actually treats empty strings as NULL. That's not to say we necessarily think that the database should be messing
7
+ with our data mind you but it does show that at least someone agrees with us.
8
+
9
+ Here's an example of what happens when the plugin is installed:
10
+
11
+ $ ./script/console
12
+ Loading development environment (Rails 2.2.2)
13
+ Welcome to interactive ruby!
14
+ irb --> u = User.new
15
+
16
+ irb --> u.name = " Simon Harris "
17
+ irb --> u.name
18
+ ==> "Simon Harris"
19
+
20
+ irb --> u.name = " "
21
+ irb --> u.name
22
+ ==> nil
23
+
24
+ == Installation
25
+
26
+ You have two choices for installation. The first uses a gem (recommended):
27
+
28
+ config.gem "harukizaemon-stripper", :lib => "stripper", :source => "http://gems.github.com"
29
+
30
+ Or you can use the Rails plugin
31
+
32
+ $ ruby script/plugin install git://github.com/harukizaemon/stripper.git
33
+
34
+ === License
35
+
36
+ This plugin is copyright 2009 Simon Harris and is released under the MIT license.
@@ -0,0 +1,20 @@
1
+ module HarukiZaemon
2
+ module Stripper
3
+ module ActiveRecord
4
+ module Base
5
+ def self.included(base)
6
+ base.alias_method_chain :write_attribute, :stripper
7
+ end
8
+
9
+ def write_attribute_with_stripper(attr_name, value)
10
+ column = column_for_attribute(attr_name)
11
+ unless column && column.type == :binary
12
+ value = value.strip if value.respond_to?(:strip)
13
+ value = nil if value.respond_to?(:empty?) && value.empty? && value != column.default
14
+ end
15
+ write_attribute_without_stripper(attr_name, value)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ require 'haruki_zaemon/stripper/active_record/base'
2
+
3
+ ActiveRecord::Base.send(:include, HarukiZaemon::Stripper::ActiveRecord::Base)
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "robworley-stripper"
3
+ s.version = "2.0.3"
4
+ s.date = "2009-06-13"
5
+ s.summary = "Remove leading and trailing blanks from attribute values in your Ruby on Rails models."
6
+ s.email = "haruki.zaemon@gmail.com"
7
+ s.homepage = "http://github.com/harukizaemon/stripper"
8
+ s.description = "Stripper is a Ruby on Rails plugin that removes leading and trailing blanks from attribute values in your models."
9
+ s.has_rdoc = true
10
+ s.authors = ["Simon Harris"]
11
+ s.files = ["CHANGELOG.rdoc",
12
+ "MIT-LICENSE",
13
+ "README.rdoc",
14
+ "stripper.gemspec",
15
+ "lib/stripper.rb",
16
+ "lib/haruki_zaemon/stripper/active_record/base.rb"]
17
+ s.rdoc_options = ["--main", "README.rdoc"]
18
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
19
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: robworley-stripper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 3
10
+ version: 2.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Simon Harris
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2009-06-13 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Stripper is a Ruby on Rails plugin that removes leading and trailing blanks from attribute values in your models.
23
+ email: haruki.zaemon@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - CHANGELOG.rdoc
30
+ - README.rdoc
31
+ files:
32
+ - CHANGELOG.rdoc
33
+ - MIT-LICENSE
34
+ - README.rdoc
35
+ - stripper.gemspec
36
+ - lib/stripper.rb
37
+ - lib/haruki_zaemon/stripper/active_record/base.rb
38
+ has_rdoc: true
39
+ homepage: http://github.com/harukizaemon/stripper
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --main
45
+ - README.rdoc
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.5.2
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Remove leading and trailing blanks from attribute values in your Ruby on Rails models.
73
+ test_files: []
74
+