ostruct-sanitizer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fbed6da9849bd08294b41532a5d3b6eddb7e2be
4
- data.tar.gz: 6cfdf6336cef374308cb8d185d11af5649ebcace
3
+ metadata.gz: fb69d7d79fdbe87d7170925729d2322892251f0d
4
+ data.tar.gz: e7916d591ac8d1f636aaf594109ef95c0e7234c8
5
5
  SHA512:
6
- metadata.gz: 94681e544a913fb8bb34d0ab3eb56bf567d7d8f01f663908df3a590fdf1eeaba5a6d15ef627ff5865c9aca9313ad08aaee2b527905e98419960f92d8159ab513
7
- data.tar.gz: 98e55eb02a6625a6323e36f33d0073f3e63e55ad7568f0858f3326ddfcfe320d88f688e17d630b78a5e6830f6a7f86878650de7ab07ba8affd058077807863f4
6
+ metadata.gz: f6d3a53a6bf8f18592ff87a1b284e61008418bfe0951afd59db0b434882427fbc14d8d9199518f76c77265cdaab4c2bf2055374d62f2343fa686e21d73d03b7b
7
+ data.tar.gz: 4dd3c31e4f72e2af30218071fc24b37847e4d9a6156adebdbb133250e28a87ee0a32bbda852a4ec636041a0dbea8461cef991e0b2a2c0b3f30fa10c5905ac52e
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # OStruct::Sanitizer
2
2
 
3
- Provides Rails-like sanitization hooks to be applied to OpenStruct fields upon their assignment, allowing for better encapsulation of such rules.
3
+ [![Build Status](https://travis-ci.org/powerhome/ostruct-sanitizer.svg?branch=master)](https://travis-ci.org/powerhome/ostruct-sanitizer)
4
+
5
+ Provides Rails-like sanitization hooks to be applied to OpenStruct fields upon their assignment, allowing for better encapsulation of such rules and simple extensibility.
4
6
 
5
7
  This module provides a few built-in sanitization rules, all built upon the basic `#sanitize` method used as building block.
6
8
 
@@ -1,5 +1,5 @@
1
1
  module OStruct
2
2
  module Sanitizer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -110,6 +110,16 @@ module OStruct
110
110
  sanitize(field) { |value| value.strip }
111
111
  end
112
112
  end
113
+
114
+ # Removes any non-digit character from the values of the given fields
115
+ #
116
+ # @param [Array<Symbol>] fields list of fields to be sanitized
117
+ #
118
+ def digits(*fields)
119
+ fields.each do |field|
120
+ sanitize(field) { |value| value.to_s.gsub(/[^0-9]/, '') }
121
+ end
122
+ end
113
123
  end
114
124
  end
115
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ostruct-sanitizer
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
  - Diego Borges