nonsuch 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/nonsuch.rb +79 -0
- metadata +43 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a8d22d983c84167f5bffa27fea15e6ac3954ba9a9dfc0506e787a38d91af29f9
|
|
4
|
+
data.tar.gz: 1a1605233be4b51d76ae7e95bbc1499cc2f8d9ed2f28ca4fb7b09d6610818c39
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cef1522059c7fcc09296c416493fb6edbd7546057010315936203d21736deb8b1aa65981aafe6431e5546ccf32818f1d8ac53ba8d3f8dbc147e42589df5d82a4
|
|
7
|
+
data.tar.gz: 8557e3b05a495392a1b78783d7d40c9749de7619dfe7c1e09622ed5199c3ace13ba9899916aa5c6dac0a22d4183292900ca58ae07b767470ce7688ed233a4653
|
data/lib/nonsuch.rb
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module Nonsuch
|
|
2
|
+
|
|
3
|
+
def business_days_between(start_date:, end_date:)
|
|
4
|
+
business_days = 0
|
|
5
|
+
date = end_date
|
|
6
|
+
while date > start_date
|
|
7
|
+
business_days = business_days + 1 unless date.saturday? or date.sunday?
|
|
8
|
+
date = date - 1.day
|
|
9
|
+
end
|
|
10
|
+
business_days
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def emails(count:, domains: self.domains(count: 4), names: nil)
|
|
14
|
+
raise ArgumentError, "names.length #{names.length} != count #{count}" if names && names.length != count
|
|
15
|
+
arr = []
|
|
16
|
+
count.times do |index|
|
|
17
|
+
if names
|
|
18
|
+
local_part = names[index].downcase.delete(" ")
|
|
19
|
+
else
|
|
20
|
+
local_part = "#{syllables(count: rand(3) + 1).join}"
|
|
21
|
+
end
|
|
22
|
+
email = "#{local_part}@#{domains.sample}"
|
|
23
|
+
arr << email unless arr.include? email
|
|
24
|
+
end
|
|
25
|
+
arr
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def domains(count:)
|
|
29
|
+
top_level = syllables count: 4
|
|
30
|
+
arr = []
|
|
31
|
+
count.times do
|
|
32
|
+
domain = "#{syllable}#{syllable}.#{top_level.sample}"
|
|
33
|
+
arr << domain unless arr.include? domain
|
|
34
|
+
end
|
|
35
|
+
arr
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def names(count:)
|
|
39
|
+
arr = []
|
|
40
|
+
count.times do
|
|
41
|
+
arr << "#{self.word(syllables: 2).capitalize} #{self.word(syllables: 3).capitalize}"
|
|
42
|
+
end
|
|
43
|
+
arr
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def sentence(words: 7)
|
|
47
|
+
"#{phrase(words: words).capitalize}."
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def phrase(words: 3)
|
|
51
|
+
arr = []
|
|
52
|
+
(rand(words) + 1).times { arr << word(syllables: 3)}
|
|
53
|
+
arr.join ' '
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def word(syllables: 1)
|
|
57
|
+
self.syllables(count: rand(syllables) + 1).join
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def syllables(count:)
|
|
61
|
+
arr = []
|
|
62
|
+
count.times do
|
|
63
|
+
current = syllable
|
|
64
|
+
arr << current unless arr.include? current
|
|
65
|
+
end
|
|
66
|
+
arr
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def syllable
|
|
70
|
+
@vowels ||= %w(a e i o u)
|
|
71
|
+
@consonants ||= ("a".."z").to_a - @vowels
|
|
72
|
+
"#{@consonants.sample}#{@vowels.sample}#{@consonants.sample}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def time
|
|
76
|
+
Time.now - rand(100000000) + 40000000
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nonsuch
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Rob Watkin
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-10-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Simple nonsense generator for test data
|
|
14
|
+
email: robwatkin@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/nonsuch.rb
|
|
20
|
+
homepage: https://github.com/robwatkin/nonsuch
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubygems_version: 3.0.6
|
|
40
|
+
signing_key:
|
|
41
|
+
specification_version: 4
|
|
42
|
+
summary: Nonsense generator
|
|
43
|
+
test_files: []
|