shufflino 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/Makefile +19 -0
- data/README.md +43 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/shufflino/helpers.rb +9 -0
- data/lib/shufflino/version.rb +3 -0
- data/lib/shufflino.rb +42 -0
- data/shufflino.gemspec +37 -0
- metadata +17 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b292f18ace326fb263ad97ca292d2e64d2dc1efa7fd0a362b9dfd979cfa851d
|
4
|
+
data.tar.gz: b339de49479966abc63f5de208632b153bffc93fd5460a6f035cd4e8351ecb58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe2251fb7803926c731310d2533903c68f839cae66792c354332ab03ed809b300f0da1fcd10f6a45858f15cfa9ffc0b2d0a813e85cb0eaa0955b1c5e1da673df
|
7
|
+
data.tar.gz: a7609ff5ec117bdc6351cfe0715436bb32d9b3e0c7b2e41849fbe7b2949f98be6c09e931f761054e22e36203f6c71cd10e8ad159f33adbb83400beea04197a45
|
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shufflino (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
byebug (11.1.1)
|
10
|
+
coderay (1.1.2)
|
11
|
+
method_source (1.0.0)
|
12
|
+
minitest (5.14.0)
|
13
|
+
minitest-power_assert (0.3.1)
|
14
|
+
minitest
|
15
|
+
power_assert (>= 1.1)
|
16
|
+
power_assert (1.1.7)
|
17
|
+
pry (0.13.0)
|
18
|
+
coderay (~> 1.1)
|
19
|
+
method_source (~> 1.0)
|
20
|
+
pry-byebug (3.9.0)
|
21
|
+
byebug (~> 11.0)
|
22
|
+
pry (~> 0.13.0)
|
23
|
+
rake (13.0.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 2.0)
|
30
|
+
minitest (~> 5.0)
|
31
|
+
minitest-power_assert (~> 0.3)
|
32
|
+
pry-byebug (~> 3.9)
|
33
|
+
rake (>= 12.3.3)
|
34
|
+
shufflino!
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Ivan Nemytchenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Shufflino
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/shufflino`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'shufflino'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install shufflino
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/shufflino. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Shufflino project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/shufflino/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "shufflino"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/shufflino.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative "shufflino/version"
|
2
|
+
require_relative "shufflino/helpers"
|
3
|
+
|
4
|
+
module Shufflino
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
class Core
|
8
|
+
def initialize(seeds)
|
9
|
+
@seeds = seeds
|
10
|
+
|
11
|
+
raise "Empty seeds array" if seeds.empty?
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate(id)
|
16
|
+
id = id.to_i
|
17
|
+
raise Shufflino::Error.new 'Not enough seeds!' if id > combinations_size - 1
|
18
|
+
|
19
|
+
indices = id.to_s(alphabet_size).rjust(id_length, "0").split("")
|
20
|
+
result = ""
|
21
|
+
|
22
|
+
indices.each_with_index do |index, i|
|
23
|
+
alphabet = @seeds[i]
|
24
|
+
result << alphabet[index.to_i].to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
result
|
28
|
+
end
|
29
|
+
|
30
|
+
def combinations_size
|
31
|
+
alphabet_size ** id_length
|
32
|
+
end
|
33
|
+
|
34
|
+
def alphabet_size
|
35
|
+
@seeds.first.size
|
36
|
+
end
|
37
|
+
|
38
|
+
def id_length
|
39
|
+
@seeds.size
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/shufflino.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "shufflino/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "shufflino"
|
7
|
+
spec.version = Shufflino::VERSION
|
8
|
+
|
9
|
+
spec.authors = ["Ivan Nemytchenko"]
|
10
|
+
spec.email = ["nemytchenko@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generates unique pseudo-random identificators based on shuffled seed arrays}
|
13
|
+
spec.description = %q{Generates unique pseudo-random identificators based on shuffled seed arrays}
|
14
|
+
spec.homepage = "https://github.com/inem/shuffled-seed-array-id"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/inem/shuffled-seed-array-id"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/inem/shuffled-seed-array-id"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
33
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
34
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
35
|
+
spec.add_development_dependency "pry-byebug", "~> 3.9"
|
36
|
+
spec.add_development_dependency 'minitest-power_assert', '~> 0.3'
|
37
|
+
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nemytchenko
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,7 +89,19 @@ extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
92
94
|
- LICENSE
|
95
|
+
- LICENSE.txt
|
96
|
+
- Makefile
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/shufflino.rb
|
102
|
+
- lib/shufflino/helpers.rb
|
103
|
+
- lib/shufflino/version.rb
|
104
|
+
- shufflino.gemspec
|
93
105
|
homepage: https://github.com/inem/shuffled-seed-array-id
|
94
106
|
licenses:
|
95
107
|
- MIT
|