validate_japanese 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cec650ea68939253db44b7af6d4d773ee238480fcbcbc72623a3f704967a76e5
4
+ data.tar.gz: 8ba384ccd7964eee845155f44cba576d6624338ab3e44412b2b2277288790411
5
+ SHA512:
6
+ metadata.gz: 71dd21a5408d9024c19bddfafff37e68f46e5d6e821e0553d71773cc3db81acff9f62cbe397b9c9f4cdc172ed496001b22753be1a7aeef3c0f44029532b65127
7
+ data.tar.gz: 5cd4c91cf3d8a74521e203747e4f90f0dd72f80e2923d34f1b8ab48945a749e331962372f00b4854d0306e85dc0210adc5588725e57d50c55a10626d783b6a81
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ /.idea
data/.travis.yml ADDED
@@ -0,0 +1,48 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ # For ruby compatibility, we test the highest and lowest minor versions only.
5
+ # For example, if our gemspec says `required_ruby_version = ">= 2.3.0"`, and
6
+ # ruby 2.5.0 has just been released, then we test 2.3 and 2.5, but not 2.4.
7
+ rvm:
8
+ - 2.3.8
9
+ - 2.4.5
10
+ - 2.5.3
11
+
12
+ env:
13
+ global:
14
+ - TRAVIS=true
15
+ matrix:
16
+ - DB=mysql
17
+ - DB=postgres
18
+ - DB=sqlite
19
+
20
+ # We want to use `sudo: false` because the container infrastructure is supposed
21
+ # to be faster, but Travis is having issues with containers lately ..
22
+ #
23
+ # > No output has been received in the last 10m0s
24
+ #
25
+ # .. and they recommend we use the VM infrastructure (`sudo: required`) in
26
+ # the meantime.
27
+ sudo: required
28
+
29
+ before_install:
30
+ - gem update bundler
31
+
32
+ gemfile:
33
+ - gemfiles/ar_4.2.gemfile
34
+ - gemfiles/ar_5.1.gemfile
35
+ - gemfiles/ar_5.2.gemfile
36
+ matrix:
37
+ exclude:
38
+ # optimization: don't test intermediate rubies (see above)
39
+ - rvm: 2.4.5
40
+ gemfile: gemfiles/ar_4.2.gemfile
41
+ - rvm: 2.4.5
42
+ gemfile: gemfiles/ar_5.1.gemfile
43
+ - rvm: 2.4.5
44
+ gemfile: gemfiles/ar_5.2.gemfile
45
+ fast_finish: true
46
+
47
+ addons:
48
+ postgresql: "9.4"
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in validate_japanese.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ validate_japanese (0.2.0)
5
+ activerecord (>= 4.2, < 6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (5.2.2)
11
+ activesupport (= 5.2.2)
12
+ activerecord (5.2.2)
13
+ activemodel (= 5.2.2)
14
+ activesupport (= 5.2.2)
15
+ arel (>= 9.0)
16
+ activesupport (5.2.2)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ arel (9.0.0)
22
+ concurrent-ruby (1.1.4)
23
+ i18n (1.3.0)
24
+ concurrent-ruby (~> 1.0)
25
+ minitest (5.11.3)
26
+ rake (12.3.2)
27
+ sqlite3 (1.3.13)
28
+ thread_safe (0.3.6)
29
+ tzinfo (1.2.5)
30
+ thread_safe (~> 0.1)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler
37
+ minitest
38
+ rake
39
+ sqlite3
40
+ validate_japanese!
41
+
42
+ BUNDLED WITH
43
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 ts-3156
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Validate Japanese
2
+
3
+ [![Build Status](https://travis-ci.org/ts-3156/validate_japanese.svg?branch=master)](https://travis-ci.org/ts-3156/validate_japanese)
4
+ [![Gem Version](https://badge.fury.io/rb/validate_japanese.svg)](https://badge.fury.io/rb/validate_japanese)
5
+
6
+ This gem adds the capability of validating Japanese to ActiveRecord. :tada:
7
+
8
+ ## Getting Started
9
+
10
+ Add this line to your application’s Gemfile:
11
+
12
+ ```ruby
13
+ gem 'validate_japanese'
14
+ ```
15
+
16
+ Add a validation rule to your model.
17
+
18
+ ```ruby
19
+ validates :name, hiragana: true
20
+ ```
21
+
22
+ or
23
+
24
+ ```ruby
25
+ validates_japanese :name
26
+ ```
27
+
28
+ ## Implementation
29
+
30
+ TODO
31
+
32
+ ## Contributing
33
+
34
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
35
+
36
+ - [Report bugs](https://github.com/ts-3156/validate_japanese/issues)
37
+ - Fix bugs and [submit pull requests](https://github.com/ts-3156/validate_japanese/pulls)
38
+ - Write, clarify, or fix documentation
39
+ - Suggest or add new features
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "validate_japanese"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 4.2.10"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 5.1.5"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 5.2.1"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ require "active_support/concern"
2
+
3
+ module ValidateJapanese
4
+ module Model
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def validates_japanese(*attr_names)
9
+ validates_with ::ActiveModel::Validations::HiraganaValidator, _merge_attributes(attr_names)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveModel
2
+ module Validations
3
+ class HiraganaValidator < ::ActiveModel::EachValidator
4
+ def validate_each(record, attribute, value)
5
+ unless value =~ /\A[ぁ-んー-]+\z/
6
+ record.errors.add(attribute, options[:message] || :invalid)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ValidateJapanese
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "active_support"
2
+ require "active_record"
3
+ require "validate_japanese/version"
4
+ require "validate_japanese/validations/hiragana_validator"
5
+ require "validate_japanese/model"
6
+
7
+ ActiveSupport.on_load(:active_record) do
8
+ include(ValidateJapanese::Model)
9
+ end
10
+
11
+ module ValidateJapanese
12
+ class Error < StandardError; end
13
+ # Your code goes here...
14
+ end
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "validate_japanese/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "validate_japanese"
8
+ spec.version = ValidateJapanese::VERSION
9
+ spec.authors = ["ts-3156"]
10
+ spec.email = ["ts_3156@yahoo.co.jp"]
11
+
12
+ spec.summary = %q{Add Japanese validators}
13
+ spec.homepage = "https://github.com/ts-3156/validate_japanese"
14
+ spec.license = "MIT"
15
+
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/ts-3156/validate_japanese"
19
+ spec.metadata["changelog_uri"] = "https://github.com/ts-3156/validate_japanese"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "activerecord", [">= 4.2", "< 6.0"]
35
+
36
+ spec.add_development_dependency "bundler"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "minitest"
39
+ spec.add_development_dependency "sqlite3"
40
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: validate_japanese
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - ts-3156
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: minitest
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: sqlite3
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description:
90
+ email:
91
+ - ts_3156@yahoo.co.jp
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".travis.yml"
98
+ - Gemfile
99
+ - Gemfile.lock
100
+ - LICENSE.txt
101
+ - README.md
102
+ - Rakefile
103
+ - bin/console
104
+ - bin/setup
105
+ - gemfiles/ar_4.2.gemfile
106
+ - gemfiles/ar_5.1.gemfile
107
+ - gemfiles/ar_5.2.gemfile
108
+ - lib/validate_japanese.rb
109
+ - lib/validate_japanese/model.rb
110
+ - lib/validate_japanese/validations/hiragana_validator.rb
111
+ - lib/validate_japanese/version.rb
112
+ - validate_japanese.gemspec
113
+ homepage: https://github.com/ts-3156/validate_japanese
114
+ licenses:
115
+ - MIT
116
+ metadata:
117
+ homepage_uri: https://github.com/ts-3156/validate_japanese
118
+ source_code_uri: https://github.com/ts-3156/validate_japanese
119
+ changelog_uri: https://github.com/ts-3156/validate_japanese
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.7.6
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Add Japanese validators
140
+ test_files: []