attr_filters 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/attr_filters/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97bb54568e619193e916547fb341d07a4dff26203a3c1892e7560064e367e7d0
|
4
|
+
data.tar.gz: 7086278f77d84a920b55b61c0afc581e04fb5496f913e90a3802f19f6917bf37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cada13d445118bbb08f414a8f8e85c1d227771fbebac0ed51ecbffa4ca1e19f3b9d70a936be25cc128fc2cdc28231704e708b4b06e0e88869935058f3482c886
|
7
|
+
data.tar.gz: 406ede63fe8d8e3db46fcf2b9efc3f310a816ece1242dbfdf9ca9358033b69f7a583b9271f2b1df7370e6643b56cb9fd5b8b27e8f4c852b9fc4c401e3fe20906
|
data/README.md
CHANGED
@@ -39,11 +39,13 @@ You can add filters like that:
|
|
39
39
|
class SingupForm
|
40
40
|
include AttrFilters
|
41
41
|
|
42
|
-
attr_accessor :email, :first_name, :last_name, :zip
|
42
|
+
attr_accessor :email, :first_name, :last_name, :zip, :birth_date, :due_date
|
43
43
|
|
44
44
|
filters :email, trim: true, downcase: true
|
45
45
|
filters :first_name, :last_name, trim: true, letters_only: true
|
46
46
|
filters :zip, trim: true, numbers_only: true
|
47
|
+
filters :birth_date, date: true
|
48
|
+
filters :due_date, date: "%m-%d-%Y"
|
47
49
|
end
|
48
50
|
```
|
49
51
|
|
@@ -57,6 +59,8 @@ form.email = " mike.dou@example.com "
|
|
57
59
|
form.first_name = "Mike 123"
|
58
60
|
form.last_name = " Dou"
|
59
61
|
form.zip = "abc12345"
|
62
|
+
form.birth_date = "2019-11-02"
|
63
|
+
form.due_date = "11-02-2019"
|
60
64
|
|
61
65
|
form.filter!
|
62
66
|
|
@@ -64,6 +68,8 @@ form.email # => "mike.dou@example.com"
|
|
64
68
|
form.first_name # => "Mike"
|
65
69
|
form.last_name # => "Dou"
|
66
70
|
form.zip # => "12345"
|
71
|
+
form.birth_date # => #<Date: 2019-11-02 ((2458790j,0s,0n),+0s,2299161j)>
|
72
|
+
form.due_date # => #<Date: 2019-11-02 ((2458790j,0s,0n),+0s,2299161j)>
|
67
73
|
```
|
68
74
|
|
69
75
|
## Integration with Rails
|
@@ -117,13 +123,9 @@ form.zip # => "12345"
|
|
117
123
|
- `squeeze` - removes duplicating whitespaces
|
118
124
|
- `numbers_only` - removes non digits characters
|
119
125
|
- `letters_only` - removes non letter characters
|
126
|
+
- `date` - parse string to date using specified format. Default format is **`%Y-%m-%d`**.
|
120
127
|
|
121
128
|
|
122
|
-
## Development
|
123
|
-
|
124
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
125
|
-
|
126
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
127
129
|
|
128
130
|
## Contributing
|
129
131
|
|
@@ -140,4 +142,4 @@ Everyone interacting in the AttrFilters project’s codebases, issue trackers, c
|
|
140
142
|
|
141
143
|
## Authors
|
142
144
|
|
143
|
-
[Syndicode.com](https://syndicode.com)
|
145
|
+
[Syndicode.com](https://syndicode.com)
|
data/lib/attr_filters/version.rb
CHANGED