jabara_group 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 +4 -4
- data/.github/workflows/test.yml +24 -0
- data/Steepfile +7 -0
- data/jabara_group.gemspec +4 -3
- data/lib/jabara_group/version.rb +1 -1
- data/lib/jabara_group.rb +17 -2
- data/sig/jabara_group.rbs +7 -0
- metadata +32 -20
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ca9d89c93f215057eee63b887a66740e98428c85331c5107e2048fdd539b412
|
4
|
+
data.tar.gz: cd8b46078972789810cb1e06e4a5fc2a99189c3d65188580c2763baa1f98748b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58fc3536bc327c7992288b406e7cf599250911535f4123cef1299de5bc62be7befbb3a8f943ae8f236aaf13b2444a5e37a529b762e583ac69810d27fac049427
|
7
|
+
data.tar.gz: 26ead80c4c0e3ad5b5f013528c555ba3eb5685e0d8b61377e3022d5e44b3e06cfa9bb68478051bf273749a81039b1d8a5b7ae56285c4c25ec0bada82acbb65e2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ['3.1', '3.0', '2.7']
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
18
|
+
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby-version }}
|
21
|
+
- name: Install dependencies
|
22
|
+
run: bundle install
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rake
|
data/Steepfile
ADDED
data/jabara_group.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "minitest"
|
28
|
+
spec.add_development_dependency "steep"
|
28
29
|
end
|
data/lib/jabara_group/version.rb
CHANGED
data/lib/jabara_group.rb
CHANGED
@@ -1,9 +1,24 @@
|
|
1
1
|
require "jabara_group/version"
|
2
2
|
|
3
3
|
module Enumerable
|
4
|
+
# Divides +self+ into +n+ groups.
|
5
|
+
#
|
6
|
+
# The distribution of elements is done as follows:
|
7
|
+
# The 1st element goes to the 1st group, the 2nd element goes to the 2nd group, ..., the nth element goes to the nth group.
|
8
|
+
# The n+1th element goes to the nth group, the n+2th element goes to the n-1th group, ..., the 2nth element goes to the 1st group.
|
9
|
+
# The 2n+1th element goes to the first group, the 2n+2th element goes to the 2nd group, and so on.
|
10
|
+
#
|
11
|
+
# Each group has <code>self.size / n</code> elements if <code>self.size % n == 0</code>.
|
12
|
+
# Otherwise, some groups have <code>(self.size / n) + 1</code> elements.
|
13
|
+
#
|
14
|
+
# ("a".."l").jabara(3) # => [["a", "f", "g", "l"], ["b", "e", "h", "k"], ["c", "d", "i", "j"]]
|
15
|
+
# ('a'..'m').jabara(3) # => [["a", "f", "g", "l", "m"], ["b", "e", "h", "k"], ["c", "d", "i", "j"]]
|
16
|
+
#
|
17
|
+
# @param n [Integer] the number of groups
|
18
|
+
# @return [Array<Array<Object>>]
|
4
19
|
def jabara(n)
|
5
|
-
raise ArgumentError.new(
|
6
|
-
return [
|
20
|
+
raise ArgumentError.new("must be positive") if n <= 0
|
21
|
+
return [to_a] if n == 1
|
7
22
|
|
8
23
|
index, direction = 0, 1
|
9
24
|
each_with_object(Array.new(n) { [] }) do |e, groups|
|
metadata
CHANGED
@@ -1,80 +1,93 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jabara_group
|
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
|
- Kouhei Yanagita
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-03 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '0'
|
20
19
|
type: :development
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '0'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rake
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
30
|
+
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
|
-
- - "
|
37
|
+
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: minitest
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
|
-
- - "
|
44
|
+
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '0'
|
48
47
|
type: :development
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
|
-
- - "
|
51
|
+
- - ">="
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
|
53
|
+
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: steep
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
56
68
|
email:
|
57
69
|
- yanagi@shakenbu.org
|
58
70
|
executables: []
|
59
71
|
extensions: []
|
60
72
|
extra_rdoc_files: []
|
61
73
|
files:
|
74
|
+
- ".github/workflows/test.yml"
|
62
75
|
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
76
|
- Gemfile
|
65
77
|
- LICENSE.txt
|
66
78
|
- README.md
|
67
79
|
- Rakefile
|
80
|
+
- Steepfile
|
68
81
|
- bin/console
|
69
82
|
- bin/setup
|
70
83
|
- jabara_group.gemspec
|
71
84
|
- lib/jabara_group.rb
|
72
85
|
- lib/jabara_group/version.rb
|
86
|
+
- sig/jabara_group.rbs
|
73
87
|
homepage: https://github.com/kyanagi/jabara_group
|
74
88
|
licenses:
|
75
89
|
- MIT
|
76
90
|
metadata: {}
|
77
|
-
post_install_message:
|
78
91
|
rdoc_options: []
|
79
92
|
require_paths:
|
80
93
|
- lib
|
@@ -89,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
102
|
- !ruby/object:Gem::Version
|
90
103
|
version: '0'
|
91
104
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
105
|
+
rubygems_version: 3.6.3
|
94
106
|
specification_version: 4
|
95
107
|
summary: Add Enumerable#jabara for jabara grouping
|
96
108
|
test_files: []
|