normalizer_jp 1.0.0 → 1.1.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 +27 -1
- data/lib/generators/normalizer_generator.rb +9 -0
- data/lib/generators/templates/normalizer.rb +8 -0
- data/lib/normalizer_jp/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be959d8f96ea055feb516013a528287d665669e266fbc408bfc2ceb6bee3d5e9
|
4
|
+
data.tar.gz: be0bfa4d50b497bbf89a5bfb0853705a3fb8e0efc22f8eee4e0d31096336cc99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '099b28c5f642cffe5af5282a3f6a83b5d7f9e830b9e64d52b5fc30020ca74b582143db9d0eb6cb21d1d59455b4ae9f7223105fd8494ec50f224ad97e84713a42'
|
7
|
+
data.tar.gz: a43f7d69f7ca6704de228b0b7c703eab780ee1d2aba5f7d4a55bbdb39478082abfee2989722c75ee3cdb4c983435d8c6f469d7aff81d3072d58f7e2a0b32d5cd
|
data/README.md
CHANGED
@@ -17,6 +17,32 @@ Or install it yourself as:
|
|
17
17
|
|
18
18
|
$ gem install normalizer_jp
|
19
19
|
|
20
|
+
## Getting Started
|
21
|
+
Start off by generating normalizer:
|
22
|
+
|
23
|
+
```
|
24
|
+
bin/rails g normalizer Strip
|
25
|
+
```
|
26
|
+
|
27
|
+
this should give you a file in:
|
28
|
+
|
29
|
+
```
|
30
|
+
app/normalizers/strip_normalizer.rb
|
31
|
+
```
|
32
|
+
|
33
|
+
Check out this file for some hints on how you can customize your normlizer. It should look something like this:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
class StripNormalizer < NormalizerJp::Normalizers::Base
|
37
|
+
class << self
|
38
|
+
# Normalizer class's responsibility is implimentaion of call method as class method
|
39
|
+
def call(attribute_value)
|
40
|
+
# Here's normalizer space
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
20
46
|
## Usage
|
21
47
|
|
22
48
|
### ActiveRecord
|
@@ -35,7 +61,7 @@ user.name_kana = 'イトウアサコ'
|
|
35
61
|
user.name_kana #=> 'いとうあさこ'
|
36
62
|
```
|
37
63
|
|
38
|
-
you can use custom
|
64
|
+
you can use custom normalizers. custom normalizers's responsibility is implementation of call method as class method. It's super cool.
|
39
65
|
```ruby
|
40
66
|
# app/normalizers/upcase_normalizer.rb
|
41
67
|
class UpcaseNormalizer < NormalizerJp::Normalizers::Base
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: normalizer_jp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- koukikitamura
|
@@ -132,6 +132,8 @@ files:
|
|
132
132
|
- Rakefile
|
133
133
|
- bin/console
|
134
134
|
- bin/setup
|
135
|
+
- lib/generators/normalizer_generator.rb
|
136
|
+
- lib/generators/templates/normalizer.rb
|
135
137
|
- lib/normalizer_jp.rb
|
136
138
|
- lib/normalizer_jp/normalize_builder.rb
|
137
139
|
- lib/normalizer_jp/normalizers.rb
|