vv 0.0.1 → 0.0.2
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 +4 -4
- data/lib/vv/array_methods.rb +11 -0
- data/lib/vv/random_methods.rb +48 -0
- data/lib/vv/string_methods.rb +18 -0
- data/lib/vv/version.rb +1 -1
- data/lib/vv.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0d4f7e451fe83d5821a7c3ffb6f6f58d713817c4f71db3f9bff23798dc09392
|
4
|
+
data.tar.gz: 7daf207132ff4558cde221b922f4746b91176a2c6549f662eeba92e3769394ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed72115dc99519d180bb87313d2f2081dbb3da7953623a2431615d92a70d4608622a1c2fded94805b758b55ef6499d379632eb830e18431ffb761207dd4e1a4
|
7
|
+
data.tar.gz: c11639c876bb3b4f9713d27301306d1c64f2e7e7f18a1912c724973f8e1bb6fdb519ae968753a72c3f61f3114c04fb9c9a430fb01d2584f0c0ca2351f405eaff
|
data/lib/vv/array_methods.rb
CHANGED
@@ -33,6 +33,17 @@ module VV
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def includes_any?(other)
|
37
|
+
raise TypeError, "Expecting array" unless other.is_a? Array
|
38
|
+
uother = other.uniq
|
39
|
+
uself = self.uniq
|
40
|
+
(uself + uother).uniq.size < (uself.size + uother.size)
|
41
|
+
end
|
42
|
+
|
43
|
+
def include_any?(other)
|
44
|
+
self.includes_any?(other)
|
45
|
+
end
|
46
|
+
|
36
47
|
def stringify_collection grave: false
|
37
48
|
return self.gravify.stringify_collection if grave
|
38
49
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module VV
|
2
|
+
|
3
|
+
module RandomClassSettings
|
4
|
+
|
5
|
+
def random_identifier_default_length
|
6
|
+
40
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
module RandomMethods
|
12
|
+
|
13
|
+
def self.included(base)
|
14
|
+
base.extend(ClassMethods)
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
|
19
|
+
def vv_included?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_charset
|
24
|
+
36
|
25
|
+
end
|
26
|
+
|
27
|
+
def identifier length=nil, charset_count: nil
|
28
|
+
length ||= self.random_identifier_default_length
|
29
|
+
|
30
|
+
charset_count ||= self.default_charset
|
31
|
+
largest_digit = (charset_count - 1).to_s charset_count
|
32
|
+
|
33
|
+
start = ( largest_digit * ( length - 1 ) ).to_i charset_count
|
34
|
+
finish = ( largest_digit * ( length ) ).to_i charset_count
|
35
|
+
range = start..finish
|
36
|
+
|
37
|
+
SecureRandom.random_number(range).to_s charset_count
|
38
|
+
end
|
39
|
+
|
40
|
+
def character *args, capitals: false
|
41
|
+
String.letters_and_numbers(capitals: capitals)
|
42
|
+
.sample(*args, random: SecureRandom)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/vv/string_methods.rb
CHANGED
@@ -13,6 +13,24 @@ module VV
|
|
13
13
|
true
|
14
14
|
end
|
15
15
|
|
16
|
+
def letters
|
17
|
+
("a".."z").to_a
|
18
|
+
end
|
19
|
+
|
20
|
+
def numbers
|
21
|
+
("0".."9").to_a
|
22
|
+
end
|
23
|
+
|
24
|
+
def capitals
|
25
|
+
("A".."Z").to_a
|
26
|
+
end
|
27
|
+
|
28
|
+
def letters_and_numbers(capitals: false)
|
29
|
+
response = self.letters
|
30
|
+
response += self.capitals if capitals
|
31
|
+
response += self.numbers
|
32
|
+
end
|
33
|
+
|
16
34
|
end
|
17
35
|
|
18
36
|
module SharedInstanceAndClassMethods
|
data/lib/vv/version.rb
CHANGED
data/lib/vv.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
require_relative "vv/gem_methods"
|
2
4
|
|
3
5
|
Gem.require_files "vv/*.rb"
|
@@ -25,3 +27,8 @@ end
|
|
25
27
|
class NilClass
|
26
28
|
include VV::NilMethods
|
27
29
|
end
|
30
|
+
|
31
|
+
class Random
|
32
|
+
include VV::RandomMethods
|
33
|
+
extend VV::RandomClassSettings
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Aysan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/vv/gem_methods.rb
|
68
68
|
- lib/vv/hash_methods.rb
|
69
69
|
- lib/vv/nil_methods.rb
|
70
|
+
- lib/vv/random_methods.rb
|
70
71
|
- lib/vv/readline_methods.rb
|
71
72
|
- lib/vv/string_methods.rb
|
72
73
|
- lib/vv/true_methods.rb
|