-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Allow space option #6
Conversation
[ | ||
' ', | ||
' カタ カナー ', | ||
'カタ カナー', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
context 'valid katakana(allow_space)' do | ||
[ | ||
' ', | ||
' カタ カナー ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
context 'valid katakana(allow_space)' do | ||
[ | ||
' ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
].each do |katakana| | ||
it "#{katakana} should be valid" do | ||
expect(KatakanaModel.new(katakana: katakana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
||
context 'valid katakana(allow_space)' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
].each do |katakana| | ||
it "#{katakana} should be valid" do | ||
expect(KatakanaModel.new(katakana: katakana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
].each do |hiragana| | ||
it "#{hiragana} should be valid" do | ||
expect(HiraganaModel.new(hiragana: hiragana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
||
context 'valid hiragana' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
].each do |hiragana| | ||
it "#{hiragana} should be valid" do | ||
expect(HiraganaModel.new(hiragana: hiragana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
@@ -24,10 +28,23 @@ class HiraganaModel < TestModel | |||
'カタカナ', | |||
'漢字', | |||
'ひらがなとカタカナ', | |||
'ひら がなー', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
lib/roshi/version.rb
Outdated
@@ -1,3 +1,3 @@ | |||
module Roshi | |||
VERSION = '0.8.0' | |||
VERSION = '0.8.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -2,7 +2,8 @@ module ActiveModel | |||
module Validations | |||
class KatakanaValidator < EachValidator | |||
def validate_each(record, attribute, value) | |||
unless value =~ /\A[\p{katakana}ー-]*\z/i | |||
space = options[:allow_space] ? '[:blank:]' : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
[ | ||
' ', | ||
' カタ カナー ', | ||
'カタ カナー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
describe 'KatakanaValidator' do | ||
context 'valid katakana' do | ||
[ | ||
'', | ||
'カタカナ', | ||
'カタカナー', | ||
'カタカナー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
[ | ||
' ', | ||
' ひら がな ', | ||
'ひら がなー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -24,10 +28,23 @@ class HiraganaModel < TestModel | |||
'カタカナ', | |||
'漢字', | |||
'ひらがなとカタカナ', | |||
'ひら がなー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
describe 'HiraganaValidator' do | ||
context 'valid hiragana' do | ||
[ | ||
'', | ||
'ひらがな', | ||
'ひらがなー', | ||
'ひらがなー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@kawahiro311 @Kta-M review this. |
@@ -2,7 +2,8 @@ module ActiveModel | |||
module Validations | |||
class KatakanaValidator < EachValidator | |||
def validate_each(record, attribute, value) | |||
unless value =~ /\A[\p{katakana}ー-]*\z/i | |||
space = options[:allow_space] ? '[:blank:]' : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
[ | ||
' ', | ||
' カタ カナー ', | ||
'カタ カナー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
context 'valid katakana(allow_space)' do | ||
[ | ||
' ', | ||
' カタ カナー ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
context 'valid katakana(allow_space)' do | ||
[ | ||
' ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
].each do |katakana| | ||
it "#{katakana} should be valid" do | ||
expect(KatakanaModel.new(katakana: katakana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
||
context 'valid katakana(allow_space)' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
].each do |hiragana| | ||
it "#{hiragana} should be valid" do | ||
expect(HiraganaModel.new(hiragana: hiragana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
||
context 'valid hiragana' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
].each do |hiragana| | ||
it "#{hiragana} should be valid" do | ||
expect(HiraganaModel.new(hiragana: hiragana)).not_to be_valid | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingWhitespace: Trailing whitespace detected.
@@ -24,10 +28,23 @@ class HiraganaModel < TestModel | |||
'カタカナ', | |||
'漢字', | |||
'ひらがなとカタカナ', | |||
'ひら がなー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
describe 'HiraganaValidator' do | ||
context 'valid hiragana' do | ||
[ | ||
'', | ||
'ひらがな', | ||
'ひらがなー', | ||
'ひらがなー' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -2,7 +2,8 @@ module ActiveModel | |||
module Validations | |||
class HiraganaValidator < EachValidator | |||
def validate_each(record, attribute, value) | |||
unless value =~ /\A[\p{hiragana}ー-]*\z/i | |||
space = options[:allow_space] ? '[:blank:]' : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok farm!
add allow_space option to katakana and hiragana
like this: