zh-lorem 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.8.3"
13
+ end
@@ -0,0 +1,31 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.8.3)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.6.5)
12
+ rake (0.9.2.2)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+ rspec (2.8.0)
16
+ rspec-core (~> 2.8.0)
17
+ rspec-expectations (~> 2.8.0)
18
+ rspec-mocks (~> 2.8.0)
19
+ rspec-core (2.8.0)
20
+ rspec-expectations (2.8.0)
21
+ diff-lcs (~> 1.1.2)
22
+ rspec-mocks (2.8.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.0.0)
29
+ jeweler (~> 1.8.3)
30
+ rdoc (~> 3.12)
31
+ rspec (~> 2.8.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Kang-min Liu
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ = zh-lorem
2
+
3
+ This rubygem is a re-imelpmentation of MoreText lipsum service provided by
4
+ Handlino Inc. See more at http://more.handlino.com/.
5
+
6
+ To use it, you `include ZhLorem::Helpers` in your code to include the following methods:
7
+
8
+ * zh_lorem_name
9
+ * zh_lorem_name_pinyin
10
+ * zh_lorem_first_name
11
+ * zh_lorem_first_name_pinyin
12
+ * zh_lorem_last_name
13
+ * zh_lorem_last_name_pinyin
14
+ * zh_lorem_email
15
+ * zh_lorem_word
16
+ * zh_lorem_words(n)
17
+ * zh_lorem_sentence
18
+ * zh_lorem_sentences(n)
19
+ * zh_lorem_paragraph
20
+ * zh_lorem_paragraphs(n)
21
+
22
+ Methods named in plural form requires one numerical argument, others requires no
23
+ arguments.
24
+
25
+ Alternatively, you may invoke methods on `ZhLorem` class, or its instance. The following
26
+ statements are taking the same action:
27
+
28
+ puts zh_lorem_sentence
29
+ puts ZhLorem.sentence
30
+ puts ZhLorem.new.sentence
31
+
32
+
33
+ All methods takes an optional replacement argument at the end of argument list.
34
+ The replacement is a String, which is the return value when provided.
35
+
36
+ That is:
37
+
38
+ puts zh_lorem_name("Wutang") #=> "Wutang"
39
+
40
+ This can be helpful when you need some tweaking.
41
+
42
+
43
+ == Contributing to zh-lorem
44
+
45
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
46
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
47
+ * Fork the project.
48
+ * Start a feature/bugfix branch.
49
+ * Commit and push until you are happy with your contribution.
50
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
51
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
52
+
53
+ == Copyright
54
+
55
+ Copyright (c) 2012 Kang-min Liu. See LICENSE.txt for
56
+ further details.
57
+
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "zh-lorem"
18
+ gem.homepage = "http://github.com/gugod/zh-lorem"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Chinese lorem ipsum text generator}
21
+ gem.description = %Q{Chinese lorem ipsum text generator}
22
+ gem.email = "gugod@gugod.org"
23
+ gem.authors = ["Kang-min Liu"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "zh-lorem #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,165 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Author:: Kang-min Liu (http://gugod.org)
4
+ # Copyright:: Copyright (c) 2012 Kang-min Liu
5
+ # License:: MIT
6
+ # Contributors:: https://github.com/gugod/zh-lorem/contributors
7
+ #
8
+
9
+ class ZhLorem
10
+ module Helpers
11
+ # Returns a random Chinese name.
12
+ def zh_lorem_name(replacement = nil)
13
+ if replacement
14
+ replacement
15
+ else
16
+ zh_lorem_last_name + zh_lorem_first_name
17
+ end
18
+ end
19
+
20
+ # Returns a random Chinese name in pinyin form
21
+ def zh_lorem_name_pinyin(replacement = nil)
22
+ if replacement
23
+ return replacement
24
+ end
25
+
26
+ return zh_lorem_first_name_pinyin + " " + zh_lorem_last_name_pinyin
27
+ end
28
+
29
+ # Returns a random Chinese firstname
30
+ def zh_lorem_first_name(replacement = nil)
31
+ if replacement
32
+ return replacement
33
+ end
34
+
35
+ x = %w[世 中 仁 伶 佩 佳 俊 信 倫 偉 傑 儀 元 冠 凱 君 哲 嘉 國 士 如 娟 婷 子 孟 宇 安 宏 宗 宜 家 建 弘 強 彥 彬 德 心 志 忠 怡 惠 慧 慶 憲 成 政 敏 文 昌 明 智 曉 柏 榮 欣 正 民 永 淑 玉 玲 珊 珍 珮 琪 瑋 瑜 瑞 瑩 盈 真 祥 秀 秋 穎 立 維 美 翔 翰 聖 育 良 芬 芳 英 菁 華 萍 蓉 裕 豪 貞 賢 郁 鈴 銘 雅 雯 霖 青 靜 韻 鴻 麗 龍]
36
+ return x[rand(x.size)] + (rand(2) == 0 ? "" : x[rand(x.size)])
37
+ end
38
+
39
+ # Returns a random Chinese firstname in pinyin form
40
+ def zh_lorem_first_name_pinyin(replacement = nil)
41
+ if replacement
42
+ return replacement
43
+ end
44
+ x = %w[Lee Wang Chang Liu Cheng Yang Huang Zhao Zho Wu Schee Sun Zhu Ma Hu Guo Lin Ho Kao Liang Zheng Luo Sung Hsieh Tang Han Cao Xu Deng Xiao Feng Tseng Tsai Peng Pan Yuan Yu Tong Su Ye Lu Wei Jiang Tian Tu Ting Shen Jiang Fan Fu Zhong Lu Wang Dai Cui Ren Liao Yiao Fang Jin Qiu Xia Jia Chu Shi Xiong Meng Qin Yan Xue Ho Lei Bai Long Duan Hao Kong Shao Shi Mao Wan Gu Lai Kang He Yi Qian Niu Hung Gung]
45
+
46
+ return x[rand(x.size)] + (rand(2) == 0 ? "" : x[rand(x.size)].downcase)
47
+ end
48
+
49
+ # Returns a random Chinese lastname.
50
+ def zh_lorem_last_name(replacement = nil)
51
+ if replacement
52
+ return replacement
53
+ end
54
+
55
+ x = %w[李 王 張 劉 陳 楊 黃 趙 周 吳 徐 孫 朱 馬 胡 郭 林 何 高 梁 鄭 羅 宋 謝 唐 韓 曹 許 鄧 蕭 馮 曾 程 蔡 彭 潘 袁 於 董 餘 蘇 葉 呂 魏 蔣 田 杜 丁 沈 姜 範 江 傅 鐘 盧 汪 戴 崔 任 陸 廖 姚 方 金 邱 夏 譚 韋 賈 鄒 石 熊 孟 秦 閻 薛 侯 雷 白 龍 段 郝 孔 邵 史 毛 常 萬 顧 賴 武 康 賀 嚴 尹 錢 施 牛 洪 龔]
56
+ return x[rand(x.size)]
57
+ end
58
+
59
+ # Returns a ranodm Chinese lastname in pinyin form
60
+ def zh_lorem_last_name_pinyin(replacement = nil)
61
+ if replacement
62
+ return replacement
63
+ end
64
+
65
+ x = %w[Li Wang Zhang Liu Chen Yang Huang Zhao Zhou Wu Xu Sun Zhu Ma Hu Guo Lin He Gao Liang Zheng Luo Song Xie Tang Han Cao Deng Xiao Feng Ceng Cheng Cai Peng Pan Yuan Dong Yu Su She Lu: Wei Jiang Tian Du Ding Chen/shen Fan Fu Zhong Lu Dai Cui Ren Liao Yao Fang Jin Qiu Jia Tan Gu Zou Dan Xiong Meng Qin Yan Xue Hou Lei Bai Long Duan Hao Kong Shao Shi Mao Chang Wan Lai Kang Yin Qian Niu Hong Gong]
66
+ return x[rand(x.size)]
67
+ end
68
+
69
+ # Returs a random email based on Chinese names
70
+ def zh_lorem_email(replacement = nil)
71
+ if replacement
72
+ return replacement
73
+ end
74
+
75
+ delimiters = [ '_', '-', '' ]
76
+ domains = %w(gmail.com yahoo.com.tw mail2000.com.tw mac.com example.com.tw ms42.hinet.net mail.notu.edu.tw)
77
+ username = zh_lorem_first_name_pinyin + zh_lorem_last_name_pinyin
78
+ return "#{username}@#{domains[rand(domains.size)]}".downcase
79
+ end
80
+
81
+ SENTENCES = [["一個有年紀的人,","一個較大的孩子說,","一到夜裡,","一到過年,","一勺冰水,","一夜的花費,","一婦人說,","一寸光陰一寸金,","一年的設定,","一時看鬧熱的人,","一箇來往的禮節,","一絲絲涼爽秋風,","一綵綵霜痕,","一邊的行列,","一陣吶喊的聲浪,","一顆銀亮亮的月球,","一類的試筆詩,","下半天的談判,","不問是誰,","不懷著危險的恐懼,","不斷地逝去,","不是容易就能奏功,","不是有學士有委員,","不是皆發了幾十萬,","不曉得我的目的,","不曉得誰創造的,","不曉得順這機會,","不用摸索,","不知是兄哥或小弟,","不知行有多少時刻,","不知談論些什麼,","不聲不響地,","不股慄不內怯,","不能成功,","不能隨即回家,","不要爭一爭氣,","不論什麼階級的人,","不讓星星的光明,","不趕他出去,","不遇著危險,","不過隨意做作而已,","不顧慮傍人,","且新正閒著的時候,","丙喝一喝茶,","丙論辯似的說,","丙驚疑地問,","乙感嘆地說,","乙接著嘴說,","也不知什麼是方向,","也因為地面的崎嶇,","也就不容易,","也就便宜,","也就分外著急,","也是不受後母教訓,","也是不容易,","也是經驗不到,","也有他們一種曆,","互有參差,","互相信賴,","互相提攜而前進,","互相提攜,","亦都出去了,","人們不預承認,","人們多不自量,","人們怎地在心境上,","人們的信仰,","什麼樣子,","他不和人家分擔,","他倆不想到休息,","他倆人中的一個,","他倆便也攜著手,","他倆感到有一種,","他倆本無分別所行,","他倆疲倦了,","他們偏不採用,","他們在平時,","他叩了不少下頭,","他的伴侶,","他說人們是在發狂,","他那麼盡力,","他高興的時候,","以樂其心志,","任便人家笑罵,","似也有稍遲緩,","似報知人們,","似皆出門去了,","但在手面趁吃人,","但現在的曆法,","但這是所謂大勢,","住在福戶內的人,","何故世上的人類們,","併也不見陶醉,","使勞者們,","使成粉末,","來浪費有用的金錢,","便說這卑怯的生命,","保不定不鬧出事來,","借著拜年的名目,","做事業的人們,","偷得空間,","傳播到廣大空間去,","像日本未來的時,","像這樣子鬧下去,","兄弟們到這樣時候,","先先後後,","光明已在前頭,","全數花掉,","典衫當被,","再回到現實世界,","再鬧下去,","別地方是什麼樣子,","到大街上玩去罷,","刺腳的荊棘,","剛纔經市長一說,","務使春風吹來,","包圍住這人世間,","十五年前的熱鬧,","卻不能稍超興奮,","卻自甘心著,","又有不可得的快樂,","又有人不平地說,","只些婦女們,","只在我們貴地,","只是前進,","只有乘這履端初吉,","只有前進,","只有風先生的慇懃,","只殘存些婦女小兒,","可以借它的魔力,","各個兒指手畫腳,","各要爭個體面,","同在這顆地球上,","向面的所向,","呻呻吟吟,","和其哀情,","和別的其餘的一日,","和狺狺的狗吠,","和純真的孩童們,","和電柱上路燈,","四城門的競爭,","四方雲集,","因一邊還都屬孩子,","因為一片暗黑,","因為市街的鬧熱日,","因為所規定的過年,","因為空間的黑暗,","因為這是親戚間,","團團地坐著,","在一個晚上,","在一處的客廳裡,","在一邊誘惑我,","在他們社會裡,","在以前任怎地追憶,","在做頭老的,","在冷靜的街尾,","在冷風中戰慄著,","在和他們同一境遇,","在幾千年前,","在成堆的人們中,","在我回憶裡,","在我的知識程度裡,","在煙縷繚繞的中間,","在環繞太陽運轉,","在這時候,","在這樣黑暗之下,","在這次血祭壇上,","在這黑暗之中,","在這黑暗統治之下,","地方自治的權能,","地球繞著太陽,","多亂惱惱地熱鬧著,","天體的現象嗎,","失了伴侶的他,","奉行正朔,","好久已無聲響的雷,","媽祖的靈應,","孩子們回答著,","孩子們得到指示,","孩子們的事,","孩子們辯說,","孩子般的眼光,","完全不同日子,","完全打消了,","家門有興騰的氣象,","富豪是先天所賦與,","實在也就難怪,","實在可憐可恨,","將腦髓裡驅逐,","小子不長進,","少年已去金難得,","就一味地吶喊著,","就可觸到金錢,","就是那些文人韻士,","就發達繁昌起來,","就說不關什麼,","居然宣佈了戰爭,","已不成功了,","已經準備下,","已經財散人亡,","已闢農場已築家室,","平生慣愛咬文嚼字,","店舖簷前的天燈,","張開他得意的大口,","強盛到肉體的增長,","得了新的刺激,","心裡不懷抱驚恐,","忘卻了溪和水,","忘記他的伴侶,","快樂的追求,","忽然地顛蹶,","忽起眩暈,","怕大家都記不起了,","思想也漸糢糊起來,","恍惚有這呼聲,","悠揚地幾聲洞簫,","想因為腳有些疲軟,","愈會賺錢,","愈要追尋快樂,","愈覺得金錢的寶貴,","意外地竟得生存,","慢慢地說,","憑我們有這一身,","我不明白,","我們是在空地上,","我們有這雙腕,","我們處在這樣環境,","我在兒童時代,","我的意見,","我記得還似昨天,","所以也不擔心到,","所以家裡市上,","所以窮的人,","所以這一回,","所以那邊的街市,","所有一切,","所有無謂的損失,","所謂雪恥的競爭,","所謂風家也者,","手一插進衣袋,","把她清冷冷的光輝,","抵當賓客的使費,","抹著一縷兩縷白雲,","拔去了不少,","捧出滿腔誠意,","接著又說,","接連鬥過兩三晚,","握著有很大權威,","揭破死一般的重幕,","擋不住大的拳頭,","放下茶杯,","放不少鞭炮,","放射到地平線以外,","救死且沒有工夫,","新年的一日,","旗鼓的行列,","既不能把它倆,","日頭是自東徂西,","早幾點鐘解決,","春五正月,","昨晚曾賜過觀覽,","是不容有異議,","是抱著滿腹的憤氣,","是社會的一成員,","是道路或非道路,","是黑暗的晚上,","時間的進行,","暗黑的氣氛,","有一陣孩子們,","有什麼科派捐募,","有時再往親戚家去,","有最古的文明,","有的孩子喊著,","未嘗有人敢自看輕,","某某和某等,","樹要樹皮人要麵皮,","橋柱是否有傾斜,","橋梁是否有斷折,","正可養成競爭心,","死鴨子的嘴吧,","比較兒童時代,","汝算不到,","沒有年歲,","波湧似的,","泰然前進,","溪的廣闊,","溺人的水窪,","滾到了天半,","漸被遮蔽,","濛迷地濃結起來,","無奈群眾的心裡,","熱血正在沸騰,","燈火星星地,","現在不高興了,","現在只有覺悟,","現在想沒得再一個,","現在的我,","生性如此,","生的糧食儘管豐富,","由我的生的行程中,","由深藍色的山頭,","由著裊裊的晚風,","由隘巷中走出來,","甲微喟的說,","甲憤憤地罵,","甲興奮地說,","略一對比,","當科白尼還未出世,","看我們現在,","看見有幾次的變遷,","看見鮮紅的血,","眩眼一縷的光明,","礙步的石頭,","福戶內的事,","禮義之邦的中國,","究竟為的是什麼,","笑掉了齒牙,","第一浮上我的思想,","筋肉比較的瘦弱,","籠罩著街上的煙,","精神上多有些緊張,","約同不平者的聲援,","統我的一生到現在,","經過了很久,","經過幾許途程,","經驗過似的鄭重說,","繞著亭仔腳柱,","纔見有些白光,","美惡竟不會分別,","老人感慨地說,","聽說市長和郡長,","聽說有人在講和,","聽說路關鐘鼓,","能夠合官廳的意思,","自己走出家來,","自鳴得意,","花去了幾千塊,","花各人自己的錢,","若會賺錢,","草繩上插的香條,","蔥惶回顧,","行動上也有些忙碌,","行行前進,","街上看鬧熱的人,","街上還是鬧熱,","街上頓添一種活氣,","被他們欺負了,","被另一邊阻撓著,","被風的歌唱所鼓勵,","要損他一文,","要是說一聲不肯,","要趁節氣,","親戚們多贊稱我,","覺得分外悠遠,","觸進人們的肌膚,","試把這箇假定廢掉,","說了不少好話,","說什麼爭氣,","說我乖巧識禮,","說是沒有法子的事,","誰都有義務分擔,","議論已失去了熱烈,","讓他獨自一個,","走過了一段里程,","身量雖然較高,","輕輕放棄,","輾轉運行,","農民播種犁田,","透過了衣衫,","這一句千古名言,","這一點不能明白,","這些談論的人,","這回在奔走的人,","這天大的奇變,","這幾聲呼喊,","這澎湃聲中,","這說是野蠻的慣習,","這邊門口幾人,","通溶化在月光裡,","連哼的一聲亦不敢,","連生意本,","進來的人說,","遂亦不受到阻礙,","遂有人出來阻擋,","過了些時,","過年種種的預備,","還是孱弱的可憐,","還有閒時間,","那三種曆法,","那不知去處的前途,","那些富家人,","那時代的一年,","那更不成問題,","那末地球運行最初,","那邊亭仔腳幾人,","那邊有些人,","都很讚成,","金錢愈不能到手,","金錢的問題,","金錢的慾念,","銅鑼響亮地敲起來,","錢的可能性愈少,","鑼的響聲,","鑼聲亦不響了,","阻斷爭論,","除廢掉舊曆,","陷人的泥澤,","雖亦有人反對,","雖則不知,","雖受過欺負,","雖未見到結論,","雖遇有些顛蹶,","雨太太的好意,","音響的餘波,","風雨又調和著節奏,","驟然受到光的刺激,","體軀支持不住了,","鬧熱到了,","鬧過別一邊去,"],["一層層堆聚起來。","不停地前進。","不可讓他佔便宜。","不教臉紅而已。","不知橫亙到何處。","丙可憐似的說。","也須為著子孫鬥爭。","互相提攜走向前去。","亦不算壞。","人類的一分子了。","今夜是明月的良宵。","他正在發瘋呢。","何用自作麻煩。","何須非議。","便把眼皮睜開。","兩方就各答應了。","再鬧一回亦好。","分辨出浩蕩的溪聲。","卻自奉行唯謹。","又一人說。","和他們做新過年。","和鍛鍊團結力。","因為不高興了。","在表示著歡迎。","在閃爍地放亮。","地方領導人。","坐著閒談。","多有一百倍以上。","奏起悲壯的進行曲。","嬉嬉譁譁地跑去了。","將要千圓。","導發反抗力的火戰。","就再開始。","就和解去。","就在明后兩天。","就是金錢。","已像將到黎明之前。","已無暇計較。","忘卻了一切。","怎麼就十五年了。","愈會碰著痛苦。","我去拿一面鑼來。","捲下中街去。","是算不上什麼。","有些多事的人問。","有人詰責似的問。","本來是橫逆不過的。","本該挨罵。","漏射到地上。","為著前進而前進。","甲哈哈地笑著說。","甲總不平地罵。","看看又要到了。","眼睛已失了作用。","神所厭棄本無價值。","移動自己的腳步。","終也渡過彼岸。","終是不可解的疑問。","繞來穿去。","繼續他們的行程。","老人懷疑地問。","街上實在繁榮極了。","街上的孩子們在喊。","被逐的前人之子。","說得很高興似的。","這原因就不容妄測。","運行了一個週環。","那就....。","那痛苦就更難堪了。","那邊比較鬧熱。","險些兒跌倒。","黃金難買少年心。"],["一樣是歹命人!","但是這一番啊!","來--來!","來和他們一拚!","值得說什麼爭麵皮!","兄弟們來!","到城裡去啊!","又受了他們一頓罵!","和他們一拚!","實在想不到!","憑這一身!","憑這雙腕!","我要頂禮他啊!","把我們龍頭割去!","捨此一身和他一拚!","明夜沒得再看啦!","歲月真容易過!","比狗還輸!","無目的地前進!","甘失掉了麵皮!","盲目地前進!","老不死的混蛋!","趕快走下山去!","這是如何地悲悽!","這是如何的決意!","那纔利害啦!"]]
82
+
83
+ # Return one Chinese word (character)
84
+ def zh_lorem_word(replacement = nil)
85
+ zh_lorem_words(1, replacement)
86
+ end
87
+
88
+ # Return the required amount of words
89
+ def zh_lorem_words(total, replacement = nil)
90
+ s = []
91
+ while (s.length < total)
92
+ x = random_one(SENTENCES[ rand(3) ])
93
+ s << random_one(x.split(//u)[0..-2])
94
+ end
95
+ return s.join("")
96
+ end
97
+
98
+ # Return exactly one sentence
99
+ def zh_lorem_sentence(replacement = nil)
100
+ if replacement
101
+ return replacement
102
+ end
103
+
104
+ out = ""
105
+ while(rand(2) == 1)
106
+ out += random_one(SENTENCES[0])
107
+ end
108
+ out += random_one(SENTENCES[1+rand(2)])
109
+ end
110
+
111
+ # Return the required amount of sentences
112
+ def zh_lorem_sentences(total, replacement = nil)
113
+ out = ""
114
+ (1..total).map { zh_lorem_sentence(replacement) }.join("")
115
+ end
116
+
117
+ # Return exactly one paragraph of Chinese text
118
+ def zh_lorem_paragraph(replacement = nil)
119
+ if replacement
120
+ return replacement
121
+ end
122
+
123
+ return zh_lorem_paragraphs(1, replacement)
124
+ end
125
+
126
+ # Return the required amount of paragraphs of Chinese text, seperated by \n\n
127
+ def zh_lorem_paragraphs(total, replacement = nil)
128
+ if replacement
129
+ return replacement
130
+ end
131
+
132
+ (1..total).map do
133
+ zh_lorem_sentences(random_one(3..7), replacement)
134
+ end.join("\n\n")
135
+ end
136
+
137
+ private
138
+
139
+ def random_one(arr)
140
+ return arr.to_a[ rand(arr.to_a.size) ]
141
+ end
142
+ end
143
+
144
+ class << self
145
+ include Helpers
146
+
147
+ alias :name :zh_lorem_name
148
+ alias :name_pinyin :zh_lorem_name_pinyin
149
+ alias :first_name :zh_lorem_first_name
150
+ alias :first_name_pinyin :zh_lorem_first_name_pinyin
151
+ alias :last_name :zh_lorem_last_name
152
+ alias :last_name_pinyin :zh_lorem_last_name_pinyin
153
+ alias :email :zh_lorem_email
154
+ alias :word :zh_lorem_word
155
+ alias :words :zh_lorem_words
156
+ alias :sentence :zh_lorem_sentence
157
+ alias :sentences :zh_lorem_sentences
158
+ alias :paragraph :zh_lorem_paragraph
159
+ alias :paragraphs :zh_lorem_paragraphs
160
+ end
161
+
162
+ def method_missing(m, *args)
163
+ ZhLorem.send(m, *args)
164
+ end
165
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'zh-lorem'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "ZhLorem" do
4
+ it "has instance methods" do
5
+ o = ZhLorem.new
6
+ s = o.sentence
7
+ s.should_not be_nil
8
+ end
9
+
10
+ it "has class methods" do
11
+ s = ZhLorem.sentence
12
+ s.should_not be_nil
13
+ end
14
+ end
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "zh-lorem"
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kang-min Liu"]
12
+ s.date = "2012-03-16"
13
+ s.description = "Chinese lorem ipsum text generator"
14
+ s.email = "gugod@gugod.org"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/zh-lorem.rb",
29
+ "spec/spec_helper.rb",
30
+ "spec/zh-lorem_spec.rb",
31
+ "zh-lorem.gemspec"
32
+ ]
33
+ s.homepage = "http://github.com/gugod/zh-lorem"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.16"
37
+ s.summary = "Chinese lorem ipsum text generator"
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
44
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
45
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
46
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
47
+ else
48
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
49
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
55
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
58
+ end
59
+ end
60
+
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zh-lorem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kang-min Liu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70226235113880 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.8.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70226235113880
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &70226235137300 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.12'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70226235137300
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70226235131820 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70226235131820
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &70226235143120 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70226235143120
58
+ description: Chinese lorem ipsum text generator
59
+ email: gugod@gugod.org
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - LICENSE.txt
64
+ - README.rdoc
65
+ files:
66
+ - .document
67
+ - .rspec
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.rdoc
72
+ - Rakefile
73
+ - VERSION
74
+ - lib/zh-lorem.rb
75
+ - spec/spec_helper.rb
76
+ - spec/zh-lorem_spec.rb
77
+ - zh-lorem.gemspec
78
+ homepage: http://github.com/gugod/zh-lorem
79
+ licenses:
80
+ - MIT
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ segments:
92
+ - 0
93
+ hash: -2601251075862993401
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.16
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Chinese lorem ipsum text generator
106
+ test_files: []