vv 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe93872b369b2bef0d97aee37de5eb1c695868657bac36a0d092be41796eceaf
4
- data.tar.gz: f8fd0ef72c7406cd5c1b2e54bf7ac50d402a1784bea259e4c9dba24190fe7b66
3
+ metadata.gz: c0d4f7e451fe83d5821a7c3ffb6f6f58d713817c4f71db3f9bff23798dc09392
4
+ data.tar.gz: 7daf207132ff4558cde221b922f4746b91176a2c6549f662eeba92e3769394ee
5
5
  SHA512:
6
- metadata.gz: 5e1b8989145f69d91378dbefa190a2ddb622fbd663c3d224c87f68d7901994a2a340f2ad18d931ab7d89325a9484e3c7d61adc6fc24316885558847700fd4044
7
- data.tar.gz: 2f59c921b3cca9a1e8a2920e47fad61585fcf09129aa96ca9bc10685acbbba20614d92b975289b53e5f8a95e27ee4b53045cc3f3e48b83ee58565e0674c51fdc
6
+ metadata.gz: 4ed72115dc99519d180bb87313d2f2081dbb3da7953623a2431615d92a70d4608622a1c2fded94805b758b55ef6499d379632eb830e18431ffb761207dd4e1a4
7
+ data.tar.gz: c11639c876bb3b4f9713d27301306d1c64f2e7e7f18a1912c724973f8e1bb6fdb519ae968753a72c3f61f3114c04fb9c9a430fb01d2584f0c0ca2351f405eaff
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module VV
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
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-30 00:00:00.000000000 Z
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