xipai 0.0.1a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +123 -0
- data/Rakefile +4 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/xipai +9 -0
- data/lib/xipai/arrangement/base.rb +72 -0
- data/lib/xipai/arrangement/lottery.rb +32 -0
- data/lib/xipai/arrangement/order.rb +25 -0
- data/lib/xipai/arrangement/pair.rb +58 -0
- data/lib/xipai/arrangement/team.rb +26 -0
- data/lib/xipai/cli.rb +91 -0
- data/lib/xipai/core.rb +47 -0
- data/lib/xipai/hashcode_generator.rb +27 -0
- data/lib/xipai/result.rb +98 -0
- data/lib/xipai/table_set.rb +99 -0
- data/lib/xipai/version.rb +5 -0
- data/lib/xipai.rb +27 -0
- data/xipai.gemspec +43 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d3897adf29572f68ed753e543f6a657c80e8d9f0aa9204c01431e548ab6f2d13
|
4
|
+
data.tar.gz: fd2df5a5a0144900a2b641f045120da82ab6c030cf2097434f825755b2203f31
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20c3bcf1519f376c7c0597f8bb2bb852ceb5e641b870a46eecb0636bbcb383d20126088433aaf39fe72ebedd7d8921caab0842c2bb97877386cfcdbeee3002ec
|
7
|
+
data.tar.gz: cc26e97198f66e15efc5c33e5dced3ff9114b5b95e3517a12cf2bb8aa0109d05ee03ecccf01b542785e3fbfd6ee5a21313af3633a0588f8352f68807264dd311
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hiroshi.ikegami@magicdrive.jp. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Hiroshi IKEGAMI
|
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/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# [WIP] Xipai
|
2
|
+
|
3
|
+
Reproducible based on seeds or random shuffling tool.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'xipai'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install xipai
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
$ xipai help
|
25
|
+
Commands:
|
26
|
+
xipai help [COMMAND] # Describe available commands or one specific command
|
27
|
+
xipai lottery -A, --items=ITEMS -m, --number-of-winners=N # Reproducible based on seeds or random shuffling, then extruct lottery winner.
|
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
|
+
xipai replay -c, --replay-yaml=REPLAY_YAML # Replay shuffling with xipai-replay yaml
|
30
|
+
xipai order -A, --items=ITEMS # Reproducible based on seeds or random shuffling.
|
31
|
+
xipai team -A, --items=ITEMS -m, --number-of-members=N # Reproducible based on seeds or random shuffling, then create teams
|
32
|
+
xipai version # Show xipai version
|
33
|
+
```
|
34
|
+
|
35
|
+
```
|
36
|
+
$ xipai help order
|
37
|
+
Usage:
|
38
|
+
xipai order -A, --items=ITEMS
|
39
|
+
|
40
|
+
Options:
|
41
|
+
-w, [--key-words=KEY_WORDS] # Comma-separated seed string
|
42
|
+
-c, [--hashcode=HASHCODE] # Hashcode to identify this randomization
|
43
|
+
-n, [--without-hashcode], [--no-without-hashcode] # Do not use hashcode for randomization
|
44
|
+
-A, --items=ITEMS # Items to be shuffled. (comma-separated)
|
45
|
+
-p, [--pretty], [--no-pretty] # Pretty print output.
|
46
|
+
-o, [--replay-output=REPLAY_OUTPUT] # Output xeplay-replay yaml to specified path
|
47
|
+
-v, [--verbose], [--no-verbose] # Verbose mode Output
|
48
|
+
|
49
|
+
Reproducible based on seeds or random shuffling, then ordered
|
50
|
+
```
|
51
|
+
|
52
|
+
```
|
53
|
+
$ xipai help lottery
|
54
|
+
Usage:
|
55
|
+
xipai lottery -A, --items=ITEMS -m, --number-of-winners=N
|
56
|
+
|
57
|
+
Options:
|
58
|
+
-m, --number-of-winners=N # Number of winners
|
59
|
+
-w, [--key-words=KEY_WORDS] # Comma-separated seed string
|
60
|
+
-c, [--hashcode=HASHCODE] # Hashcode to identify this randomization
|
61
|
+
-n, [--without-hashcode], [--no-without-hashcode] # Do not use hashcode for randomization
|
62
|
+
-A, --items=ITEMS # Items to be shuffled. (comma-separated)
|
63
|
+
-p, [--pretty], [--no-pretty] # Pretty print output.
|
64
|
+
-o, [--replay-output=REPLAY_OUTPUT] # Output xeplay-replay yaml to specified path
|
65
|
+
-v, [--verbose], [--no-verbose] # Verbose mode Output
|
66
|
+
|
67
|
+
Reproducible based on seeds or random shuffling, then extruct lottery winner.
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
```
|
72
|
+
$ xipai help pair
|
73
|
+
Usage:
|
74
|
+
xipai pair -K, --key-items=KEY_ITEMS -V, --value-items=VALUE_ITEMS
|
75
|
+
|
76
|
+
Options:
|
77
|
+
-w, [--key-words=KEY_WORDS] # Comma-separated seed string
|
78
|
+
-c, [--hashcode=HASHCODE] # Hashcode to identify this randomization
|
79
|
+
-n, [--without-hashcode], [--no-without-hashcode] # Do not use hashcode for randomization
|
80
|
+
-K, --key-items=KEY_ITEMS # Items to be shuffled. (comma-separated)
|
81
|
+
-V, --value-items=VALUE_ITEMS # Items to be shuffled. (comma-separated)
|
82
|
+
-p, [--pretty], [--no-pretty] # Pretty print output.
|
83
|
+
-o, [--replay-output=REPLAY_OUTPUT] # Output xeplay-replay yaml to specified path
|
84
|
+
-v, [--verbose], [--no-verbose] # Verbose mode Output
|
85
|
+
|
86
|
+
Reproducible based on seeds or random shuffling, then pairing key-items and value-items.
|
87
|
+
```
|
88
|
+
|
89
|
+
```
|
90
|
+
$ xipai help team
|
91
|
+
Usage:
|
92
|
+
xipai team -A, --items=ITEMS -m, --number-of-members=N
|
93
|
+
|
94
|
+
Options:
|
95
|
+
-m, --number-of-members=N # Number of team-members
|
96
|
+
-w, [--key-words=KEY_WORDS] # Comma-separated seed string
|
97
|
+
-c, [--hashcode=HASHCODE] # Hashcode to identify this randomization
|
98
|
+
-n, [--without-hashcode], [--no-without-hashcode] # Do not use hashcode for randomization
|
99
|
+
-A, --items=ITEMS # Items to be shuffled. (comma-separated)
|
100
|
+
-p, [--pretty], [--no-pretty] # Pretty print output.
|
101
|
+
-o, [--replay-output=REPLAY_OUTPUT] # Output xeplay-replay yaml to specified path
|
102
|
+
-v, [--verbose], [--no-verbose] # Verbose mode Output
|
103
|
+
|
104
|
+
Reproducible based on seeds or random shuffling, then create teams
|
105
|
+
```
|
106
|
+
|
107
|
+
## Development
|
108
|
+
|
109
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
110
|
+
|
111
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
|
115
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/magicdrive/xipai. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/magicdrive/xipai/blob/main/CODE_OF_CONDUCT.md).
|
116
|
+
|
117
|
+
## License
|
118
|
+
|
119
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
120
|
+
|
121
|
+
## Code of Conduct
|
122
|
+
|
123
|
+
Everyone interacting in the Xipai project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/magicdrive/xipai/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "xipai"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/xipai
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
4
|
+
require "yaml"
|
5
|
+
require "optional"
|
6
|
+
|
7
|
+
module Xipai
|
8
|
+
module Arrangement
|
9
|
+
class Base
|
10
|
+
|
11
|
+
attr_reader :params
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def attributes(*attrs)
|
15
|
+
define_method(:"__attributes__") {attrs}
|
16
|
+
private :"__attributes__"
|
17
|
+
end
|
18
|
+
|
19
|
+
def require_attributes(*attrs)
|
20
|
+
define_method(:"__require_attributes__") {attrs}
|
21
|
+
private :"__require_attributes__"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def __require_attributes__
|
26
|
+
#return %i(a b c)
|
27
|
+
end
|
28
|
+
|
29
|
+
def __attributes__
|
30
|
+
#return %i(a b c)
|
31
|
+
end
|
32
|
+
|
33
|
+
def valid!()
|
34
|
+
__require_attributes__.each do |key|
|
35
|
+
raise "Error: params-#{key} is null value." if [[],{},"",nil].include?(params[key])
|
36
|
+
end
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(_params)
|
41
|
+
@params = _params
|
42
|
+
end
|
43
|
+
|
44
|
+
def method_missing(method, *args)
|
45
|
+
before, result = method_missing_hook(method, *args)
|
46
|
+
if before
|
47
|
+
return result
|
48
|
+
elsif params.has_key?(:"#{method}")
|
49
|
+
return params[:"#{method}"]
|
50
|
+
end
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def method_missing_hook(method, *args)
|
55
|
+
return false, nil
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_replay_data
|
59
|
+
return __attributes__.inject({}) do |memo, attribute_name|
|
60
|
+
memo[attribute_name] = params[attribute_name]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def dump_replay_yaml(path)
|
65
|
+
raise "Error: replay_yaml path is nil." if path.nil?
|
66
|
+
FileUtils.mkdir_p(File.dirname(path))
|
67
|
+
YAML.dump(self.to_replay_data, File.open(path, "w"))
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
4
|
+
require "optional"
|
5
|
+
|
6
|
+
module Xipai
|
7
|
+
module Arrangement
|
8
|
+
class Lottery < Xipai::Arrangement::Base
|
9
|
+
|
10
|
+
attributes :mode, :key_words, :hashcode, :without_hashcode, :pretty, :items, :number_of_winners
|
11
|
+
require_attributes :mode, :items, :number_of_winners
|
12
|
+
|
13
|
+
def apply
|
14
|
+
_hashcode, _shuffled = Xipai::Core.scrumble!(
|
15
|
+
key_words, hashcode, items, params
|
16
|
+
).tap {|me| break *[me[:hashcode], me[:shuffled]]}
|
17
|
+
_result_set = lottery(_shuffled, number_of_winners)
|
18
|
+
|
19
|
+
return Xipai::Result.new(mode, _hashcode, _result_set, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def lottery(_items, _number_of_winners)
|
23
|
+
return Some[_number_of_winners].match do |m|
|
24
|
+
m.some(->(x){x == 1}) {[_items[0]]}
|
25
|
+
m.some(->(x){x > 0}) {|x|_items[0..(x-1)]}
|
26
|
+
m.some() {raise "error: number_of_winners"}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
module Xipai
|
6
|
+
module Arrangement
|
7
|
+
class Order < Xipai::Arrangement::Base
|
8
|
+
attributes :mode, :key_words, :hashcode, :without_hashcode, :items
|
9
|
+
require_attributes :mode, :items
|
10
|
+
|
11
|
+
def apply
|
12
|
+
_hashcode, _shuffled = Xipai::Core.scrumble!(
|
13
|
+
key_words, hashcode, items, params
|
14
|
+
).tap {|me| break *[me[:hashcode], me[:shuffled]]}
|
15
|
+
result_set = single(_shuffled)
|
16
|
+
|
17
|
+
return Xipai::Result.new(mode, _hashcode, result_set, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def single(_items)
|
21
|
+
return _items
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
4
|
+
require "optional"
|
5
|
+
|
6
|
+
module Xipai
|
7
|
+
module Arrangement
|
8
|
+
class Pair < Xipai::Arrangement::Base
|
9
|
+
|
10
|
+
attributes :mode, :key_words, :hashcode, :without_hashcode, :key_items, :pretty, :value_items
|
11
|
+
require_attributes :mode, :key_items, :value_items
|
12
|
+
|
13
|
+
def apply
|
14
|
+
_hashcode, _shuffled_keys = Xipai::Core.scrumble!(
|
15
|
+
key_words, hashcode, key_items, params
|
16
|
+
).tap {|me| break *[me[:hashcode], me[:shuffled]]}
|
17
|
+
|
18
|
+
_hashcode, _shuffled_values = Xipai::Core.scrumble!(
|
19
|
+
key_words, _hashcode, value_items, {}
|
20
|
+
).tap {|me| break *[me[:hashcode], me[:shuffled]]}
|
21
|
+
|
22
|
+
result_set = pair(_shuffled_keys, _shuffled_values)
|
23
|
+
|
24
|
+
return Xipai::Result.new(mode, _hashcode, result_set, params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def pair(_keys, _values)
|
28
|
+
return Hash[Some[{a:_keys.size, b: _values.size}].match { |m|
|
29
|
+
m.some(->(x){x[:a] > x[:b]}) {
|
30
|
+
result = [].tap {|me|
|
31
|
+
_keys.each.with_index do |key, index|
|
32
|
+
Some[_values[index]].match do |mat|
|
33
|
+
mat.some(->(x){!x.nil?}) { me.push([key, _values[index]]) }
|
34
|
+
mat.some(->(x){ x.nil?}) { me.push([key, :null]) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
}
|
38
|
+
}
|
39
|
+
m.some(->(x){x[:a] < x[:b]}) {
|
40
|
+
result = [].tap {|me|
|
41
|
+
_values.each.with_index do |value, index|
|
42
|
+
Some[_keys[index]].match do |mat|
|
43
|
+
mat.some(->(x){!x.nil?}) { me.push([key[index], value]) }
|
44
|
+
mat.some(->(x){ x.nil?}) { me.push([index.to_s, value]) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
}
|
48
|
+
}
|
49
|
+
m.some(->(x){x[:a] == x[:b]}) { |x|
|
50
|
+
[*0..x[:a].to_i].map do |index|
|
51
|
+
result.push([_keys[index], _values[index]])
|
52
|
+
end
|
53
|
+
}
|
54
|
+
}]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../../xipai", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
module Xipai
|
6
|
+
module Arrangement
|
7
|
+
class Team < Xipai::Arrangement::Base
|
8
|
+
attributes :mode, :key_words, :hashcode, :without_hashcode, :pretty, :items, :number_of_members
|
9
|
+
require_attributes :mode, :items, :number_of_members
|
10
|
+
|
11
|
+
def apply
|
12
|
+
_hashcode, _shuffled = Xipai::Core.scrumble!(
|
13
|
+
key_words, hashcode, items, params
|
14
|
+
).tap {|me| break *[me[:hashcode], me[:shuffled]]}
|
15
|
+
result_set = team(_shuffled, number_of_members)
|
16
|
+
|
17
|
+
return Xipai::Result.new(mode, _hashcode, result_set, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def team(_items, _number_of_members)
|
21
|
+
return _items.each_slice(_number_of_members).to_a
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/xipai/cli.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'fileutils'
|
5
|
+
require File.expand_path("../xipai", File.dirname(__FILE__))
|
6
|
+
|
7
|
+
module Xipai
|
8
|
+
class CLI < Thor
|
9
|
+
|
10
|
+
default_command :help
|
11
|
+
|
12
|
+
desc "version", "Show xipai version"
|
13
|
+
def version
|
14
|
+
$stdout.puts Xipai::VERSION
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "replay", "Replay shuffling with xipai-replay yaml"
|
18
|
+
option :"replay_yaml", aliases: "-c", type: :string, required: true, desc: "Xipai replay config defined yaml file."
|
19
|
+
option :"replay_output", aliases: "-o", type: :string, default: "", desc: "Output xipai-replay yaml to specified path"
|
20
|
+
option :"verbose", aliases: "-v", type: :boolean, default: false, desc: "Verbose mode Output (Show yamldata string)"
|
21
|
+
def replay()
|
22
|
+
yamldata = File.read(options[:"replay_yaml"])
|
23
|
+
$stdout.puts yamldata if options[:verbose]
|
24
|
+
finalize Xipai.replay!(yamldata, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "order", "Reproducible based on seeds or random shuffling, then ordered"
|
28
|
+
option :"key_words", aliases: "-w", type: :string, default: "", desc: "Comma-separated seed string"
|
29
|
+
option :"hashcode", aliases: "-c", type: :string, default: "", desc: "Hashcode to identify this randomization"
|
30
|
+
option :"without_hashcode", aliases: "-n", type: :boolean, default: false, desc: "Do not use hashcode for randomization"
|
31
|
+
option :"items", aliases: "-A", type: :string, required: true, desc: "Items to be shuffled. (comma-separated)"
|
32
|
+
option :"pretty", aliases: "-p", type: :boolean, default: false, desc: "Pretty print output."
|
33
|
+
option :"replay_output", aliases: "-o", type: :string, default: "", desc: "Output xeplay-replay yaml to specified path"
|
34
|
+
option :"verbose", aliases: "-v", type: :boolean, default: false, desc: "Verbose mode Output"
|
35
|
+
def order()
|
36
|
+
finalize Xipai.lets_do_this!(:order, options)
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "team", "Reproducible based on seeds or random shuffling, then create teams"
|
40
|
+
option :"number_of_members", aliases: "-m", type: :numeric, required: true, desc: "Number of team-members"
|
41
|
+
option :"key_words", aliases: "-w", type: :string, default: "", desc: "Comma-separated seed string"
|
42
|
+
option :"hashcode", aliases: "-c", type: :string, default: "", desc: "Hashcode to identify this randomization"
|
43
|
+
option :"without_hashcode", aliases: "-n", type: :boolean, default: false, desc: "Do not use hashcode for randomization"
|
44
|
+
option :"items", aliases: "-A", type: :string, required: true, desc: "Items to be shuffled. (comma-separated)"
|
45
|
+
option :"pretty", aliases: "-p", type: :boolean, default: false, desc: "Pretty print output."
|
46
|
+
option :"replay_output", aliases: "-o", type: :string, default: "", desc: "Output xeplay-replay yaml to specified path"
|
47
|
+
option :"verbose", aliases: "-v", type: :boolean, default: false, desc: "Verbose mode Output"
|
48
|
+
def team()
|
49
|
+
finalize Xipai.lets_do_this!(:team, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "lottery", "Reproducible based on seeds or random shuffling, then extruct lottery winner."
|
53
|
+
option :"number_of_winners", aliases: "-m", type: :numeric, required: true, desc: "Number of winners"
|
54
|
+
option :"key_words", aliases: "-w", type: :string, default: "", desc: "Comma-separated seed string"
|
55
|
+
option :"hashcode", aliases: "-c", type: :string, default: "", desc: "Hashcode to identify this randomization"
|
56
|
+
option :"without_hashcode", aliases: "-n", type: :boolean, default: false, desc: "Do not use hashcode for randomization"
|
57
|
+
option :"items", aliases: "-A", type: :string, required: true, desc: "Items to be shuffled. (comma-separated)"
|
58
|
+
option :"pretty", aliases: "-p", type: :boolean, default: false, desc: "Pretty print output."
|
59
|
+
option :"replay_output", aliases: "-o", type: :string, default: "", desc: "Output xeplay-replay yaml to specified path"
|
60
|
+
option :"verbose", aliases: "-v", type: :boolean, default: false, desc: "Verbose mode Output"
|
61
|
+
def lottery()
|
62
|
+
finalize Xipai.lets_do_this!(:lottery, options)
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "pair", "Reproducible based on seeds or random shuffling, then pairing key-items and value-items."
|
66
|
+
option :"key_words", aliases: "-w", type: :string, default: "", desc: "Comma-separated seed string"
|
67
|
+
option :"hashcode", aliases: "-c", type: :string, default: "", desc: "Hashcode to identify this randomization"
|
68
|
+
option :"without_hashcode", aliases: "-n", type: :boolean, default: false, desc: "Do not use hashcode for randomization"
|
69
|
+
option :"key_items", aliases: "-K", type: :string, required: true, desc: "Items to be shuffled. (comma-separated)"
|
70
|
+
option :"value_items", aliases: "-V", type: :string, required: true, desc: "Items to be shuffled. (comma-separated)"
|
71
|
+
option :"pretty", aliases: "-p", type: :boolean, default: false, desc: "Pretty print output."
|
72
|
+
option :"replay_output", aliases: "-o", type: :string, default: "", desc: "Output xeplay-replay yaml to specified path"
|
73
|
+
option :"verbose", aliases: "-v", type: :boolean, default: false, desc: "Verbose mode Output"
|
74
|
+
def pair()
|
75
|
+
finalize Xipai.lets_do_this!(:pair, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
def finalize(xipai_result)
|
80
|
+
$stdout.puts xipai_result.data_json
|
81
|
+
dump_replay_yaml(xipai_result) if xipai_result.replay_output?
|
82
|
+
end
|
83
|
+
|
84
|
+
def dump_replay_yaml(xipai_result)
|
85
|
+
raise "error: replay_yaml path is nil." if xipai_result.replay_output_path.nil?
|
86
|
+
FileUtils.mkdir_p(File.dirname(xipai_result.replay_output_path))
|
87
|
+
YAML.dump(xipai_result.replay_data, File.open(xipai_result.replay_output_path, "w"))
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
data/lib/xipai/core.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
require File.expand_path("../xipai", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
module Xipai
|
6
|
+
module Core
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def scrumble!(words, hashcode, items, opt = {})
|
11
|
+
seed, hashcode = spinkle_hashcode_bytes(generate_seed(words), hashcode, opt)
|
12
|
+
|
13
|
+
random = seed == 0 ? Random.new : Random.new(seed)
|
14
|
+
|
15
|
+
shuffled = normalize_items(items).shuffle!(random: random)
|
16
|
+
return {
|
17
|
+
hashcode: hashcode,
|
18
|
+
shuffled: shuffled
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def normalize_items(items)
|
24
|
+
return items.map {|item| item.strip}
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_seed(words)
|
28
|
+
return seed = words.map {|item|
|
29
|
+
item.bytes.reduce(:*)
|
30
|
+
}.reduce(:+)
|
31
|
+
end
|
32
|
+
|
33
|
+
def spinkle_hashcode_bytes(seed, hashcode, opt = {})
|
34
|
+
_hashcode = Xipai::HashcodeGenerator.generate_or_existing(hashcode)
|
35
|
+
_hashcode = nil if [true, "true", 1, "without_hashcode"].include?(opt[:without_hashcode])
|
36
|
+
|
37
|
+
seed = 0 if seed.nil?
|
38
|
+
seed += _hashcode.bytes.reduce(:*) unless [nil, ""].include?(_hashcode)
|
39
|
+
|
40
|
+
return seed, _hashcode
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "digest/sha2"
|
4
|
+
require "time"
|
5
|
+
require "securerandom"
|
6
|
+
|
7
|
+
|
8
|
+
module Xipai
|
9
|
+
module HashcodeGenerator
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def random_hashcode()
|
13
|
+
digit_seed =
|
14
|
+
"#{self.name.object_id}-#{$$}-#{Time.now.to_i}-#{SecureRandom.hex(16)}-#{SecureRandom.hex(16)}}"
|
15
|
+
_hashcode_ = Digest::SHA256.hexdigest(digit_seed)[0 .. 16]
|
16
|
+
return _hashcode_
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_or_existing(hashcode)
|
20
|
+
return random_hashcode if ["", nil].include?(hashcode)
|
21
|
+
return hashcode
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
data/lib/xipai/result.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../xipai", File.dirname(__FILE__))
|
4
|
+
require "json"
|
5
|
+
require "time"
|
6
|
+
require "optional"
|
7
|
+
|
8
|
+
module Xipai
|
9
|
+
class Result
|
10
|
+
|
11
|
+
attr_accessor :timestamp, :mode, :hashcode, :result, :options
|
12
|
+
|
13
|
+
def initialize(_mode, _hashcode, _set, _options)
|
14
|
+
@timestamp = Time.now
|
15
|
+
@mode = _mode
|
16
|
+
@hashcode = _hashcode
|
17
|
+
@result = _set
|
18
|
+
@options = _options
|
19
|
+
end
|
20
|
+
|
21
|
+
def data_json
|
22
|
+
data = Some[options].match do |m|
|
23
|
+
m.some(->(x){["true" , true, 1, "verbose"].include?(x[:verbose])}) {
|
24
|
+
{
|
25
|
+
timestamp: timestamp,
|
26
|
+
mode: mode,
|
27
|
+
hashcode: hashcode,
|
28
|
+
result: result,
|
29
|
+
options: options
|
30
|
+
}
|
31
|
+
}
|
32
|
+
m.some(->(x){["false", false, 0, nil, ""].include?(x[:verbose]) }) {
|
33
|
+
{
|
34
|
+
mode: mode,
|
35
|
+
hashcode: hashcode,
|
36
|
+
result: result,
|
37
|
+
}
|
38
|
+
}
|
39
|
+
m.some {raise "Error: verbose mode option value is invalid."}
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
data = Some[options].match do |m|
|
44
|
+
m.some(->(x){["true", true, 1, "without_hashcode"].include?(x[:without_hashcode]) }) {
|
45
|
+
data.delete(:hashcode)
|
46
|
+
data
|
47
|
+
}
|
48
|
+
m.some(->(x){["false", false, 0, "", nil].include?(x[:without_hashcode]) }) {
|
49
|
+
data
|
50
|
+
}
|
51
|
+
m.some {raise "Error: without_hashcode option value is invalid."}
|
52
|
+
end
|
53
|
+
|
54
|
+
return data_json_string(data)
|
55
|
+
end
|
56
|
+
|
57
|
+
def replay_data
|
58
|
+
return hash_deep_stringize(options.dup.tap {|me|
|
59
|
+
me.delete(:replay_output)
|
60
|
+
me[:mode] = me[:mode].to_s
|
61
|
+
})
|
62
|
+
end
|
63
|
+
|
64
|
+
def replay_output_path
|
65
|
+
return nil if [nil, ""].include?(options[:replay_output])
|
66
|
+
basename = File.basename(options[:replay_output]).tap {|me|
|
67
|
+
break me += ".xipai-replay.yaml" if me !~ /\A(?:.*\.(?:yaml|yml))\z/xo
|
68
|
+
}
|
69
|
+
return "#{File.dirname(options[:replay_output])}/#{basename}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def replay_output?
|
73
|
+
return ![nil, ""].include?(options[:replay_output])
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
def data_json_string(hash)
|
78
|
+
return Some[options[:pretty]].match do |m|
|
79
|
+
m.some(->(x){["true" , true, 1, "pretty"].include?(x)}) { JSON.pretty_generate(hash) }
|
80
|
+
m.some(->(x){["false", false, 0, nil, ""].include?(x)}) { JSON.generate(hash) }
|
81
|
+
m.some { raise "Error: pretty option value is invalid." }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def hash_deep_stringize(obj)
|
86
|
+
return Some[obj].match do |m|
|
87
|
+
m.some(->(x){x.is_a?(Hash)}) {
|
88
|
+
obj.inject({}){|memo,(k,v)| memo[k.to_s] = hash_deep_stringize(v); memo}
|
89
|
+
}
|
90
|
+
m.some(->(x){x.is_a?(Array)}) {
|
91
|
+
obj.inject([]){|memo,v| memo << hash_deep_stringize(v); memo}
|
92
|
+
}
|
93
|
+
m.some {obj}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../xipai", File.dirname(__FILE__))
|
4
|
+
require "yaml"
|
5
|
+
require "optional"
|
6
|
+
|
7
|
+
module Xipai
|
8
|
+
module TableSet
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def parse_yaml(yamldata)
|
13
|
+
data = hash_deep_symbolize(YAML.load(yamldata))
|
14
|
+
return arrange(data[:mode], data)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_options(mode, options)
|
18
|
+
return arrange(mode, hash_deep_symbolize(options))
|
19
|
+
end
|
20
|
+
|
21
|
+
def arrange(mode, attrs)
|
22
|
+
params = {}
|
23
|
+
Some[mode.intern].match do |m|
|
24
|
+
m.some(->(x){x == :team}) {
|
25
|
+
params[:mode] = mode.intern
|
26
|
+
params[:key_words] = normalize_csv_array(attrs[:key_words])
|
27
|
+
params[:hashcode] = attrs[:hashcode]
|
28
|
+
params[:without_hashcode] = attrs[:without_hashcode]
|
29
|
+
params[:pretty] = attrs[:pretty]
|
30
|
+
params[:items] = normalize_csv_array(attrs[:items])
|
31
|
+
params[:number_of_members] = attrs[:number_of_members]
|
32
|
+
params[:verbose] = attrs[:verbose]
|
33
|
+
params[:replay_output] = attrs[:replay_output]
|
34
|
+
}
|
35
|
+
m.some(->(x){x == :lottery}) {
|
36
|
+
params[:mode] = mode.intern
|
37
|
+
params[:key_words] = normalize_csv_array(attrs[:key_words])
|
38
|
+
params[:hashcode] = attrs[:hashcode]
|
39
|
+
params[:without_hashcode] = attrs[:without_hashcode]
|
40
|
+
params[:pretty] = attrs[:pretty]
|
41
|
+
params[:items] = normalize_csv_array(attrs[:items])
|
42
|
+
params[:number_of_winners] = attrs[:number_of_winners]
|
43
|
+
params[:verbose] = attrs[:verbose]
|
44
|
+
params[:replay_output] = attrs[:replay_output]
|
45
|
+
}
|
46
|
+
m.some(->(x){x == :pair}) {
|
47
|
+
params[:mode] = mode.intern
|
48
|
+
params[:key_words] = normalize_csv_array(attrs[:key_words])
|
49
|
+
params[:hashcode] = attrs[:hashcode]
|
50
|
+
params[:without_hashcode] = attrs[:without_hashcode]
|
51
|
+
params[:key_items] = normalize_csv_array(attrs[:key_items])
|
52
|
+
params[:pretty] = attrs[:pretty]
|
53
|
+
params[:value_items] = normalize_csv_array(attrs[:value_items])
|
54
|
+
params[:verbose] = attrs[:verbose]
|
55
|
+
params[:replay_output] = attrs[:replay_output]
|
56
|
+
}
|
57
|
+
m.some(->(x){x == :order}) {
|
58
|
+
params[:mode] = mode.intern
|
59
|
+
params[:key_words] = normalize_csv_array(attrs[:key_words])
|
60
|
+
params[:hashcode] = attrs[:hashcode]
|
61
|
+
params[:without_hashcode] = attrs[:without_hashcode]
|
62
|
+
params[:pretty] = attrs[:pretty]
|
63
|
+
params[:items] = normalize_csv_array(attrs[:items])
|
64
|
+
params[:verbose] = attrs[:verbose]
|
65
|
+
params[:replay_output] = attrs[:replay_output]
|
66
|
+
}
|
67
|
+
m.some {raise "Error: mode invalid."}
|
68
|
+
end
|
69
|
+
|
70
|
+
table = Object.const_get("Xipai::Arrangement::#{mode.capitalize}").new(hash_deep_symbolize(params))
|
71
|
+
|
72
|
+
return table if table.valid!
|
73
|
+
end
|
74
|
+
|
75
|
+
def normalize_csv_array(obj)
|
76
|
+
return Some[obj].match do |m|
|
77
|
+
m.some(->(x){x.is_a?(String)}) {
|
78
|
+
obj == "" ? [] : obj.split(",").map(&:strip)
|
79
|
+
}
|
80
|
+
m.some(->(x){x.is_a?(Array)}) { obj }
|
81
|
+
m.some { "Error: normalize_csv_array invalid value(s)."}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def hash_deep_symbolize(obj)
|
86
|
+
return Some[obj].match do |m|
|
87
|
+
m.some(->(x){x.is_a?(Hash)}) {
|
88
|
+
obj.inject({}){|memo,(k,v)| memo[k.to_s.intern] = hash_deep_symbolize(v); memo}
|
89
|
+
}
|
90
|
+
m.some(->(x){x.is_a?(Array)}) {
|
91
|
+
obj.inject([]){|memo,v| memo << hash_deep_symbolize(v); memo}
|
92
|
+
}
|
93
|
+
m.some {obj}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/xipai.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Dir.glob(
|
4
|
+
File.expand_path("xipai/**/*.rb", File.dirname(__FILE__)
|
5
|
+
)).each do |mod_name|
|
6
|
+
require_relative "#{mod_name}"
|
7
|
+
end
|
8
|
+
|
9
|
+
require "ostruct"
|
10
|
+
|
11
|
+
module Xipai
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def lets_do_this!(_mode, _options)
|
15
|
+
xipai = Xipai::TableSet.parse_options(_mode, _options)
|
16
|
+
result = xipai.apply
|
17
|
+
return result
|
18
|
+
end
|
19
|
+
|
20
|
+
def replay!(yamldata, _options)
|
21
|
+
xipai = Xipai::TableSet.parse_yaml(yamldata)
|
22
|
+
result = xipai.apply
|
23
|
+
return result
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/xipai.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xipai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1a
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hiroshi IKEGAMI
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: optional
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.7
|
41
|
+
description: Reproducible based on seeds or random shuffling tool.
|
42
|
+
email:
|
43
|
+
- hiroshi.ikegami@magicdrive.jp
|
44
|
+
executables:
|
45
|
+
- xipai
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- CODE_OF_CONDUCT.md
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- exe/xipai
|
57
|
+
- lib/xipai.rb
|
58
|
+
- lib/xipai/arrangement/base.rb
|
59
|
+
- lib/xipai/arrangement/lottery.rb
|
60
|
+
- lib/xipai/arrangement/order.rb
|
61
|
+
- lib/xipai/arrangement/pair.rb
|
62
|
+
- lib/xipai/arrangement/team.rb
|
63
|
+
- lib/xipai/cli.rb
|
64
|
+
- lib/xipai/core.rb
|
65
|
+
- lib/xipai/hashcode_generator.rb
|
66
|
+
- lib/xipai/result.rb
|
67
|
+
- lib/xipai/table_set.rb
|
68
|
+
- lib/xipai/version.rb
|
69
|
+
- xipai.gemspec
|
70
|
+
homepage: https://github.com/magicdrive/xipai
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata:
|
74
|
+
allowed_push_host: https://rubygems.org
|
75
|
+
homepage_uri: https://github.com/magicdrive/xipai
|
76
|
+
source_code_uri: https://github.com/magicdrive/xipai
|
77
|
+
changelog_uri: https://github.com/magicdrive/xipai
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.5.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.3.1
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.2.22
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Reproducible based on seeds or random shuffling tool.
|
97
|
+
test_files: []
|