shufflino 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/lib/shufflino/version.rb +1 -1
- data/lib/shufflino.rb +7 -2
- data/shufflino.gemspec +2 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35d13921cdcbf0dab375bd05b93885adb11026ae89911cdf4409a4830388d69a
|
4
|
+
data.tar.gz: 92d8b430160209fa83083e5bf3613cdfab6b3425a9177531e353ba62108f0893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c536664e03f8cb4b99182ae8a7a9ded7ac914f308c3b26a37a77fac1e28ca66d6883ce3ce2316ce82b00c3b074afd8c812a3b6a7d1039cb1abb7f0a97edad9c
|
7
|
+
data.tar.gz: b17fc747441288faffd89f2c565df8c0abf4b186925571ed4eb94724606f8dc99cba3e9a9ffaa789193ff0abe6c878eae53868bc375a1897332541cf7eabc60f
|
data/Gemfile.lock
CHANGED
data/lib/shufflino/version.rb
CHANGED
data/lib/shufflino.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative "shufflino/version"
|
2
2
|
require_relative "shufflino/helpers"
|
3
3
|
|
4
|
+
require 'bases'
|
5
|
+
|
4
6
|
module Shufflino
|
5
7
|
class Error < StandardError; end
|
6
8
|
|
@@ -20,12 +22,15 @@ module Shufflino
|
|
20
22
|
id = id.to_i
|
21
23
|
raise Shufflino::Error.new 'Not enough seeds!' if id > combinations_size - 1
|
22
24
|
|
23
|
-
indices = id.to_s(
|
25
|
+
indices = Bases[id.to_s].in_base(10).to_base(alphabet_size).split("").map(&:to_i)
|
26
|
+
|
27
|
+
indices = Array.new(id_length - indices.size, 0) + indices # rjust
|
28
|
+
|
24
29
|
result = ""
|
25
30
|
|
26
31
|
indices.each_with_index do |index, i|
|
27
32
|
alphabet = @seeds[i]
|
28
|
-
result << alphabet[index
|
33
|
+
result << alphabet[index].to_s
|
29
34
|
end
|
30
35
|
|
31
36
|
result
|
data/shufflino.gemspec
CHANGED
@@ -34,4 +34,6 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "minitest", "~> 5.0"
|
35
35
|
spec.add_development_dependency "pry-byebug", "~> 3.9"
|
36
36
|
spec.add_development_dependency 'minitest-power_assert', '~> 0.3'
|
37
|
+
|
38
|
+
spec.add_dependency 'bases', '~> 1.0'
|
37
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shufflino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nemytchenko
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bases
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
83
97
|
description: Generates unique pseudo-random identificators based on shuffled seed
|
84
98
|
arrays
|
85
99
|
email:
|