normalizer_jp 0.4.4 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '06946b93936ba980a881277a6f049cd0893a02d949cd64036f9675b9595f7079'
4
- data.tar.gz: 527403d8104f15b8b539c5e71a8fa0eeec6a0af749a92ca17447c47ac2d69c76
3
+ metadata.gz: 417d64efbb124b0e5372e05baeeeef03adacb7813ac02ed4a7a457ddcd903e9c
4
+ data.tar.gz: 30e5c9a1dd10f7836e5f28da2d9efde85165071ee0ea29eb78f0dd8ed4afef08
5
5
  SHA512:
6
- metadata.gz: c24260b8608952af7a0e389e5591b1f9297e15cb26c470e662b081f37c2e4fed7068c84f195011e26841ce700e0d08357c3fe22bf81f959ff5f0d5eeeb4f6167
7
- data.tar.gz: d807333e9d1f220f762471aaa19c7565c003a8aff6aad57b8a6d90b2bbc7b2c4da3d912242b5788d89085539ad32184076e9862ce718293ada1c2ebbe4372d86
6
+ metadata.gz: c9610ae79fe74310a87159c992f9250a4cdb528a78513b6789ef6eb52ec44aeca34a616fd84d23e573e3d61cb1f84fa190966a255437f1ee6bf00b6392d993f6
7
+ data.tar.gz: f6faec9b08413e0ee6c1d678f9a76d0fa3c6b351e792f896a08138097725d5585a35befecb50c8d9d80468fca1e4ed0e08b7d38c491cfb95ed5738891a2b9ef0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- normalizer_jp (0.4.3)
4
+ normalizer_jp (0.4.4)
5
5
  activerecord (~> 5.0)
6
6
  activesupport (~> 5.0)
7
7
 
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # NormalizerJp
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/normalizer_jp`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This gem a provites a simple and flexible way to normalize attributes of
4
+ Ruby Object. NormalizerJP includes a word JP(stands for Japanese), but this gem
5
+ is useful for the other(not Japanese) because you can user custom Normalizer.
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
6
7
 
7
8
  ## Installation
8
9
 
@@ -12,23 +13,57 @@ Add this line to your application's Gemfile:
12
13
  gem 'normalizer_jp'
13
14
  ```
14
15
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
16
  Or install it yourself as:
20
17
 
21
18
  $ gem install normalizer_jp
22
19
 
23
20
  ## Usage
24
21
 
25
- TODO: Write usage instructions here
22
+ ### ActiveRecord
23
+ you can use normalizers of this gem.
24
+ ```ruby
25
+ class User < ActiveRecord
26
+ include NormalizerJp::Normalizers
26
27
 
27
- ## Development
28
+ mount_normalizer :name_kana, HiraganaNormalizer
29
+ end
30
+ ```
31
+ normlizer works as following:
32
+ ```ruby
33
+ user = User.new
34
+ user.name_kana = 'イトウアサコ'
35
+ user.name_kana #=> 'いとうあさこ'
36
+ ```
28
37
 
29
- 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.
38
+ you can use custom normalizer. customer normalizer's responsibility is implementation of call method as class method. It's super cool.
39
+ ```ruby
40
+ # app/normalizers/upcase_normalizer.rb
41
+ class UpcaseNormalizer < NormalizerJp::Normalizers::Base
42
+ class << self
43
+ def call(attribute_value)
44
+ attribute_value.to_s.upcase
45
+ end
46
+ end
47
+ end
48
+
49
+ # app/models/blog.rb
50
+ class Blog < ActiveRecord
51
+ mount_normalizer :title, UpcaseNormalizer
52
+ end
53
+ ```
54
+
55
+ custom normalizer works as following:
56
+ ```ruby
57
+ blog = Blog.new
58
+ blog.title = 'awesome title'
59
+ blog.title #=> 'AWESOME TITLE'
60
+ ```
61
+ ### Plain Old Ruby Object
62
+ this gem dose not depends active_record, which mean we use this gem in
63
+ Plain Old Ruby Object.
30
64
 
31
- 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).
65
+ ## Versioning
66
+ This project uses [Semantic Versioning](https://semver.org/) for release numbering.
32
67
 
33
68
  ## Contributing
34
69
 
@@ -1,6 +1,6 @@
1
1
  module NormalizerJp
2
2
  module Normalizers
3
- class HankakuNormalizer
3
+ class HankakuNormalizer < Base
4
4
  class << self
5
5
  def call(atrribute_value)
6
6
  convert_alphabet_and_nubmer_to_hankaku(atrribute_value)
@@ -1,6 +1,6 @@
1
1
  module NormalizerJp
2
2
  module Normalizers
3
- class HiraganaNormalizer
3
+ class HiraganaNormalizer < Base
4
4
  class << self
5
5
  def call(attribute_value)
6
6
  convert_katakana_to_hiragana(attribute_value)
@@ -1,6 +1,6 @@
1
1
  module NormalizerJp
2
2
  module Normalizers
3
- class KatakanaNormalizer
3
+ class KatakanaNormalizer < Base
4
4
  class << self
5
5
  def call(attribute_value)
6
6
  convert_hiragana_to_katakana(attribute_value)
@@ -1,9 +1,16 @@
1
- require "normalizer_jp/normalizers/hankaku_normalizer"
2
- require "normalizer_jp/normalizers/katakana_normalizer"
3
- require "normalizer_jp/normalizers/hiragana_normalizer"
4
-
5
1
  module NormalizerJp
6
2
  module Normalizers
3
+ class Base
4
+ class << self
5
+ def call(attribute_value)
6
+ raise NotImplementedError,
7
+ 'Normalizer must implement call methods as class method'
8
+ end
9
+ end
10
+ end
7
11
  end
8
12
  end
9
13
 
14
+ require "normalizer_jp/normalizers/hankaku_normalizer"
15
+ require "normalizer_jp/normalizers/katakana_normalizer"
16
+ require "normalizer_jp/normalizers/hiragana_normalizer"
@@ -1,3 +1,3 @@
1
1
  module NormalizerJp
2
- VERSION = "0.4.4"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalizer_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - koukikitamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-18 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler