scrubba 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -2
- data/lib/scrubba/active_methods.rb +14 -10
- data/lib/scrubba/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba2ed8480e2ff0e7b1464159fc749eb67abca90b
|
4
|
+
data.tar.gz: 7b2357f30b4a4e36e10db6892e3109e174040b9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908262afc8c7d5fd63d1d7d1806e96609bb890ef30e00f0fdeb8fa5a35cf82e3c96cd3600c1b036bfd7888e1a9fe541c21f16bf612bdede2e314e3cfe13e558e
|
7
|
+
data.tar.gz: fb318e8d2142aed98075667e5f23f09901bc1db536155d7e510b8020e8b0fa9e603a3b93f6603c3cb984477558a1b8d260fe1e7c491caedae2ab91eaf5fdedbd
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Scrubba: Clean your strings!
|
2
2
|
|
3
|
-
[](https://travis-ci.org/jmdeldin/scrubba)
|
3
|
+
[](https://travis-ci.org/jmdeldin/scrubba) [](https://codeclimate.com/github/jmdeldin/scrubba)
|
4
4
|
|
5
5
|
Scrubba is a tiny gem to strip and normalize whitespace. It provides a few convenient methods for working with ActiveRecord/ActiveModel/ActiveAttr/ActiveNode attributes too.
|
6
6
|
|
@@ -38,7 +38,7 @@ In an ActiveRecord model:
|
|
38
38
|
require "scrubba"
|
39
39
|
|
40
40
|
class Post < ActiveRecord::Base
|
41
|
-
|
41
|
+
include Scrubba::ActiveMethods
|
42
42
|
|
43
43
|
strip :title, :body
|
44
44
|
normalize :title
|
@@ -1,18 +1,22 @@
|
|
1
1
|
module Scrubba
|
2
2
|
module ActiveMethods
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
def scrubba_apply(keys, func)
|
8
|
+
keys.each do |k|
|
9
|
+
self[k] = Scrubba.public_send(func, self[k]) if self[k].present?
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
keys
|
14
|
-
|
15
|
-
|
13
|
+
module ClassMethods
|
14
|
+
def scrub(*keys)
|
15
|
+
before_validation { scrubba_apply(keys, :scrub) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def normalize(*keys)
|
19
|
+
before_validation { scrubba_apply(keys, :normalize) }
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/scrubba/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrubba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon-Michael Deldin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- ".rubocop.yml"
|
106
106
|
- ".ruby-version"
|
107
107
|
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
108
109
|
- Gemfile
|
109
110
|
- LICENSE.txt
|
110
111
|
- README.md
|