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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 055a7e285d85a35ea1419927b9484b6991eaf7032d759338c206f0e48f0ab2ae
4
- data.tar.gz: 73c54fa867ae235217cda1beb87d582498bc959772686af4847a6424644687cb
3
+ metadata.gz: 35d13921cdcbf0dab375bd05b93885adb11026ae89911cdf4409a4830388d69a
4
+ data.tar.gz: 92d8b430160209fa83083e5bf3613cdfab6b3425a9177531e353ba62108f0893
5
5
  SHA512:
6
- metadata.gz: e655bd0247e8ad985978acbb5f06b39888079c67e0efdcb29ac1dcc43c73d3710e653569c21879d6ba06b23664f653d29f0b493764638ee05fc83c1c85114d77
7
- data.tar.gz: 4ac23d05d2ea34a7dc8f0a622916b8eca97c4f418c922fad05f0fd0b45ee950cf8ae9a6deb94936e929ce87370be6d056360d7f22fad50a7cb59552fc48dc8dc
6
+ metadata.gz: 3c536664e03f8cb4b99182ae8a7a9ded7ac914f308c3b26a37a77fac1e28ca66d6883ce3ce2316ce82b00c3b074afd8c812a3b6a7d1039cb1abb7f0a97edad9c
7
+ data.tar.gz: b17fc747441288faffd89f2c565df8c0abf4b186925571ed4eb94724606f8dc99cba3e9a9ffaa789193ff0abe6c878eae53868bc375a1897332541cf7eabc60f
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shufflino (0.2.1)
4
+ shufflino (0.3.0)
5
+ bases (~> 1.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ bases (1.0.2)
9
11
  byebug (11.1.1)
10
12
  coderay (1.1.2)
11
13
  method_source (1.0.0)
@@ -1,3 +1,3 @@
1
1
  module Shufflino
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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(alphabet_size).rjust(id_length, "0").split("")
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.to_i].to_s
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.2.1
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: