chinese_name 0.1.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
+ SHA1:
3
+ metadata.gz: 701aa195a4cd566f1f885ab9e6a7469bda0832e4
4
+ data.tar.gz: f105340986e1a9c61fad8bbe12c8a24fe071ddb3
5
+ SHA512:
6
+ metadata.gz: 118cd853dc0e19a0350a3e12de319e1cf13968f2a886cd12c6c727b51c30aafa3deda19dcf209b5e7153d30db70f266952e0f3fadb60c05c2b656a47c4d0b47c
7
+ data.tar.gz: 9f54bdc9357637549026fe70f4ccea6135293fa7caa5ef3bed44c2147e2e0da10599065d89f480c92e774f69dc86b42509478aafc887032c5f91312eb2f8bb38
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chinese_name.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # ChineseName
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/chinese_name`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'chinese_name'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install chinese_name
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ require 'chinese_name'
27
+
28
+ 2.4.0 :001 > g = ChineseName.generate
29
+ => #<ChineseName:0x007feed28f8220 @last_name="陈", @first_name="艺天", @full_name="陈艺天">
30
+ 2.4.0 :002 > g.last_name
31
+ => "陈"
32
+ 2.4.0 :003 > g.first_name
33
+ => "艺天"
34
+ 2.4.0 :004 > g.full_name
35
+ => "陈艺天"
36
+ 2.4.0 :005 > g.to_s
37
+ => "陈艺天"
38
+ 2.4.0 :006 > "#{g}"
39
+ => "陈艺天"
40
+ ```
41
+
42
+ ## Development
43
+
44
+ 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.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/graysonchen/chinese_name.
51
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "chinese_name"
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,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chinese_name/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chinese_name"
8
+ spec.version = ChineseName::VERSION
9
+ spec.authors = ["Grayson Chen"]
10
+ spec.email = ["cgg5207@sina.com"]
11
+
12
+ spec.summary = %q{Generate a Random Chinese Name}
13
+ spec.description = %q{Generate a Random Chinese Name.}
14
+ spec.homepage = "https://github.com/graysonchen/chinese_name"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.14"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "pry"
35
+ end
@@ -0,0 +1,434 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ 单于
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ 淳于
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+ 东方
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ 公孙
90
+ 公羊
91
+ 公冶
92
+
93
+
94
+
95
+
96
+
97
+
98
+ 广
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ 赫连
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ 怀
122
+
123
+
124
+ 皇甫
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ 令狐
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+ 万俟
215
+
216
+
217
+
218
+ 慕容
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+ 欧阳
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+ 濮阳
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+ 上官
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+ 申屠
283
+
284
+
285
+
286
+
287
+
288
+
289
+ 寿
290
+
291
+
292
+
293
+
294
+
295
+
296
+ 司空
297
+ 司马
298
+ 司徒
299
+
300
+
301
+
302
+ 宿
303
+
304
+
305
+
306
+ 太叔
307
+
308
+
309
+ 澹台
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+ 闻人
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+ 夏侯
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+ 徐离
361
+
362
+ 轩辕
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+ 羿
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+ 尉迟
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+ 宇文
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+ 长孙
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+ 仲孙
420
+
421
+ 诸葛
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+ 宗政
432
+
433
+
434
+
@@ -0,0 +1,3 @@
1
+ class ChineseName
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,50 @@
1
+ require "chinese_name/version"
2
+
3
+ class ChineseName
4
+ LAST_NAME_DATA = 'last_name.dat'.freeze
5
+
6
+ attr_reader :full_name, :first_name, :last_name
7
+
8
+ class << self
9
+ def generate
10
+ new
11
+ end
12
+ alias_method :g, :generate
13
+ end
14
+
15
+ def initialize
16
+ full_name
17
+ self
18
+ end
19
+
20
+ def full_name
21
+ @full_name ||= "#{last_name}#{first_name}"
22
+ end
23
+
24
+ def first_name
25
+ @first_name ||= generate_first_name.join
26
+ end
27
+
28
+ def last_name
29
+ @last_name ||= all_last_name[Random.rand(all_last_name.size)]
30
+ end
31
+
32
+ alias_method :to_s, :full_name
33
+
34
+ private
35
+ attr_writer :all_last_name
36
+
37
+ def generate_first_name
38
+ Random.rand(1..2).times.inject([]) { |arr, val| arr << generate_word }
39
+ end
40
+
41
+ def generate_word
42
+ word = (19968..20901).to_a.sample
43
+ [word.to_s(16)].pack('H*').force_encoding('utf-16be').encode('utf-8')
44
+ end
45
+
46
+ def all_last_name
47
+ filedata = File.dirname(__FILE__) + "/../data/#{LAST_NAME_DATA}"
48
+ IO.foreach(filedata).inject([]){ |arr, line| arr << line.strip }
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chinese_name
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Grayson Chen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
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: Generate a Random Chinese Name.
56
+ email:
57
+ - cgg5207@sina.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - bin/console
67
+ - bin/setup
68
+ - chinese_name.gemspec
69
+ - data/last_name.dat
70
+ - lib/chinese_name.rb
71
+ - lib/chinese_name/version.rb
72
+ homepage: https://github.com/graysonchen/chinese_name
73
+ licenses: []
74
+ metadata:
75
+ allowed_push_host: https://rubygems.org
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.8
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Generate a Random Chinese Name
96
+ test_files: []