chinese_name 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/bin/rand_chinese_name +6 -0
- data/lib/chinese_name.rb +11 -4
- data/lib/chinese_name/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a039ded39317622f9783839f83e12e162c9b9132
|
4
|
+
data.tar.gz: 77338af02a11908b56ea4439c49b6a1d42dbcc43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04e7846815bd8450924c734639810af31b0d58000974392a72838b7856c3cac38693c0d7a119a247f3412b6219c55d5b75144e788ef721a44eddab6dffe6a698
|
7
|
+
data.tar.gz: b4927e478e8a95265ab4551b76664becfbf3d6ac4c5166532b6d8195476726253e35e0c7cbedec097ee404e2b474c429575b4102b2c2b26a9d4c64fdf5fb67d6
|
data/README.md
CHANGED
@@ -39,6 +39,14 @@ require 'chinese_name'
|
|
39
39
|
=> "陈艺天"
|
40
40
|
```
|
41
41
|
|
42
|
+
by command line
|
43
|
+
|
44
|
+
```
|
45
|
+
$ rand_chinese_name
|
46
|
+
雷严乒
|
47
|
+
```
|
48
|
+
|
49
|
+
|
42
50
|
## Development
|
43
51
|
|
44
52
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/chinese_name.rb
CHANGED
@@ -26,13 +26,12 @@ class ChineseName
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def last_name
|
29
|
-
@last_name ||=
|
29
|
+
@last_name ||= generate_last_name
|
30
30
|
end
|
31
31
|
|
32
32
|
alias_method :to_s, :full_name
|
33
33
|
|
34
34
|
private
|
35
|
-
attr_writer :all_last_name
|
36
35
|
|
37
36
|
def generate_first_name
|
38
37
|
Random.rand(1..2).times.inject([]) { |arr, val| arr << generate_word }
|
@@ -43,8 +42,16 @@ class ChineseName
|
|
43
42
|
[word.to_s(16)].pack('H*').force_encoding('utf-16be').encode('utf-8')
|
44
43
|
end
|
45
44
|
|
45
|
+
def generate_last_name
|
46
|
+
rand_name = all_last_name
|
47
|
+
rand_name[Random.rand(rand_name.size)]
|
48
|
+
end
|
49
|
+
|
46
50
|
def all_last_name
|
47
|
-
|
48
|
-
|
51
|
+
IO.foreach(file_data).inject([]) { |arr, line| arr << line.strip }
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_data
|
55
|
+
File.dirname(__FILE__) + "/../data/#{LAST_NAME_DATA}"
|
49
56
|
end
|
50
57
|
end
|
data/lib/chinese_name/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chinese_name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grayson Chen
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
66
|
- bin/console
|
67
|
+
- bin/rand_chinese_name
|
67
68
|
- bin/setup
|
68
69
|
- chinese_name.gemspec
|
69
70
|
- data/last_name.dat
|