safe_random 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c3e19d8f944b47364e485578bef15bd1acabf548f19a0d3821a92730be51783
4
- data.tar.gz: 666d8ba6ed02922dff7e796bfc502c289aaadf41c7f2863b33233f86f1c3f9d0
3
+ metadata.gz: ee9662786e36671f54f7b523144344ef5492ed8411e9f9b6bf74e39efe17fa1d
4
+ data.tar.gz: c0c79b240db576806e75209dd39232b962ba499dc340cab953ca67c475204255
5
5
  SHA512:
6
- metadata.gz: b449d056be0b468ee2221517e9b39952c38751238776eb23d67e4e6ae16de8d7db3b3653dea68fedc50297861f46ba6d627f6435b9b582c4eccb004753a7c97d
7
- data.tar.gz: 2f77a3fe3986021f19901ecb0892d757969028f8f8e072a5a4a56b9900fc5bdaf5edb8b611cf12f07d0b0ba39ad3a9051c14a9fbcffd22cb15299e8af3a4e2f5
6
+ metadata.gz: 82413fdfa5b9e48f557d7e65969a9a9e5663190231ebc57f3fdd57de2609b4bd787c58985d1a553c26e20470eb3234782af271279662db1cc1b6dff95b3d7d7c
7
+ data.tar.gz: 5e00f45412341d550114ba412463d346b738e48283c7c321dfadca7da6dc5714bc49e8cd773b722035ee42fbce85b3159d8feab0947cd9c2c2ed570249c41284
data/README.md CHANGED
@@ -28,7 +28,19 @@ Try this snippet of code on ruby irb
28
28
  puts SafeRandom.alphanumeric # => PpHPUg1gPnsGD6RNDETsP3DAwm3sGqD3
29
29
  puts SafeRandom.alphanumeric(5) # => rPtK2
30
30
  puts SafeRandom.small_token # => 52b2df1c8
31
-
31
+
32
+ # => Sentences & Paragraphs
33
+ puts SafeRandom.sentences # => "Always fighting all the evil forces bringing peace and justice to all."
34
+ puts SafeRandom.sentences(2) # => "I might jump an open drawbridge or Tarzan from a vine. Beause I'm the unknown stuntman that makes Eastwood look so fine."
35
+ puts SafeRandom.paragraphs # => "Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Who says you have to call just one place home?. \n\n"
36
+ puts SafeRandom.paragraphs(3) # => "Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \n\n Who says you have to call just one place home?. Soaring through all the galaxies in search of Earth flying in to the night. \n\n Maybe tomorrow I'll want to settle down - until tomorrow I'll just keep moving on. \n\n"
37
+
38
+
39
+ # => Strong string : Minumum number should be greater than 5 otherwise by default 8 character string.
40
+ puts SafeRandom.strong_string # => 4skgSy93zaCUZZCoF9WiJF4z3IDCGk%Y
41
+ puts SafeRandom.strong_string(3) # => P4eUbcK%
42
+ puts SafeRandom.strong_string(5) # => 5$Rkdo
43
+
32
44
  ## Contributing
33
45
 
34
46
  1. Fork it ( https://github.com/[my-github-username]/safe_random/fork )
@@ -11,11 +11,6 @@ module SafeRandom
11
11
  random(_length, Constants::SET_ALPHANUMBERIC)
12
12
  end
13
13
 
14
- def self.random(len = 32, character_set)
15
- chars = character_set.map { |x| x.is_a?(Range) ? x.to_a : x }.flatten
16
- Array.new(len) { chars.sample }.join
17
- end
18
-
19
14
  def self.small_token
20
15
  generate_token(6)
21
16
  end
@@ -24,7 +19,40 @@ module SafeRandom
24
19
  generate_token(10)
25
20
  end
26
21
 
22
+ # => Methods - For Main
23
+
24
+ def self.random(len = 32, character_set)
25
+ chars = character_set.map { |x| x.is_a?(Range) ? x.to_a : x }.flatten
26
+ Array.new(len) { chars.sample }.join
27
+ end
28
+
29
+ def self.strong_string(_len = 32)
30
+ _len = 8 if _len < 5
31
+ [single('number'),
32
+ single('symbol'),
33
+ single('upcase'),
34
+ single('downcase'),
35
+ alphanumeric(_len - 4)]
36
+ .shuffle
37
+ .join
38
+ end
39
+
27
40
  def self.generate_token(_length)
28
41
  Digest::SHA1.hexdigest([Time.now, rand].join)[0.._length]
29
42
  end
43
+
44
+ def self.single(_type)
45
+ case _type
46
+ when 'number'
47
+ random(1, Constants::SET_NUMBER)
48
+ when 'upcase'
49
+ random(1, Constants::SET_UPCASE)
50
+ when 'downcase'
51
+ random(1, Constants::SET_DOWNCASE)
52
+ when 'symbol'
53
+ random(1, Constants::SET_SYMBOL)
54
+ else
55
+ random(1, Constants::SET_ALPHANUMBERIC)
56
+ end
57
+ end
30
58
  end
@@ -1,6 +1,9 @@
1
1
  module Constants
2
2
  SET_NUMBER = ['0'..'9'].freeze
3
3
  SET_STRING = ['A'..'Z', 'a'..'z'].freeze
4
+ SET_UPCASE = ['A'..'Z'].freeze
5
+ SET_DOWNCASE = ['a'..'z'].freeze
6
+ SET_SYMBOL = %i[@ # $ % &].freeze
4
7
  SET_ALPHANUMBERIC = ['A'..'Z', 'a'..'z', '0'..'9'].freeze
5
8
 
6
9
  SET_PARAGRAPH = [
@@ -1,6 +1,7 @@
1
1
  module SafeRandom
2
2
  # => Returns a given number of paragraphs delimited by two newlines (defaults to two paragraphs),
3
3
  # => using a small pool of generic sentences.
4
+ # => SafeRandom.sentences
4
5
  # => SafeRandom.paragraphs
5
6
  #
6
7
  # "I might jump an open drawbridge or Tarzan from a vine, beause I'm the unknown stuntman that makes Eastwood look so fine.\n\n \Always fighting all the evil forces bringing peace and justice to all. \n\n"
@@ -1,3 +1,3 @@
1
1
  module SafeRandom
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_random
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Patil
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: SafeRandom gem will help to generate random string, paragraphs, number
42
- and alphanumeric very easily.
41
+ description: SafeRandom gem will help to generate random string, paragraphs, strong
42
+ string, number and alphanumeric very easily.
43
43
  email:
44
44
  - rahupatil_scs@yahoo.co.in
45
45
  executables: []
@@ -54,7 +54,7 @@ files:
54
54
  - lib/safe_random/constants.rb
55
55
  - lib/safe_random/text.rb
56
56
  - lib/safe_random/version.rb
57
- homepage: ''
57
+ homepage: https://github.com/rpatil/safe_random
58
58
  licenses:
59
59
  - MIT
60
60
  metadata: {}