jia 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: 356637b6572c0c062000274f665bfc3f0807515a
4
+ data.tar.gz: da85e4f31d8cbbde8b82dd97080ec791564ae0f9
5
+ SHA512:
6
+ metadata.gz: efbb0f27154e416fdaa3b9fbc7170ed08bfae666011768a243d9a3bf3098b87aaf9f0cd0d01533d7b05fcfc2d7842d4563f0c3845ccb9dd7b1f4ac03ecc33d89
7
+ data.tar.gz: d251413b78d890d569ea216ca5089f63d852cb226948d3c131706196c91ed3939d6c9369f6476b230a422fda14d0a04318b44819df2d960b01831bcdd095ed68
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jia.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jun Lin
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,45 @@
1
+ # Jiǎ (假)
2
+
3
+ A ruby gem for generating random Chinese user data.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jia'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jia
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ fake_user = Jia::User.new
25
+ fake_user.surname #=> '林'
26
+ fake_user.given_name #=> '萌'
27
+ fake_user.full_name #=> '林萌'
28
+ fake_user.email #=> 'xxxx@sohu.com"'
29
+ fake_user.email(safe: true) #=> 'xxxx@example.com"'
30
+ fake_user.phone #=> '15500000000'
31
+ ```
32
+
33
+ ## Note
34
+
35
+ * The surname list comes from http://en.wikipedia.org/wiki/List_of_most_common_surnames_in_Asia
36
+ * The given name list comes from http://en.wikipedia.org/wiki/List_of_most_popular_given_names
37
+ * Phone numbers http://en.wikipedia.org/wiki/Telephone_numbers_in_China
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/[my-github-username]/jia/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jia/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jia"
8
+ spec.version = Jia::VERSION
9
+ spec.authors = ["Jun Lin"]
10
+ spec.email = ["linjunpop@gmail.com"]
11
+ spec.summary = %q{A ruby gem for generating random Chinese user data.}
12
+ spec.description = %q{A ruby gem for generating random Chinese user data.}
13
+ spec.homepage = "https://github.com/linjunpop/jia"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'ruby-pinyin'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "pry"
26
+ end
@@ -0,0 +1,4 @@
1
+ 163.com
2
+ qq.com
3
+ sina.com.cn
4
+ sohu.com
@@ -0,0 +1,37 @@
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
+
@@ -0,0 +1,31 @@
1
+ 133
2
+ 153
3
+ 180
4
+ 181
5
+ 189
6
+ 177
7
+ 130
8
+ 131
9
+ 132
10
+ 155
11
+ 156
12
+ 185
13
+ 186
14
+ 176
15
+ 135
16
+ 136
17
+ 137
18
+ 138
19
+ 139
20
+ 150
21
+ 151
22
+ 152
23
+ 158
24
+ 159
25
+ 182
26
+ 183
27
+ 184
28
+ 157
29
+ 187
30
+ 188
31
+ 178
@@ -0,0 +1,19 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
@@ -0,0 +1,7 @@
1
+ require "jia/version"
2
+
3
+ require 'jia/user'
4
+
5
+ module Jia
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,56 @@
1
+ require 'ruby-pinyin'
2
+ require_relative 'utils'
3
+
4
+ module Jia
5
+ class User
6
+ # Get given name
7
+ #
8
+ # Jia::User.new.given_name # => '萌'
9
+ def given_name
10
+ @given_name ||= Jia::Utils.load_data('given_name').sample
11
+ end
12
+
13
+ # Get surname
14
+ #
15
+ # Jia::User.new.surname # => '林'
16
+ def surname
17
+ @surname ||= Jia::Utils.load_data('surname').sample
18
+ end
19
+
20
+ # Get full name
21
+ #
22
+ # Jia::User.new.full_name # => '林萌'
23
+ def full_name
24
+ "#{surname}#{given_name}"
25
+ end
26
+
27
+ # Get email
28
+ #
29
+ # Jia::User.new.email # => 'lin.meng123@qq.com'
30
+ # Jia::User.new.email(safe: true) # => 'lin.meng123@example.com'
31
+ def email(safe:false)
32
+ @email ||= -> {
33
+ domains = if safe
34
+ ['example.com']
35
+ else
36
+ Jia::Utils.load_data('email_domain')
37
+ end
38
+ account = ::PinYin.of_string(full_name).join('.')
39
+ suffix = rand(999)
40
+ "#{account}#{suffix}@#{domains.sample}"
41
+ }.call
42
+ end
43
+
44
+ # Get phone number
45
+ #
46
+ # Jia::User.new.phone # => '18100000000'
47
+ def phone
48
+ @phone ||= -> {
49
+ mac = Jia::Utils.load_data('phone_mac').sample
50
+ area_code = rand(9999).to_s.center(4, rand(9).to_s)
51
+ user_identifier = rand(9999).to_s.center(4, rand(9).to_s)
52
+ "#{mac}#{area_code}#{user_identifier}"
53
+ }.call
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,15 @@
1
+ require 'yaml'
2
+
3
+ module Jia
4
+ class Utils
5
+ # Read data file
6
+ #
7
+ # load_data('email_domain') # => ['163.com', 'qq.com']
8
+ #
9
+ # Returns data in array
10
+ def self.load_data(name)
11
+ data_file = ::File.expand_path("../../data/#{name}.txt", __FILE__)
12
+ ::File.read(data_file).split("\n")
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Jia
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jun Lin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-pinyin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A ruby gem for generating random Chinese user data.
70
+ email:
71
+ - linjunpop@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - jia.gemspec
82
+ - lib/data/email_domain.txt
83
+ - lib/data/given_name.txt
84
+ - lib/data/phone_mac.txt
85
+ - lib/data/surname.txt
86
+ - lib/jia.rb
87
+ - lib/jia/user.rb
88
+ - lib/jia/utils.rb
89
+ - lib/jia/version.rb
90
+ homepage: https://github.com/linjunpop/jia
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A ruby gem for generating random Chinese user data.
114
+ test_files: []