taiwan_validator 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 757740928b53776a01be1ebf2fdf6e7214b374b7
4
- data.tar.gz: 9cfe758db6cba0e2d2341a8a39bd1b2693f8e127
3
+ metadata.gz: e978b3e14481c43e70d8bb38da2da3c531c7c687
4
+ data.tar.gz: b2adf448f573066ffda09387ab4748267badd114
5
5
  SHA512:
6
- metadata.gz: bccb74f30d14c162d0d1a2bba16d57b96706f8ce04addbf45a94b9ddefd90effcc37cf3daaaf8c523a0e2b328929fd26a988ab09c38b0de69fd06332c4a71508
7
- data.tar.gz: 642573c17c41a9243b7aa68e44a401e1376e1d853f6c6de060c947820459cf5e1d5329a8b4150298424c48dc420da41693660883a51004ab03bec8499c9d228b
6
+ metadata.gz: 456ba18914c2ceab4ce3efa8e8c47af32bdc6614f02c405b45d1b714e38d990ef2d6d679225aaaa08c59b1d717b7de4674509231f93a73de17070c3f4b85e478
7
+ data.tar.gz: a12455bdbf160765cf7b083f9d9eacf8b1d1a4925d9bbd48b77c52b4cced7d2c3e88ae053665ab56a8aa969f751ac99b6ec8f8e8945786527a157fcc22d573f7
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
5
  - 2.2.3
4
6
  before_install: gem install bundler -v 1.10.6
5
7
  addons:
6
8
  code_climate:
7
9
  repo_token: 85915b296b49680c2c4fd50d2be8f76cc094409297c63b37cf15c145968f1e91
8
-
data/README.md CHANGED
@@ -25,6 +25,8 @@ Or install it yourself as:
25
25
  ## Usage
26
26
 
27
27
  ```ruby
28
+ include TaiwanValidator
29
+
28
30
  validates :ubn, ubn: true
29
31
  validates :id, id: true
30
32
  validates :address, address: true
@@ -39,7 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
39
41
 
40
42
  ## Contributing
41
43
 
42
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/taiwan_validator.
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/abookyun/taiwan_validator.
43
45
 
44
46
 
45
47
  ## License
@@ -1,4 +1,4 @@
1
- class AddressValidator < ActiveModel::EachValidator
1
+ class TaiwanValidator::AddressValidator < ActiveModel::EachValidator
2
2
  class << self
3
3
  def valid?(address)
4
4
  /(\A\d{3,5})?\s?(\D+[縣市])(\D+[鄉鎮市區])?(.+)/.match(address)
@@ -1,4 +1,4 @@
1
- class IdValidator < ActiveModel::EachValidator
1
+ class TaiwanValidator::IdValidator < ActiveModel::EachValidator
2
2
  MULTIPLIER = [1,9,8,7,6,5,4,3,2,1,1].freeze
3
3
  FIRST_LETTER = HashWithIndifferentAccess.new(
4
4
  A: 10, B: 11, C: 12, D: 13, E: 14,
@@ -20,7 +20,7 @@ class IdValidator < ActiveModel::EachValidator
20
20
  digits = (VALID_FIRST_LETTER[id[0]].to_s.chars + id[1..9].to_s.chars).map(&:to_i)
21
21
  results = digits.zip(MULTIPLIER).map { |r| r.inject(&:*) }.inject(&:+)
22
22
 
23
- results % 10 == 0 ? true : false
23
+ results % 10 == 0
24
24
  end
25
25
  end
26
26
 
@@ -1,4 +1,4 @@
1
- class PhoneNumberValidator < ActiveModel::EachValidator
1
+ class TaiwanValidator::PhoneNumberValidator < ActiveModel::EachValidator
2
2
  class << self
3
3
  def valid?(phone_number)
4
4
  phone_number.gsub(/[\+\-\s]/, "") =~ /\A(886|0)[2-9]([0-9]{6,8})\z/
@@ -1,4 +1,4 @@
1
- class UbnValidator < ActiveModel::EachValidator
1
+ class TaiwanValidator::UbnValidator < ActiveModel::EachValidator
2
2
  MULTIPLIER = [1,2,1,2,1,2,4,1].freeze
3
3
 
4
4
  class << self
@@ -14,7 +14,7 @@ class UbnValidator < ActiveModel::EachValidator
14
14
  digit
15
15
  end.inject(&:+)
16
16
 
17
- results % 10 == 0 ? true : false
17
+ results % 10 == 0
18
18
  end
19
19
 
20
20
  private
@@ -1,3 +1,3 @@
1
1
  module TaiwanValidator
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -1,10 +1,10 @@
1
1
  require "taiwan_validator/version"
2
2
  require "active_model"
3
3
  require "active_support/hash_with_indifferent_access"
4
- require "ubn_validator"
5
- require "id_validator"
6
- require "address_validator"
7
- require "phone_number_validator"
4
+ require "taiwan_validator/ubn_validator"
5
+ require "taiwan_validator/id_validator"
6
+ require "taiwan_validator/address_validator"
7
+ require "taiwan_validator/phone_number_validator"
8
8
 
9
9
  module TaiwanValidator
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taiwan_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Yun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2016-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -97,12 +97,12 @@ files:
97
97
  - Rakefile
98
98
  - bin/console
99
99
  - bin/setup
100
- - lib/address_validator.rb
101
- - lib/id_validator.rb
102
- - lib/phone_number_validator.rb
103
100
  - lib/taiwan_validator.rb
101
+ - lib/taiwan_validator/address_validator.rb
102
+ - lib/taiwan_validator/id_validator.rb
103
+ - lib/taiwan_validator/phone_number_validator.rb
104
+ - lib/taiwan_validator/ubn_validator.rb
104
105
  - lib/taiwan_validator/version.rb
105
- - lib/ubn_validator.rb
106
106
  - taiwan_validator.gemspec
107
107
  homepage: https://github.com/abookyun/taiwan_validator
108
108
  licenses: