normalizy 1.6.0 → 1.7.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 +16 -6
- data/README.md +13 -2
- data/lib/normalizy/config.rb +2 -1
- data/lib/normalizy/filters/slug.rb +1 -1
- data/lib/normalizy/filters/strip.rb +1 -1
- data/lib/normalizy/filters/truncate.rb +16 -0
- data/lib/normalizy/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee7f65965cec5c289729431b01fcf23be051784ec7b18bf9b71ae00c698d9d93
|
4
|
+
data.tar.gz: ad9ce5473030dec2eae92783feecf6895e8e5e841bee48b5af46f4b6579dcc12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c043c42e3627fb56b02defc6a0081311da5b72dfb1da0ecda255abca81a734b4a47c4c25054f24d5c4dec75059862fa250482e54d84f79a6905ecde4e5a7cc
|
7
|
+
data.tar.gz: eec956c476590a3a521f33ed58e657add31f52d391cb29362856d9dce14968f8d55df4f38b7d030071283da2d236ee1ec87654c5b6598a181ea45c227ef32216
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## v1.7.0
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
- Adds `truncate` filter; [#3](https://github.com/wbotelhos/normalizy/pull/3) by [rafaeldev](https://github.com/rafaeldev)
|
6
|
+
|
7
|
+
### Updates
|
8
|
+
|
9
|
+
- Adds RuboCop task on the CI;
|
10
|
+
|
1
11
|
## v1.6.0
|
2
12
|
|
3
13
|
### Fixes
|
@@ -9,13 +19,13 @@
|
|
9
19
|
- Adds Code Quality;
|
10
20
|
- Adds Test Coverage;
|
11
21
|
- Migrates the build to Github Actions;
|
12
|
-
- Removes Git dependency for build;
|
22
|
+
- Removes Git dependency for the build;
|
13
23
|
|
14
24
|
## v1.5.0
|
15
25
|
|
16
26
|
### Features
|
17
27
|
|
18
|
-
- Filter `date` now supports call object that
|
28
|
+
- Filter `date` now supports call object that responds to `beginning_of_day` or `end_of_day`;
|
19
29
|
|
20
30
|
## v1.4.0
|
21
31
|
|
@@ -39,19 +49,19 @@
|
|
39
49
|
|
40
50
|
### Fixes
|
41
51
|
|
42
|
-
- When
|
52
|
+
- When using `slug` filter the original values were not saved.
|
43
53
|
|
44
54
|
## v1.1.0
|
45
55
|
|
46
56
|
### Features
|
47
57
|
|
48
|
-
- Added `slug` filter with option to apply the value on other
|
58
|
+
- Added `slug` filter with the option to apply the value on other fields.
|
49
59
|
|
50
60
|
## v1.0.1
|
51
61
|
|
52
62
|
### Fixes
|
53
63
|
|
54
|
-
- When `type` options
|
64
|
+
- When `type` options were `cents` and had no decimal on the number, extra decimals were added.
|
55
65
|
|
56
66
|
## v1.0.0
|
57
67
|
|
@@ -73,7 +83,7 @@
|
|
73
83
|
### Updates
|
74
84
|
|
75
85
|
- `number` filter no more make cast automatically.
|
76
|
-
- `number` now accept `cast` options with method to be used on cast type;
|
86
|
+
- `number` now accept `cast` options with a method to be used on cast type;
|
77
87
|
|
78
88
|
### Features
|
79
89
|
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
[](https://github.com/wbotelhos/normalizy/actions)
|
4
4
|
[](https://badge.fury.io/rb/normalizy)
|
5
|
-
[](https://codeclimate.com/github/wbotelhos/normalizy/maintainability)
|
6
|
+
[](https://codecov.io/gh/wbotelhos/normalizy)
|
7
7
|
[](https://www.patreon.com/wbotelhos)
|
8
8
|
|
9
9
|
Attribute normalizer for Rails.
|
@@ -406,6 +406,17 @@ normalizy :name, with: { strip: { side: :both } }
|
|
406
406
|
|
407
407
|
As you can see, the rules can be passed as Symbol/String or as Hash if it has options.
|
408
408
|
|
409
|
+
### Truncate
|
410
|
+
|
411
|
+
Remove excedent string part from a gived limit.
|
412
|
+
|
413
|
+
```ruby
|
414
|
+
normalizy :description, with: { truncate: { limit: 10 } }
|
415
|
+
|
416
|
+
'Once upon a time in a world far far away'
|
417
|
+
# 'Once upon '
|
418
|
+
```
|
419
|
+
|
409
420
|
## Multiple Filters
|
410
421
|
|
411
422
|
You can normalize with a couple of filters at once:
|
data/lib/normalizy/config.rb
CHANGED
@@ -29,7 +29,8 @@ module Normalizy
|
|
29
29
|
number: Normalizy::Filters::Number,
|
30
30
|
percent: Normalizy::Filters::Percent,
|
31
31
|
slug: Normalizy::Filters::Slug,
|
32
|
-
strip: Normalizy::Filters::Strip
|
32
|
+
strip: Normalizy::Filters::Strip,
|
33
|
+
truncate: Normalizy::Filters::Truncate,
|
33
34
|
}
|
34
35
|
end
|
35
36
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Normalizy
|
4
|
+
module Filters
|
5
|
+
module Truncate
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def call(input, options = {})
|
9
|
+
return input unless options[:limit].is_a?(Integer)
|
10
|
+
return input unless input.is_a?(String)
|
11
|
+
|
12
|
+
input[0, options[:limit]]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/normalizy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: normalizy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Washington Botelho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: debug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -146,12 +146,14 @@ files:
|
|
146
146
|
- lib/normalizy/filters/percent.rb
|
147
147
|
- lib/normalizy/filters/slug.rb
|
148
148
|
- lib/normalizy/filters/strip.rb
|
149
|
+
- lib/normalizy/filters/truncate.rb
|
149
150
|
- lib/normalizy/rspec/matcher.rb
|
150
151
|
- lib/normalizy/version.rb
|
151
152
|
homepage: https://github.com/wbotelhos/normalizy
|
152
153
|
licenses:
|
153
154
|
- MIT
|
154
|
-
metadata:
|
155
|
+
metadata:
|
156
|
+
rubygems_mfa_required: 'true'
|
155
157
|
post_install_message:
|
156
158
|
rdoc_options: []
|
157
159
|
require_paths:
|
@@ -167,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
169
|
- !ruby/object:Gem::Version
|
168
170
|
version: '0'
|
169
171
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.1.6
|
171
173
|
signing_key:
|
172
174
|
specification_version: 4
|
173
175
|
summary: Attribute normalizer for Rails.
|