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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fad6478c28b93b323d700ab5f92b02a5693d7b6
4
- data.tar.gz: a5ecff169902c3da492f0b1a9aaece26ec6a45a2
3
+ metadata.gz: ba2ed8480e2ff0e7b1464159fc749eb67abca90b
4
+ data.tar.gz: 7b2357f30b4a4e36e10db6892e3109e174040b9a
5
5
  SHA512:
6
- metadata.gz: f10b5c034de3041751c1419092006251fafb4e0ea757820c28a94969cf10fc477e0288040441530c086bebee431d9784b258d8e0922af58d4da83c842cca4ebe
7
- data.tar.gz: 8da73c23ed34f140261c663f0e711f6e36c374f984da734441a8f090e7cd00af98093c5b02e72324267b7fa6f1d09eb31be003d0183426b31235316bf101321c
6
+ metadata.gz: 908262afc8c7d5fd63d1d7d1806e96609bb890ef30e00f0fdeb8fa5a35cf82e3c96cd3600c1b036bfd7888e1a9fe541c21f16bf612bdede2e314e3cfe13e558e
7
+ data.tar.gz: fb318e8d2142aed98075667e5f23f09901bc1db536155d7e510b8020e8b0fa9e603a3b93f6603c3cb984477558a1b8d260fe1e7c491caedae2ab91eaf5fdedbd
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # 0.2.0 (2015-08-29)
2
+
3
+ - Switched from `extend` to `include` for consistency with gems and
4
+ DRY-er code
5
+
6
+ # 0.1.0 (2015-08-28)
7
+
8
+ Initial release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Scrubba: Clean your strings!
2
2
 
3
- [![Build Status](https://travis-ci.org/jmdeldin/scrubba.svg)](https://travis-ci.org/jmdeldin/scrubba)
3
+ [![Build Status](https://travis-ci.org/jmdeldin/scrubba.svg)](https://travis-ci.org/jmdeldin/scrubba) [![Code Climate](https://codeclimate.com/github/jmdeldin/scrubba/badges/gpa.svg)](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
- extend Scrubba::ActiveMethods
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 scrub(*keys)
4
- before_validation do
5
- keys.each do |k|
6
- self[k] = Scrubba.scrub(self[k]) if self[k].present?
7
- end
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
- def normalize(*keys)
12
- before_validation do
13
- keys.each do |k|
14
- self[k] = Scrubba.normalize(self[k]) if self[k].present?
15
- end
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
@@ -1,3 +1,3 @@
1
1
  module Scrubba
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-28 00:00:00.000000000 Z
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