xipai 0.0.1a → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/xipai/arrangement/base.rb +0 -1
- data/lib/xipai/arrangement/lottery.rb +10 -4
- data/lib/xipai/arrangement/order.rb +3 -1
- data/lib/xipai/arrangement/pair.rb +9 -5
- data/lib/xipai/arrangement/team.rb +3 -1
- data/lib/xipai/core.rb +8 -3
- data/lib/xipai/result.rb +0 -1
- data/lib/xipai/table_set.rb +6 -1
- data/lib/xipai/version.rb +1 -1
- data/lib/xipai.rb +1 -2
- metadata +5 -6
- data/xipai.gemspec +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa59e4bc8e489eaeeb14e86540c01ca05f23dcc1aea61159874e382b20ea41b
|
4
|
+
data.tar.gz: 37e82b54443848a72472cd7389af8db116177f37dea87f78cee243e43a00cef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c330bdfb0d5fcb61d47e9304b93fdc7b8798faeb1e0d25a52cffb51873da395fa0056f31d92bc36de84ac187769adc522b79b2483a0bf54b4598b2f2e731dd77
|
7
|
+
data.tar.gz: df9c2b748527bac6972075f502dfa3607269e6dce44503e5c6904c1bd38cd54a8c648407cca6ce6b7941b230a28a6f326a9e78fca5c863603c9c1a20a7651561
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Xipai
|
2
2
|
|
3
3
|
Reproducible based on seeds or random shuffling tool.
|
4
4
|
|
@@ -27,7 +27,7 @@ Commands:
|
|
27
27
|
xipai lottery -A, --items=ITEMS -m, --number-of-winners=N # Reproducible based on seeds or random shuffling, then extruct lottery winner.
|
28
28
|
xipai pair -K, --key-items=KEY_ITEMS -V, --value-items=VALUE_ITEMS # Reproducible based on seeds or random shuffling, then pairing key-items and value-items.
|
29
29
|
xipai replay -c, --replay-yaml=REPLAY_YAML # Replay shuffling with xipai-replay yaml
|
30
|
-
xipai order -A, --items=ITEMS
|
30
|
+
xipai order -A, --items=ITEMS # Reproducible based on seeds or random shuffling.
|
31
31
|
xipai team -A, --items=ITEMS -m, --number-of-members=N # Reproducible based on seeds or random shuffling, then create teams
|
32
32
|
xipai version # Show xipai version
|
33
33
|
```
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
3
|
+
require File.expand_path("../../xipai/core", File.dirname(__FILE__))
|
4
|
+
require File.expand_path("../../xipai/result", File.dirname(__FILE__))
|
5
|
+
require File.expand_path("../../xipai/arrangement/base", File.dirname(__FILE__))
|
4
6
|
require "optional"
|
7
|
+
require "json"
|
5
8
|
|
6
9
|
module Xipai
|
7
10
|
module Arrangement
|
@@ -21,9 +24,12 @@ module Xipai
|
|
21
24
|
|
22
25
|
def lottery(_items, _number_of_winners)
|
23
26
|
return Some[_number_of_winners].match do |m|
|
24
|
-
m.some(->(x){x
|
25
|
-
|
26
|
-
|
27
|
+
m.some(->(x){x > 0}) {|x|
|
28
|
+
_items.sample(x, random: Random.new(
|
29
|
+
JSON.generate(_items).bytes.reduce(:*)
|
30
|
+
))
|
31
|
+
}
|
32
|
+
m.some() {raise "Error: number_of_winners"}
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
3
|
+
require File.expand_path("../../xipai/core", File.dirname(__FILE__))
|
4
|
+
require File.expand_path("../../xipai/result", File.dirname(__FILE__))
|
5
|
+
require File.expand_path("../../xipai/arrangement/base", File.dirname(__FILE__))
|
4
6
|
|
5
7
|
module Xipai
|
6
8
|
module Arrangement
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
3
|
+
require File.expand_path("../../xipai/core", File.dirname(__FILE__))
|
4
|
+
require File.expand_path("../../xipai/result", File.dirname(__FILE__))
|
5
|
+
require File.expand_path("../../xipai/arrangement/base", File.dirname(__FILE__))
|
4
6
|
require "optional"
|
5
7
|
|
6
8
|
module Xipai
|
@@ -25,7 +27,7 @@ module Xipai
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def pair(_keys, _values)
|
28
|
-
return Hash[Some[{a:_keys.size, b: _values.size}].match { |m|
|
30
|
+
return Hash[Some[{a: _keys.size, b: _values.size}].match { |m|
|
29
31
|
m.some(->(x){x[:a] > x[:b]}) {
|
30
32
|
result = [].tap {|me|
|
31
33
|
_keys.each.with_index do |key, index|
|
@@ -47,9 +49,11 @@ module Xipai
|
|
47
49
|
}
|
48
50
|
}
|
49
51
|
m.some(->(x){x[:a] == x[:b]}) { |x|
|
50
|
-
[
|
51
|
-
|
52
|
-
|
52
|
+
result = [].tap {|me|
|
53
|
+
[*0..(x[:a].to_i-1)].each do |index|
|
54
|
+
me.push([_keys[index], _values[index]])
|
55
|
+
end
|
56
|
+
}
|
53
57
|
}
|
54
58
|
}]
|
55
59
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
3
|
+
require File.expand_path("../../xipai/core", File.dirname(__FILE__))
|
4
|
+
require File.expand_path("../../xipai/result", File.dirname(__FILE__))
|
5
|
+
require File.expand_path("../../xipai/arrangement/base", File.dirname(__FILE__))
|
4
6
|
|
5
7
|
module Xipai
|
6
8
|
module Arrangement
|
data/lib/xipai/core.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
require File.expand_path("../xipai", File.dirname(__FILE__))
|
3
|
+
require File.expand_path("../xipai/hashcode_generator", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
module Xipai
|
6
6
|
module Core
|
@@ -11,8 +11,13 @@ module Xipai
|
|
11
11
|
seed, hashcode = spinkle_hashcode_bytes(generate_seed(words), hashcode, opt)
|
12
12
|
|
13
13
|
random = seed == 0 ? Random.new : Random.new(seed)
|
14
|
-
|
15
|
-
shuffled =
|
14
|
+
normalized_items = normalize_items(items)
|
15
|
+
shuffled =
|
16
|
+
normalized_items.shuffle!(
|
17
|
+
random: Random.new(JSON.generate(
|
18
|
+
normalized_items.shuffle!(random: random)
|
19
|
+
).bytes.reduce(:+) + seed.to_i
|
20
|
+
))
|
16
21
|
return {
|
17
22
|
hashcode: hashcode,
|
18
23
|
shuffled: shuffled
|
data/lib/xipai/result.rb
CHANGED
data/lib/xipai/table_set.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
Dir.glob(
|
4
|
+
"arrangement/*.rb", base: File.dirname(__FILE__)
|
5
|
+
).each do |mode_name|
|
6
|
+
require "#{File.dirname(__FILE__)}/#{mode_name}"
|
7
|
+
end
|
8
|
+
|
4
9
|
require "yaml"
|
5
10
|
require "optional"
|
6
11
|
|
data/lib/xipai/version.rb
CHANGED
data/lib/xipai.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xipai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi IKEGAMI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- lib/xipai/result.rb
|
67
67
|
- lib/xipai/table_set.rb
|
68
68
|
- lib/xipai/version.rb
|
69
|
-
- xipai.gemspec
|
70
69
|
homepage: https://github.com/magicdrive/xipai
|
71
70
|
licenses:
|
72
71
|
- MIT
|
@@ -86,11 +85,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
85
|
version: 2.5.0
|
87
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
87
|
requirements:
|
89
|
-
- - "
|
88
|
+
- - ">="
|
90
89
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
90
|
+
version: '0'
|
92
91
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
92
|
+
rubygems_version: 3.0.3.1
|
94
93
|
signing_key:
|
95
94
|
specification_version: 4
|
96
95
|
summary: Reproducible based on seeds or random shuffling tool.
|
data/xipai.gemspec
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/xipai/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "xipai"
|
7
|
-
spec.version = Xipai::VERSION
|
8
|
-
spec.authors = ["Hiroshi IKEGAMI"]
|
9
|
-
spec.email = ["hiroshi.ikegami@magicdrive.jp"]
|
10
|
-
|
11
|
-
spec.summary = "Reproducible based on seeds or random shuffling tool."
|
12
|
-
spec.description = "Reproducible based on seeds or random shuffling tool."
|
13
|
-
spec.homepage = "https://github.com/magicdrive/xipai"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.5.0"
|
16
|
-
|
17
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
-
|
19
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
-
spec.metadata["changelog_uri"] = spec.homepage
|
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(__dir__)) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
spec.bindir = "exe"
|
32
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
-
|
34
|
-
spec.require_paths = ["lib"]
|
35
|
-
spec.add_runtime_dependency 'thor', '>= 1.0'
|
36
|
-
spec.add_runtime_dependency 'optional', '>= 0.0.7'
|
37
|
-
|
38
|
-
# Uncomment to register a new dependency of your gem
|
39
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
40
|
-
|
41
|
-
# For more information and examples about making a new gem, checkout our
|
42
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
43
|
-
end
|