gimei 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6016ced4c59c2104679d20754ed73dfe6600634
4
+ data.tar.gz: aac2b4cf83d822c670be1ea9883fb20e99bbdb9d
5
+ SHA512:
6
+ metadata.gz: 8b826c7c83f91f657bfc4eec693bf994ed1bf46c3513f15487b894d4c9e74a7a59253fe77f5de07fd48674ae138c18142f1386aa7985bdd457342b8323c348e2
7
+ data.tar.gz: b84659f6942c54bdf91368df623cce31387d9b4ec4d0aa90fdeff40b2b7ce2b18fe6258777560ae34ca278cd92e47aa3daf54d4e757b46c7a0f9caa57526752a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gimei.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 willnet
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ # Gimei
2
+
3
+ [![Build Status](https://travis-ci.org/willnet/gimei.png)](https://travis-ci.org/willnet/gimei)
4
+ [![endorse](https://api.coderwall.com/willnet/endorsecount.png)](https://coderwall.com/willnet)
5
+
6
+ gimei は、日本人の名前をランダムに返すライブラリです。テストの時などに使います。似たようなライブラリに[faker](https://github.com/stympy/faker)があります。[faker](https://github.com/stympy/faker)はとても優れたライブラリで、多言語対応もしていますが、ふりがな(フリガナ)は流石に対応していません。gimei は名前のふりがな(及びフリガナ)に対応しています。
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'gimei'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install gimei
21
+
22
+ ## Usage
23
+
24
+ 下記のように使います。
25
+
26
+ ```ruby
27
+ gimei = Gimei.new
28
+ gimei.kanji #=> "斎藤 陽菜"
29
+ gimei.hiragana #=> "さいとう はるな"
30
+ gimei.katakana #=> "サイトウ ハルナ"
31
+ gimei.last.kanji #=> "斎藤"
32
+ gimei.last.hiragana #=> "さいとう"
33
+ gimei.last.katakana #=> "サイトウ"
34
+ gimei.first.kanji #=> "陽菜"
35
+ gimei.first.hiragana #=> "はるな"
36
+ gimei.first.katakana #=> "ハルナ"
37
+ ```
38
+
39
+ 漢字、ひらがな、カタカナどれか一種類だけ取得できればよい場合には、下記のように書くことも出来ます。
40
+
41
+ ```ruby
42
+ Gimei.kanji #=> "伊藤 結衣"
43
+ Gimei.hiragana #=> "いとう みさき"
44
+ Gimei.katakana #=> "タカハシ ユイナ"
45
+ Gimei.last.kanji #=> "清水"
46
+ Gimei.last.hiragana #=> "いとう"
47
+ Gimei.last.katakana #=> "コバヤシ"
48
+ Gimei.first.kanji #=> "結菜"
49
+ Gimei.first.hiragana #=> "ここあ"
50
+ Gimei.first.katakana #=> "ヤマト"
51
+ ```
52
+
53
+ 出力される名前の候補となるデータは `lib/data/names.yml` にあるので、必要であればファイルを修正してください。
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "spec/*_spec.rb"
6
+ end
7
+
8
+ task :default => :test
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gimei/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "gimei"
8
+ gem.version = Gimei::VERSION
9
+ gem.authors = ["willnet"]
10
+ gem.email = ["netwillnet@gmail.com"]
11
+ gem.description = %q{random Japanese name generator}
12
+ gem.summary = %q{random Japanese name generator. support kanji, hiragana, and katakana}
13
+ gem.homepage = "https://github.com/willnet/gimei"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_development_dependency('rake')
20
+ gem.add_development_dependency('moji')
21
+ gem.add_development_dependency('minitest')
22
+ end
@@ -0,0 +1,36 @@
1
+ first_name:
2
+ - ['樹', 'いつき', 'イツキ']
3
+ - ['大和', 'やまと', 'ヤマト']
4
+ - ['太一', 'たいち', 'タイチ']
5
+ - ['蒼空', 'あおぞら', 'アオゾラ']
6
+ - ['翼', 'つばさ', 'ツバサ']
7
+ - ['陽菜', 'はるな', 'ハルナ']
8
+ - ['結衣', 'ゆい', 'ユイ']
9
+ - ['杏', 'あんず', 'アンズ']
10
+ - ['莉子', 'りこ', 'リコ']
11
+ - ['美羽', 'みう', 'ミウ']
12
+ - ['結菜', 'ゆいな', 'ユイナ']
13
+ - ['心愛', 'ここあ', 'ココア']
14
+ - ['愛菜', 'あいな', 'アイナ']
15
+ - ['美咲', 'みさき', 'ミサキ']
16
+ last_name:
17
+ - ['佐藤', 'さとう', 'サトウ']
18
+ - ['鈴木', 'すずき', 'スズキ']
19
+ - ['高橋', 'たかはし', 'タカハシ']
20
+ - ['田中', 'たなか', 'タナカ']
21
+ - ['渡辺', 'わたなべ', 'ワタナベ']
22
+ - ['伊藤', 'いとう', 'イトウ']
23
+ - ['山本', 'やまもと', 'ヤマモト']
24
+ - ['中村', 'なかむら', 'ナカムラ']
25
+ - ['小林', 'こばやし', 'コバヤシ']
26
+ - ['加藤', 'かとう', 'カトウ']
27
+ - ['吉田', 'よしだ', 'ヨシダ']
28
+ - ['山田', 'やまだ', 'ヤマダ']
29
+ - ['佐々木', 'ささき', 'ササキ']
30
+ - ['山口', 'やまぐち', 'ヤマグチ']
31
+ - ['斎藤', 'さいとう', 'サイトウ']
32
+ - ['松本', 'まつもと', 'マツモト']
33
+ - ['井上', 'いのうえ', 'イノウエ']
34
+ - ['木村', 'きむら', 'キムラ']
35
+ - ['林', 'はやし', 'ハヤシ']
36
+ - ['清水', 'しみず', 'シミズ']
@@ -0,0 +1,92 @@
1
+ require "gimei/version"
2
+ require 'yaml'
3
+
4
+ class Gimei
5
+ NAMES = YAML.load_file(File.expand_path(File.join('..', 'data', 'names.yml'), __FILE__))
6
+
7
+ class First
8
+ def initialize
9
+ @name = NAMES['first_name'].sample
10
+ end
11
+
12
+ def kanji
13
+ @name[0]
14
+ end
15
+
16
+ def hiragana
17
+ @name[1]
18
+ end
19
+
20
+ def katakana
21
+ @name[2]
22
+ end
23
+ end
24
+
25
+ class Last
26
+ def initialize
27
+ @name = NAMES['last_name'].sample
28
+ end
29
+
30
+ def kanji
31
+ @name[0]
32
+ end
33
+
34
+ def hiragana
35
+ @name[1]
36
+ end
37
+
38
+ def katakana
39
+ @name[2]
40
+ end
41
+ end
42
+
43
+ def initialize
44
+ @first = First.new
45
+ @last = Last.new
46
+ end
47
+
48
+ def kanji
49
+ "#{last.kanji} #{first.kanji}"
50
+ end
51
+
52
+ def hiragana
53
+ "#{last.hiragana} #{first.hiragana}"
54
+ end
55
+
56
+ def katakana
57
+ "#{last.katakana} #{first.katakana}"
58
+ end
59
+
60
+ def first
61
+ @first
62
+ end
63
+
64
+ def last
65
+ @last
66
+ end
67
+
68
+ class << self
69
+ def kanji
70
+ name = new
71
+ "#{name.last.kanji} #{name.first.kanji}"
72
+ end
73
+
74
+ def hiragana
75
+ name = new
76
+ "#{name.last.hiragana} #{name.first.hiragana}"
77
+ end
78
+
79
+ def katakana
80
+ name = new
81
+ "#{name.last.katakana} #{name.first.katakana}"
82
+ end
83
+
84
+ def first
85
+ new.first
86
+ end
87
+
88
+ def last
89
+ new.last
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,3 @@
1
+ class Gimei
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,69 @@
1
+ # -*- coding: utf-8 -*-
2
+ require_relative 'spec_helper'
3
+
4
+ describe Gimei do
5
+ before { @name = Gimei.new }
6
+
7
+ describe '#kanji' do
8
+ it '全角文字とスペースが返ること' do
9
+ @name.kanji.must_match /\A[#{Moji.zen}\s]+\z/
10
+ end
11
+ end
12
+
13
+ describe '#hiragana' do
14
+ it 'ひらがなとスペースが返ること' do
15
+ @name.hiragana.must_match /\A[\p{hiragana}\s]+\z/
16
+ end
17
+ end
18
+
19
+ describe '#katakana' do
20
+ it 'カタカナとスペースが返ること' do
21
+ @name.katakana.must_match /\A[\p{katakana}\s]+\z/
22
+ end
23
+ end
24
+ end
25
+
26
+ describe Gimei::First do
27
+ before { @name = Gimei::First.new }
28
+
29
+ describe '#kanji' do
30
+ it '全角文字が返ること' do
31
+ @name.kanji.must_match /\A#{Moji.zen}+\z/
32
+ end
33
+ end
34
+
35
+ describe '#hiragana' do
36
+ it 'ひらがなが返ること' do
37
+ @name.hiragana.must_match /\A\p{hiragana}+\z/
38
+ end
39
+ end
40
+
41
+ describe '#katakana' do
42
+ it 'カタカナが返ること' do
43
+ @name.katakana.must_match /\A\p{katakana}+\z/
44
+ end
45
+ end
46
+ end
47
+
48
+ describe Gimei::Last do
49
+ before { @name = Gimei::Last.new }
50
+
51
+ describe '#kanji' do
52
+ it '全角文字が返ること' do
53
+ @name.kanji.must_match /\A#{Moji.zen}+\z/
54
+ end
55
+ end
56
+
57
+ describe '#hiragana' do
58
+ it 'ひらがなが返ること' do
59
+ @name.hiragana.must_match /\A\p{hiragana}+\z/
60
+ end
61
+ end
62
+
63
+ describe '#katakana' do
64
+ it 'カタカナが返ること' do
65
+ @name.katakana.must_match /\A\p{katakana}+\z/
66
+ end
67
+ end
68
+ end
69
+
@@ -0,0 +1,8 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'gimei'
5
+
6
+ require 'bundler/setup'
7
+ require 'minitest/autorun'
8
+ require 'moji'
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gimei
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - willnet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: moji
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: random Japanese name generator
56
+ email:
57
+ - netwillnet@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - gimei.gemspec
69
+ - lib/data/names.yml
70
+ - lib/gimei.rb
71
+ - lib/gimei/version.rb
72
+ - spec/name_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: https://github.com/willnet/gimei
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: random Japanese name generator. support kanji, hiragana, and katakana
97
+ test_files:
98
+ - spec/name_spec.rb
99
+ - spec/spec_helper.rb