laowaihua 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lao_wai_hua.rb +11 -10
- metadata +23 -38
data/lib/lao_wai_hua.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
module LaoWaiHua
|
2
|
-
|
3
|
+
|
3
4
|
WORDS = %w(
|
4
5
|
一 位 爷 爷 他 姓 顾 ,
|
5
6
|
上 街 打 醋 又 买 布 。
|
@@ -8,15 +9,15 @@ module LaoWaiHua
|
|
8
9
|
放 下 布 , 搁 下 醋 ,
|
9
10
|
上 前 去 追 鹰 和 兔 ,
|
10
11
|
飞 了 鹰 , 跑 了 兔 。
|
11
|
-
打 翻 醋 , 醋 湿 布
|
12
|
+
打 翻 醋 , 醋 湿 布
|
12
13
|
)
|
13
|
-
|
14
|
+
|
14
15
|
PUNCTUATION = %w( , 。 )
|
15
|
-
|
16
|
+
|
16
17
|
WORDS_WITHOUT_PUNCTUATION = WORDS.select{|word| !PUNCTUATION.include?(word)}
|
17
|
-
|
18
|
+
|
18
19
|
class << self
|
19
|
-
|
20
|
+
|
20
21
|
# return a string of *length* taken from the provided tongue twister
|
21
22
|
# defaults to the full length of the text
|
22
23
|
def generate(length=WORDS.length)
|
@@ -31,12 +32,12 @@ module LaoWaiHua
|
|
31
32
|
def random_word()
|
32
33
|
WORDS_WITHOUT_PUNCTUATION[rand(WORDS_WITHOUT_PUNCTUATION.length)]
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
# return a string or random words of the provided *length*
|
36
37
|
def random(length)
|
37
38
|
words = []
|
38
39
|
next_punctuation = nil
|
39
|
-
|
40
|
+
|
40
41
|
1.upto(length) do
|
41
42
|
next_punctuation ||= rand(3)+2
|
42
43
|
if next_punctuation == 0
|
@@ -49,9 +50,9 @@ module LaoWaiHua
|
|
49
50
|
end
|
50
51
|
words.join("")
|
51
52
|
end
|
52
|
-
|
53
|
+
|
53
54
|
protected
|
54
|
-
|
55
|
+
|
55
56
|
def random_punctuation()
|
56
57
|
PUNCTUATION[rand(PUNCTUATION.length)]
|
57
58
|
end
|
metadata
CHANGED
@@ -1,67 +1,52 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: laowaihua
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Matthew Rudy
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-04-25 00:00:00 +08:00
|
18
|
-
default_executable:
|
12
|
+
date: 2012-04-17 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description:
|
22
15
|
email: matthewrudyjacobs@gmail.com
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
28
19
|
- README
|
29
|
-
files:
|
20
|
+
files:
|
30
21
|
- README
|
31
22
|
- lib/lao_wai_hua/railtie.rb
|
32
23
|
- lib/lao_wai_hua.rb
|
33
24
|
- lib/laowaihua.rb
|
34
25
|
- lib/tasks/lao_wai_hua.rake
|
35
|
-
has_rdoc: true
|
36
26
|
homepage: http://github.com/matthewrudy/laowaihua
|
37
27
|
licenses: []
|
38
|
-
|
39
28
|
post_install_message:
|
40
|
-
rdoc_options:
|
29
|
+
rdoc_options:
|
41
30
|
- --main
|
42
31
|
- README
|
43
|
-
require_paths:
|
32
|
+
require_paths:
|
44
33
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
59
46
|
requirements: []
|
60
|
-
|
61
47
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.
|
48
|
+
rubygems_version: 1.8.17
|
63
49
|
signing_key:
|
64
50
|
specification_version: 3
|
65
51
|
summary: a Lorem Ipsum generator for Chinese
|
66
52
|
test_files: []
|
67
|
-
|