malarkey 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/malarkey.rb +272 -0
  2. metadata +54 -0
data/lib/malarkey.rb ADDED
@@ -0,0 +1,272 @@
1
+ class Malarkey
2
+ def initialize(*data)
3
+ sow(data)
4
+ end
5
+
6
+ def hash(data)
7
+ n = 0xefc8249d
8
+ h = 0
9
+ d = data.to_s
10
+
11
+ d.each_codepoint { |cp|
12
+ n += cp
13
+ h = 0.02519603282416938 * n
14
+ n = h.to_i
15
+ h -= n
16
+ h *= n
17
+ n = h.to_i
18
+ h -= n
19
+ n += h * 0x100000000 # 2^32
20
+ }
21
+
22
+ n.to_i * 2.3283064365386963e-10 # 2^-32
23
+ end
24
+
25
+ def rnd
26
+ t = 2091639 * @s0 + @c * 2.3283064365386963e-10 # 2^-32
27
+
28
+ @c = t.to_i
29
+ @s0 = @s1
30
+ @s1 = @s2
31
+ @s2 = t - @c
32
+
33
+ @s2
34
+ end
35
+
36
+ def sow(*data)
37
+ @s0 = hash(' ')
38
+ @s1 = hash(@s0)
39
+ @s2 = hash(@s1)
40
+ @c = 1
41
+
42
+ data.each { |d|
43
+ @s0 -= hash(d)
44
+ @s0 += 1 if @s0 < 0
45
+
46
+ @s1 -= hash(d)
47
+ @s1 += 1 if @s1 < 0
48
+
49
+ @s2 -= hash(d)
50
+ @s2 += 1 if @s2 < 0
51
+ }
52
+ end
53
+
54
+ def uint32
55
+ rnd * 0x100000000
56
+ end
57
+
58
+ def fract32
59
+ rnd + (rnd * 0x200000).to_i * 1.1102230246251565e-16 # 2^-53
60
+ end
61
+
62
+ def integer
63
+ uint32
64
+ end
65
+
66
+ def frac
67
+ fract32
68
+ end
69
+
70
+ def real
71
+ uint32 + fract32
72
+ end
73
+
74
+ def integer_in_range(min=0, max=0)
75
+ real_in_range(min, max).floor
76
+ end
77
+
78
+ def real_in_range(min=0, max=0)
79
+ frac * (max - min) + min
80
+ end
81
+
82
+ def normal
83
+ 1.0 - 2.0 * frac
84
+ end
85
+
86
+ def uuid
87
+ 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.gsub!(/[xy]/) do |c|
88
+ r = integer_in_range(0, 16)
89
+ if c == 'x'
90
+ v = r
91
+ else
92
+ v = (r&0x3|0x8)
93
+ end
94
+ v.to_s(16)
95
+ end
96
+ end
97
+
98
+ def pick(ary)
99
+ ary[integer_in_range(0, ary.length)]
100
+ end
101
+
102
+ def weighted_pick(ary)
103
+ ary[(frac**2).to_i * ary.length]
104
+ end
105
+
106
+ def word
107
+ pick(DATA[:lipsum])
108
+ end
109
+
110
+ def words(num=3)
111
+ ret = []
112
+ (0..num).each do |i|
113
+ ret.push(word)
114
+ end
115
+
116
+ ret.join(' ')
117
+ end
118
+
119
+ def sentence
120
+ (words(integer_in_range(2, 16)).capitalize) + '.'
121
+ end
122
+
123
+ def sentences(num=3)
124
+ ret = []
125
+
126
+ (0..num).each do |i|
127
+ ret.push(sentence)
128
+ end
129
+
130
+ ret.join(' ')
131
+ end
132
+
133
+ def timestamp(min=946684800, max=1577862000)
134
+ real_in_range(min, max)
135
+ end
136
+
137
+ def first_name
138
+ "#{pick(DATA[:names][:first])}"
139
+ end
140
+
141
+ def last_name
142
+ "#{pick(DATA[:names][:last])}"
143
+ end
144
+
145
+ def name
146
+ "#{pick(DATA[:names][:first])} #{pick(DATA[:names][:last])}"
147
+ end
148
+
149
+ def job_title
150
+ "#{pick(DATA[:departments])} #{pick(DATA[:positions])}"
151
+ end
152
+
153
+ def buzz_phrase
154
+ "#{pick(DATA[:buzz][:verbs])} #{pick(DATA[:buzz][:adjectives])} #{pick(DATA[:buzz][:nouns])}"
155
+ end
156
+
157
+ DATA = {
158
+ lipsum: [
159
+ "lorem", "ipsum", "dolor", "sit", "amet", "consectetur",
160
+ "adipiscing", "elit", "nunc", "sagittis", "tortor", "ac", "mi",
161
+ "pretium", "sed", "convallis", "massa", "pulvinar", "curabitur",
162
+ "non", "turpis", "velit", "vitae", "rutrum", "odio", "aliquam",
163
+ "sapien", "orci", "tempor", "sed", "elementum", "sit", "amet",
164
+ "tincidunt", "sed", "risus", "etiam", "nec", "lacus", "id", "ante",
165
+ "hendrerit", "malesuada", "donec", "porttitor", "magna", "eget",
166
+ "libero", "pharetra", "sollicitudin", "aliquam", "mattis", "mattis",
167
+ "massa", "et", "porta", "morbi", "vitae", "magna", "augue",
168
+ "vestibulum", "at", "lectus", "sed", "tellus", "facilisis",
169
+ "tincidunt", "suspendisse", "eros", "magna", "consequat", "at",
170
+ "sollicitudin", "ac", "vestibulum", "vel", "dolor", "in", "egestas",
171
+ "lacus", "quis", "lacus", "placerat", "et", "molestie", "ipsum",
172
+ "scelerisque", "nullam", "sit", "amet", "tortor", "dui", "aenean",
173
+ "pulvinar", "odio", "nec", "placerat", "fringilla", "neque", "dolor"
174
+ ],
175
+ names: {
176
+ first: [
177
+ "Jacob", "Isabella", "Ethan", "Emma", "Michael", "Olivia",
178
+ "Alexander", "Sophia", "William", "Ava", "Joshua", "Emily",
179
+ "Daniel", "Madison", "Jayden", "Abigail", "Noah", "Chloe",
180
+ "Anthony", "Mia", "Christopher", "Elizabeth", "Aiden",
181
+ "Addison", "Matthew", "Alexis", "David", "Ella", "Andrew",
182
+ "Samantha", "Joseph", "Natalie", "Logan", "Grace", "James",
183
+ "Lily", "Ryan", "Alyssa", "Benjamin", "Ashley", "Elijah",
184
+ "Sarah", "Gabriel", "Taylor", "Christian", "Hannah", "Nathan",
185
+ "Brianna", "Jackson", "Hailey", "John", "Kaylee", "Samuel",
186
+ "Lillian", "Tyler", "Leah", "Dylan", "Anna", "Jonathan",
187
+ "Allison", "Caleb", "Victoria", "Nicholas", "Avery", "Gavin",
188
+ "Gabriella", "Mason", "Nevaeh", "Evan", "Kayla", "Landon",
189
+ "Sofia", "Angel", "Brooklyn", "Brandon", "Riley", "Lucas",
190
+ "Evelyn", "Isaac", "Savannah", "Isaiah", "Aubrey", "Jack",
191
+ "Alexa", "Jose", "Peyton", "Kevin", "Makayla", "Jordan",
192
+ "Layla", "Justin", "Lauren", "Brayden", "Zoe", "Luke", "Sydney",
193
+ "Liam", "Audrey", "Carter", "Julia"
194
+ ],
195
+ last: [
196
+ "Smith", "Johnson", "Williams", "Jones", "Brown", "Davis",
197
+ "Miller", "Wilson", "Moore", "Taylor", "Anderson", "Thomas",
198
+ "Jackson", "White", "Harris", "Martin", "Thompson", "Garcia",
199
+ "Martinez", "Robinson", "Clark", "Rodriguez", "Lewis", "Lee",
200
+ "Walker", "Hall", "Allen", "Young", "Hernandez", "King",
201
+ "Wright", "Lopez", "Hill", "Scott", "Green", "Adams", "Baker",
202
+ "Gonzalez", "Nelson", "Carter", "Mitchell", "Perez", "Roberts",
203
+ "Turner", "Phillips", "Campbell", "Parker", "Evans", "Edwards",
204
+ "Collins", "Stewart", "Sanchez", "Morris", "Rogers", "Reed",
205
+ "Cook", "Morgan", "Bell", "Murphy", "Bailey", "Rivera",
206
+ "Cooper", "Richardson", "Cox", "Howard", "Ward", "Torres",
207
+ "Peterson", "Gray", "Ramirez", "James", "Watson", "Brooks",
208
+ "Kelly", "Sanders", "Price", "Bennett", "Wood", "Barnes",
209
+ "Ross", "Henderson", "Coleman", "Jenkins", "Perry", "Powell",
210
+ "Long", "Patterson", "Hughes", "Flores", "Washington", "Butler",
211
+ "Simmons", "Foster", "Gonzales", "Bryant", "Alexander",
212
+ "Russell", "Griffin", "Diaz", "Hayes"
213
+ ]
214
+ },
215
+
216
+ departments: ['HR', 'IT', 'Marketing', 'Engineering', 'Sales'],
217
+
218
+ positions: ['Director', 'Manager', 'Team Lead', 'Team Member'],
219
+
220
+ internet: {
221
+ tlds: ['.com', '.net', '.org', '.edu', '.co.uk']
222
+ },
223
+
224
+ buzz: {
225
+ nouns: [
226
+ "action-items", "applications", "architectures", "bandwidth",
227
+ "channels", "communities", "content", "convergence",
228
+ "deliverables", "e-business", "e-commerce", "e-markets",
229
+ "e-services", "e-tailers", "experiences", "eyeballs",
230
+ "functionalities", "infomediaries", "infrastructures",
231
+ "initiatives", "interfaces", "markets", "methodologies",
232
+ "metrics", "mindshare", "models", "networks", "niches",
233
+ "paradigms", "partnerships", "platforms", "portals",
234
+ "relationships", "ROI", "schemas", "solutions", "supply-chains",
235
+ "synergies", "systems", "technologies", "users", "vortals",
236
+ "web services", "web-readiness"
237
+ ],
238
+ adjectives: [
239
+ "24/365", "24/7", "B2B", "B2C", "back-end", "best-of-breed",
240
+ "bleeding-edge", "bricks-and-clicks", "clicks-and-mortar",
241
+ "collaborative", "compelling", "cross-media", "cross-platform",
242
+ "customized", "cutting-edge", "distributed", "dot-com",
243
+ "dynamic", "e-business", "efficient", "end-to-end",
244
+ "enterprise", "extensible", "frictionless", "front-end",
245
+ "global", "granular", "holistic", "impactful", "innovative",
246
+ "integrated", "interactive", "intuitive", "killer",
247
+ "leading-edge", "magnetic", "mission-critical", "multiplatform",
248
+ "next-generation", "one-to-one", "open-source",
249
+ "out-of-the-box", "plug-and-play", "proactive", "real-time",
250
+ "revolutionary", "rich", "robust", "scalable", "seamless",
251
+ "sexy", "sticky", "strategic", "synergistic", "transparent",
252
+ "turn-key", "ubiquitous", "user-centric", "value-added",
253
+ "vertical", "viral", "virtual", "visionary", "web-enabled",
254
+ "wireless", "world-class"
255
+ ],
256
+ verbs: [
257
+ "aggregate", "architect", "benchmark", "brand", "cultivate",
258
+ "deliver", "deploy", "disintermediate", "drive", "e-enable",
259
+ "embrace", "empower", "enable", "engage", "engineer", "enhance",
260
+ "envisioneer", "evolve", "expedite", "exploit", "extend",
261
+ "facilitate", "generate", "grow", "harness", "implement",
262
+ "incentivize", "incubate", "innovate", "integrate", "iterate",
263
+ "leverage", "matrix", "maximize", "mesh", "monetize", "morph",
264
+ "optimize", "orchestrate", "productize", "recontextualize",
265
+ "redefine", "reintermediate", "reinvent", "repurpose",
266
+ "revolutionize", "scale", "seize", "strategize", "streamline",
267
+ "syndicate", "synergize", "synthesize", "target", "transform",
268
+ "transition", "unleash", "utilize", "visualize", "whiteboard"
269
+ ]
270
+ }
271
+ }
272
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: malarkey
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Josh Faul
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-05-09 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Generate repeatable random data
17
+ email: josh.faul@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/malarkey.rb
26
+ homepage: http://github.com/jocafa/malarkey
27
+ licenses: []
28
+
29
+ post_install_message:
30
+ rdoc_options: []
31
+
32
+ require_paths:
33
+ - lib
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"
46
+ requirements: []
47
+
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.10
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Malarkey
53
+ test_files: []
54
+