dingo 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -10
- data/lib/dingo.rb +62 -36
- data/test/dingo_test.rb +46 -12
- data/{dingo.txt → word_lists/dingo.txt} +1 -47
- data/word_lists/people.txt +46 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 791e347a5215563bf184acb17e3665d94eb345ea
|
4
|
+
data.tar.gz: 58ab9254421822c6cf8d361b140061b1fc647262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3a6ae956dfd3b256b5a6a3d4a010be61093f19639b0658ea64ead3315f7f369390896918bc38c776131e992214fe223226d17ccad1d38c656153b8c24b5be2
|
7
|
+
data.tar.gz: 9dbea39d999cef2b1b64483bd42b518c690144b81b73b0e5f0e9f232d8a397b70577a084ee119badeee578e1c26ad5b180d1194264656dfafd50a0ba6017c92f
|
data/README.md
CHANGED
@@ -1,21 +1,52 @@
|
|
1
|
-
Dingo
|
2
|
-
--
|
1
|
+
# Dingo
|
3
2
|
|
4
3
|
Dingo generates copy. Because you're a real aussie and are too lazy to write
|
5
4
|
your own.
|
6
5
|
|
6
|
+
It works by generating an infinite sequences of Australian flavoured copy.
|
7
|
+
|
8
|
+
## API
|
9
|
+
|
7
10
|
```
|
8
|
-
Dingo.
|
11
|
+
dingo = Dingo.new
|
12
|
+
|
13
|
+
dingo.words.take(4)
|
9
14
|
=> ["mateship", "Woolies", "marbo", "sicky"]
|
10
15
|
|
11
|
-
|
16
|
+
dingo.sentences.take(1)
|
12
17
|
=> ["Acca dacca wranga red hot go herald sun mullet qantas."]
|
13
18
|
|
19
|
+
dingo.paragraphs.take(1)
|
20
|
+
=> ["Underdog roy & hg sam newman slow internet sunburn 52 beers in one flight.
|
21
|
+
Little people riding horses richie benaud true blue battered sav doll bludger qantas.
|
22
|
+
Grand final the 7 30 report liking soccer when we're in the world cup shaun micaleff bruce mcavaney cobber.
|
23
|
+
Don burke's beard one hand one bounce woolies burke & wills reversing the ute one handed roy & hg."]
|
24
|
+
|
25
|
+
dingo.people.take(4)
|
26
|
+
=> ["eddie mcguire", "bruce mcavaney", "thorpey", "shaun micaleff", "tony"]
|
27
|
+
|
28
|
+
dingo.emails.take(2)
|
29
|
+
=> ["adam.hills@sunburn.com.au", "gough.whitlam@pavlova.com.au"]
|
30
|
+
```
|
31
|
+
|
32
|
+
all of the above can also be called as class methods.
|
33
|
+
|
34
|
+
```
|
35
|
+
Dingo.words.take(1)
|
36
|
+
Dingo.sentences.take(1)
|
14
37
|
Dingo.paragraphs.take(1)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
38
|
+
Dingo.people.take(1)
|
39
|
+
Dingo.emails.take(1)
|
40
|
+
```
|
41
|
+
|
42
|
+
## Configurables
|
43
|
+
|
44
|
+
```
|
45
|
+
Dingo.new(
|
46
|
+
random: 12,
|
47
|
+
source_words: ["Bush fires", "Resenting the monarchy"],
|
48
|
+
source_people: ["Matey Cobber-Sheep", "Ragey McSportsdad"],
|
49
|
+
sentence_length: 7,
|
50
|
+
paragraph_length: 3
|
51
|
+
)
|
21
52
|
```
|
data/lib/dingo.rb
CHANGED
@@ -1,54 +1,80 @@
|
|
1
1
|
require 'enumerator'
|
2
|
+
require 'forwardable'
|
2
3
|
|
3
4
|
class Dingo
|
4
|
-
|
5
|
-
SENTENCE_LENGTH = 6
|
5
|
+
extend SingleForwardable
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
dir = "../../word_lists/"
|
8
|
+
DEFAULT_WORD_PATH = File.expand_path(dir + "dingo.txt", __FILE__)
|
9
|
+
DEFAULT_PEOPLE_PATH = File.expand_path(dir + "people.txt", __FILE__)
|
11
10
|
|
12
|
-
|
13
|
-
infinite_sequence { aussie_sentence(source_words, random) }
|
14
|
-
end
|
11
|
+
def_delegators :dingo, :words, :sentences, :paragraphs, :people, :emails
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def initialize(
|
14
|
+
random: Random.new,
|
15
|
+
source_words: read_file(DEFAULT_WORD_PATH),
|
16
|
+
source_people: read_file(DEFAULT_PEOPLE_PATH),
|
17
|
+
sentence_length: 6,
|
18
|
+
paragraph_length: 4
|
19
|
+
)
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
@random = random
|
22
|
+
@source_words = source_words.select { |w| !w.include?(" ") }
|
23
|
+
@source_people = source_people
|
24
|
+
@all_words = source_words + source_people
|
25
|
+
@sentence_length = sentence_length
|
26
|
+
@paragraph_length = paragraph_length
|
27
|
+
end
|
24
28
|
|
25
|
-
|
29
|
+
def words; infinite_sequence { word } end
|
30
|
+
def sentences; infinite_sequence { sentence } end
|
31
|
+
def paragraphs; infinite_sequence { paragraph } end
|
32
|
+
def people; infinite_sequence { person } end
|
33
|
+
def emails; infinite_sequence { email } end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def read_file(file_path)
|
38
|
+
File.read(file_path).lines.map(&:chomp)
|
39
|
+
end
|
26
40
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
41
|
+
def infinite_sequence(&block)
|
42
|
+
Enumerator.new do |y|
|
43
|
+
loop do
|
44
|
+
y.yield block.call
|
32
45
|
end
|
33
46
|
end
|
47
|
+
end
|
34
48
|
|
35
|
-
|
36
|
-
|
37
|
-
|
49
|
+
def word
|
50
|
+
@source_words.sample(random: @random)
|
51
|
+
end
|
38
52
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
53
|
+
def sentence
|
54
|
+
sentence = @all_words.
|
55
|
+
sample(@sentence_length, random: @random).
|
56
|
+
join(" ") + "."
|
57
|
+
sentence.capitalize!
|
58
|
+
sentence
|
59
|
+
end
|
43
60
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
61
|
+
def paragraph
|
62
|
+
sentences.take(@paragraph_length).join(" ")
|
63
|
+
end
|
64
|
+
|
65
|
+
def person
|
66
|
+
@source_people.sample(random: @random)
|
67
|
+
end
|
68
|
+
|
69
|
+
def email
|
70
|
+
people.take(1)[0].gsub(" ", ".") + "@" + words.take(1)[0] + ".com.au"
|
71
|
+
end
|
72
|
+
|
73
|
+
class << self
|
74
|
+
private
|
49
75
|
|
50
|
-
def
|
51
|
-
|
76
|
+
def dingo(random: Random.new)
|
77
|
+
@@dingo ||= Dingo.new(random: random)
|
52
78
|
end
|
53
79
|
end
|
54
80
|
end
|
data/test/dingo_test.rb
CHANGED
@@ -1,33 +1,67 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
-
|
3
2
|
require 'dingo'
|
4
3
|
|
5
4
|
class DingoTest < MiniTest::Unit::TestCase
|
6
5
|
def test_skeleton
|
7
|
-
assert_equal 4,
|
6
|
+
assert_equal 4, dingo.words.take(4).length
|
8
7
|
end
|
9
8
|
|
10
9
|
def test_makes_a_lot_of_words
|
11
|
-
assert_equal 40,
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_makes_only_words
|
15
|
-
assert_equal [nil], Dingo.words(source_words: ["more than one word"]).take(1)
|
10
|
+
assert_equal 40, dingo.words.take(40).length
|
16
11
|
end
|
17
12
|
|
18
13
|
def test_makes_sentences_with_full_stops
|
19
|
-
assert_equal ".",
|
14
|
+
assert_equal ".", dingo.sentences.take(1).first[-1]
|
20
15
|
end
|
21
16
|
|
22
17
|
def test_makes_sentences_with_capital_letters
|
23
|
-
|
18
|
+
dingo = dingo(source_words: ["abcdef"], source_people: [])
|
19
|
+
assert_equal "A", dingo.sentences.take(1).first[0]
|
24
20
|
end
|
25
21
|
|
26
22
|
def test_makes_paragraphs
|
27
|
-
assert_equal true,
|
23
|
+
assert_equal true, !!(dingo.paragraphs.take(1)[0].match(/(.*\..*){4}/)[0])
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_makes_people
|
27
|
+
dingo = dingo(source_people: ["naul pewman"])
|
28
|
+
assert_equal ["naul pewman"], dingo.people.take(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_makes_email_addresses
|
32
|
+
assert_equal true, !!(dingo.emails.take(1)[0].match(/.*@.*/)[0])
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_removes_spaces_from_email_addresses
|
36
|
+
dingo = dingo(source_words: ["domain"], source_people: ["san holo"])
|
37
|
+
assert_equal ["san.holo@domain.com.au"], dingo.emails.take(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_configurable_sentence_length
|
41
|
+
dingo = dingo(
|
42
|
+
sentence_length: 2,
|
43
|
+
source_words: ["a", "b", "c"],
|
44
|
+
source_people: []
|
45
|
+
)
|
46
|
+
|
47
|
+
# length 4 to account for a space and fullstop
|
48
|
+
assert_equal 4, dingo.sentences.take(1)[0].length
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_configurable_paragraph_length
|
52
|
+
dingo = dingo(paragraph_length: 2)
|
53
|
+
assert_equal true, !!(dingo.paragraphs.take(1)[0].match(/(.*\..*){2}/)[0])
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_class_api
|
57
|
+
assert Dingo.words.take(1)
|
58
|
+
assert Dingo.sentences.take(1)
|
59
|
+
assert Dingo.paragraphs.take(1)
|
60
|
+
assert Dingo.people.take(1)
|
61
|
+
assert Dingo.emails.take(1)
|
28
62
|
end
|
29
63
|
|
30
|
-
def
|
31
|
-
Dingo.
|
64
|
+
def dingo(opts = {})
|
65
|
+
Dingo.new(opts)
|
32
66
|
end
|
33
67
|
end
|
@@ -1,29 +1,16 @@
|
|
1
|
-
daryl somers
|
2
1
|
herald sun
|
3
2
|
sausage roll
|
4
3
|
footy
|
5
4
|
speccy
|
6
|
-
Ernie Dingo
|
7
|
-
bruce mcavaney
|
8
|
-
cathy freeman
|
9
5
|
mate
|
10
6
|
cobber
|
11
7
|
4 and 20
|
12
8
|
true blue
|
13
9
|
mateship
|
14
10
|
quintessentially australian
|
15
|
-
julia gillard
|
16
|
-
mad monk
|
17
|
-
bob hawke
|
18
|
-
warney
|
19
|
-
gillie
|
20
|
-
merv hughes
|
21
|
-
richie benaud
|
22
11
|
australian gold
|
23
12
|
canary yellow
|
24
13
|
green and gold
|
25
|
-
dawn fraser
|
26
|
-
thorpey
|
27
14
|
vb
|
28
15
|
xxxx
|
29
16
|
holding the ball!
|
@@ -35,8 +22,6 @@ southern cross
|
|
35
22
|
bondi beach
|
36
23
|
great southern land
|
37
24
|
land down under
|
38
|
-
ned kelly
|
39
|
-
paul kelly
|
40
25
|
dog on the tucker box
|
41
26
|
'burbs
|
42
27
|
holden
|
@@ -45,19 +30,13 @@ bogan
|
|
45
30
|
ACDC
|
46
31
|
un-australian
|
47
32
|
swing the willow at it
|
48
|
-
lleyton hewitt
|
49
|
-
pat rafter
|
50
33
|
bonds
|
51
34
|
vegemite
|
52
35
|
sicky
|
53
|
-
pharlap
|
54
|
-
sam newman
|
55
|
-
eddie mcguire
|
56
36
|
great australian hero
|
57
37
|
too right
|
58
38
|
strewth!
|
59
39
|
crikey!
|
60
|
-
agro
|
61
40
|
nullarbor
|
62
41
|
uluru
|
63
42
|
woolies
|
@@ -66,10 +45,6 @@ wranga
|
|
66
45
|
tomato sauce
|
67
46
|
heinz
|
68
47
|
mullet
|
69
|
-
kath & kim
|
70
|
-
glen robbins
|
71
|
-
rove
|
72
|
-
adam hills
|
73
48
|
harsh but fair
|
74
49
|
yeah nah
|
75
50
|
reversing the ute one handed
|
@@ -106,31 +81,20 @@ don burke's beard
|
|
106
81
|
tin shed
|
107
82
|
bundy
|
108
83
|
taking the kids to sea world
|
109
|
-
steve irwin
|
110
84
|
battered sav
|
111
|
-
nikki webster
|
112
85
|
liking soccer when we're in the world cup
|
113
86
|
fish and chips
|
114
|
-
roy & hG
|
115
87
|
little people riding horses
|
116
88
|
having a punt
|
117
89
|
sportsbet
|
118
90
|
slow internet
|
119
|
-
tony
|
120
91
|
you're terrible muriel
|
121
92
|
scooped it outta the punnet
|
122
93
|
marbo
|
123
|
-
Shaun Micaleff
|
124
94
|
52 beers in one flight
|
125
|
-
boonie
|
126
95
|
smuggling budgies
|
127
96
|
stealing land
|
128
97
|
getting inappropriately drunk in Bali
|
129
|
-
tony Lockett
|
130
|
-
wayne carey
|
131
|
-
gary ablett
|
132
|
-
shane crawford
|
133
|
-
burke & wills
|
134
98
|
blue-ringed octopus
|
135
99
|
sting ray
|
136
100
|
grand final
|
@@ -144,25 +108,16 @@ scones
|
|
144
108
|
v8
|
145
109
|
cashed up bogans buying fluoro work cars
|
146
110
|
vomitting your kebab into a taxi
|
147
|
-
skippy
|
148
|
-
paul hogan
|
149
|
-
crocodile dundee
|
150
111
|
charlie the wonder dog
|
151
112
|
brendan fevola
|
113
|
+
crocodile dundee
|
152
114
|
sizzler
|
153
|
-
harold holt
|
154
115
|
undeserved gold at the winter olympics
|
155
|
-
gough whitlam
|
156
116
|
today tonight
|
157
117
|
a current affair
|
158
118
|
the 7 30 report
|
159
|
-
ray martin
|
160
|
-
humphrey b bear
|
161
119
|
great white shark
|
162
120
|
greg norman
|
163
|
-
schapelle corby
|
164
|
-
john horward
|
165
|
-
jeff kennet
|
166
121
|
qantas
|
167
122
|
ansett
|
168
123
|
royal flying doctor service
|
@@ -170,5 +125,4 @@ one hand one bounce
|
|
170
125
|
cricket
|
171
126
|
waltzing matilda
|
172
127
|
advance australia fair
|
173
|
-
jimmy barnes
|
174
128
|
eating our national animal
|
@@ -0,0 +1,46 @@
|
|
1
|
+
daryl somers
|
2
|
+
ernie dingo
|
3
|
+
bruce mcavaney
|
4
|
+
cathy freeman
|
5
|
+
julia gillard
|
6
|
+
mad monk
|
7
|
+
bob hawke
|
8
|
+
warney
|
9
|
+
gillie
|
10
|
+
merv hughes
|
11
|
+
richie benaud
|
12
|
+
dawn fraser
|
13
|
+
ned kelly
|
14
|
+
paul kelly
|
15
|
+
thorpey
|
16
|
+
lleyton hewitt
|
17
|
+
pat rafter
|
18
|
+
pharlap
|
19
|
+
sam newman
|
20
|
+
eddie mcguire
|
21
|
+
agro
|
22
|
+
glen robbins
|
23
|
+
kath and kim
|
24
|
+
steve irwin
|
25
|
+
nikki webster
|
26
|
+
roy and hg
|
27
|
+
tony
|
28
|
+
shaun micaleff
|
29
|
+
boonie
|
30
|
+
tony Lockett
|
31
|
+
burke and wills
|
32
|
+
wayne carey
|
33
|
+
skippy
|
34
|
+
paul hogan
|
35
|
+
gary ablett
|
36
|
+
harold holt
|
37
|
+
gough whitlam
|
38
|
+
ray martin
|
39
|
+
humphrey b bear
|
40
|
+
schapelle corby
|
41
|
+
jimmy barnes
|
42
|
+
john horward
|
43
|
+
jeff kennet
|
44
|
+
shane crawford
|
45
|
+
rove
|
46
|
+
adam hills
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dingo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JaredShay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generate true blue copy
|
14
14
|
email:
|
@@ -19,8 +19,9 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- lib/dingo.rb
|
21
21
|
- test/dingo_test.rb
|
22
|
+
- word_lists/dingo.txt
|
23
|
+
- word_lists/people.txt
|
22
24
|
- README.md
|
23
|
-
- dingo.txt
|
24
25
|
homepage: https://github.com/jaredshay/dingo
|
25
26
|
licenses: []
|
26
27
|
metadata: {}
|