attr_filters 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/attr_filters/filters.rb +3 -1
- data/lib/attr_filters/filters/base.rb +3 -2
- data/lib/attr_filters/filters/date.rb +15 -0
- data/lib/attr_filters/filters_macro.rb +3 -3
- data/lib/attr_filters/instance_methods.rb +3 -3
- data/lib/attr_filters/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5d9621f613bdb9188c3e39ce6cc9d9c7d0d310fc7f3c5b1fe301e46f40250f4
|
4
|
+
data.tar.gz: aead70cf656f6fb587fd811b5c7a68e10464d0e291fe22e1360b374efce0a4d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95e5e1a38c9405ea7f7e14b9770106afeaae9ab1ab3e0540c2d7d9fa74cc35cfe295f1ef73ab9f855876a68a98735039496a4d29eab0eea564af59bcc8782e5c
|
7
|
+
data.tar.gz: 7593f45e1d12da007104abc013eb98ebff60dc6d2dc6db13bb9892e3fd270ab0d50997568b72c7f159440ac000d68edc064f484901a95e63d37552506abdfa84
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.com/Syndicode/attr-filters.svg?branch=master)](https://travis-ci.com/Syndicode/attr-filters)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/attr_filters.svg)](https://badge.fury.io/rb/attr_filters)
|
5
|
-
[![FOSSA Status](https://app.fossa.
|
5
|
+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSyndicode%2Fattr-filters.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSyndicode%2Fattr-filters?ref=badge_shield)
|
6
|
+
|
6
7
|
|
7
8
|
Light weight gem for filtering PORO (Plain Old Ruby Objects) attributes with zero dependencies.
|
8
9
|
|
@@ -132,10 +133,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Syndic
|
|
132
133
|
|
133
134
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
134
135
|
|
136
|
+
|
135
137
|
## Code of Conduct
|
136
138
|
|
137
139
|
Everyone interacting in the AttrFilters project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Syndicode/attr_filters/blob/master/CODE_OF_CONDUCT.md).
|
138
140
|
|
139
141
|
## Authors
|
140
142
|
|
141
|
-
[Syndicode.com](https://syndicode.com)
|
143
|
+
[Syndicode.com](https://syndicode.com)
|
data/lib/attr_filters/filters.rb
CHANGED
@@ -11,6 +11,7 @@ module AttrFilters
|
|
11
11
|
autoload :Squeeze, "attr_filters/filters/squeeze"
|
12
12
|
autoload :LettersOnly, "attr_filters/filters/letters_only"
|
13
13
|
autoload :NumbersOnly, "attr_filters/filters/numbers_only"
|
14
|
+
autoload :Date, "attr_filters/filters/date"
|
14
15
|
|
15
16
|
LIST = {
|
16
17
|
trim: Trim.new,
|
@@ -19,7 +20,8 @@ module AttrFilters
|
|
19
20
|
numbers_only: NumbersOnly.new,
|
20
21
|
letters_only: LettersOnly.new,
|
21
22
|
squeeze: Squeeze.new,
|
22
|
-
capitalize: Capitalize.new
|
23
|
+
capitalize: Capitalize.new,
|
24
|
+
date: Date.new
|
23
25
|
}.freeze
|
24
26
|
end
|
25
27
|
end
|
@@ -20,9 +20,9 @@ module AttrFilters
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def register_filters(filters, attrs)
|
23
|
-
filters.each_pair do |filter,
|
24
|
-
@_registered_filters[filter] ||= Set.new
|
25
|
-
@_registered_filters[filter].merge(attrs)
|
23
|
+
filters.each_pair do |filter, options|
|
24
|
+
@_registered_filters[filter] ||= { attributes: Set.new, options: options }
|
25
|
+
@_registered_filters[filter][:attributes].merge(attrs)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -3,11 +3,11 @@
|
|
3
3
|
module AttrFilters
|
4
4
|
module InstanceMethods
|
5
5
|
def filter!
|
6
|
-
self.class._registered_filters.each_pair do |filter_name,
|
6
|
+
self.class._registered_filters.each_pair do |filter_name, params|
|
7
7
|
filter = build_filter(filter_name)
|
8
|
-
|
8
|
+
params[:attributes].each do |attr|
|
9
9
|
value = send(attr)
|
10
|
-
send("#{attr}=", filter.call(value))
|
10
|
+
send("#{attr}=", filter.call(value, params[:options]))
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/attr_filters/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Holovko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/attr_filters/filters.rb
|
114
114
|
- lib/attr_filters/filters/base.rb
|
115
115
|
- lib/attr_filters/filters/capitalize.rb
|
116
|
+
- lib/attr_filters/filters/date.rb
|
116
117
|
- lib/attr_filters/filters/downcase.rb
|
117
118
|
- lib/attr_filters/filters/letters_only.rb
|
118
119
|
- lib/attr_filters/filters/numbers_only.rb
|
@@ -145,8 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
146
|
- !ruby/object:Gem::Version
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.7.6
|
149
|
+
rubygems_version: 3.0.3
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Light weight gem for filtering PORO (Plain Old Ruby Objects) attributes with
|