shufflino 0.1.0 → 0.1.1

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: e8ae25d6c11b2f74272b07f64f1369e54df26a241689291e03cf1f5538e3d718
4
- data.tar.gz: e908c192f69ff763be2254880d45bbf3d50e4b1f1557c9e526e8aada64de2fd4
3
+ metadata.gz: 7b292f18ace326fb263ad97ca292d2e64d2dc1efa7fd0a362b9dfd979cfa851d
4
+ data.tar.gz: b339de49479966abc63f5de208632b153bffc93fd5460a6f035cd4e8351ecb58
5
5
  SHA512:
6
- metadata.gz: 613441f705f7172ac98dfeb5499907cd20f8a9cfe3d9c23141aec3f594e8ceebbfdc9162a286000855f6bdb80e7caea97a7430aa195b870d61c37def1c278a39
7
- data.tar.gz: fccc643055d7c22d2f022cc03cefd413eea937ff360c1761d5b4ddf9bdacbd94ab9721b275e99d63d74b9f82511e3042c6e73de23bdff8f8930304f5bc752c9d
6
+ metadata.gz: fe2251fb7803926c731310d2533903c68f839cae66792c354332ab03ed809b300f0da1fcd10f6a45858f15cfa9ffc0b2d0a813e85cb0eaa0955b1c5e1da673df
7
+ data.tar.gz: a7609ff5ec117bdc6351cfe0715436bb32d9b3e0c7b2e41849fbe7b2949f98be6c09e931f761054e22e36203f6c71cd10e8ad159f33adbb83400beea04197a45
data/.gitignore CHANGED
@@ -54,3 +54,4 @@ build-iPhoneSimulator/
54
54
 
55
55
  # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
56
  # .rubocop-https?--*
57
+ .vscode/settings.json
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in shufflino.gemspec
4
+ gemspec
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
@@ -0,0 +1,19 @@
1
+ test:
2
+ rake test
3
+
4
+ build:
5
+ rm pkg/*.gem
6
+ rake build
7
+
8
+ publish:
9
+ gem push pkg/*.gem
10
+ rm pkg/*.gem
11
+
12
+ push:
13
+ git push origin master
14
+
15
+ all: test build publish
16
+
17
+ .DEFAULT_GOAL := all
18
+
19
+ .PHONY: test
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
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ module Shufflino
2
+ class Helpers
3
+ def self.factorial(num)
4
+ return 1 if num < 1
5
+
6
+ num * factorial(num - 1)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Shufflino
2
+ VERSION = "0.1.1"
3
+ end
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.0
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: '10.0'
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: '10.0'
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