jabara_group 0.1.1 → 0.2.0

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: 0ca9d89c93f215057eee63b887a66740e98428c85331c5107e2048fdd539b412
4
- data.tar.gz: cd8b46078972789810cb1e06e4a5fc2a99189c3d65188580c2763baa1f98748b
3
+ metadata.gz: f3146fa943e7c76cb41fea4a2a0029a0b3dcefb2d7cebdc63db124d6e70184db
4
+ data.tar.gz: 9101738b638da7d9bbc2ee1eab20368dc14da2e00b852cbaaca53ac9628f8146
5
5
  SHA512:
6
- metadata.gz: 58fc3536bc327c7992288b406e7cf599250911535f4123cef1299de5bc62be7befbb3a8f943ae8f236aaf13b2444a5e37a529b762e583ac69810d27fac049427
7
- data.tar.gz: 26ead80c4c0e3ad5b5f013528c555ba3eb5685e0d8b61377e3022d5e44b3e06cfa9bb68478051bf273749a81039b1d8a5b7ae56285c4c25ec0bada82acbb65e2
6
+ metadata.gz: 5889df9191b542cf47d51f497b894ecdf601a744aa71b6273a95a7946db975df832f8e21e1248c149bb353e80b299839409004ee2a87bc5b62b968079525bf5f
7
+ data.tar.gz: 7f245a6eba794a691f3d163d0cccf591d97cd7b10e9be885cf1f6715074f07f3fe0d0dfbce1d625e5d1d522073957a9fd3dd03f8a81a55f710d307f1ff2ba43f
@@ -9,15 +9,22 @@ on:
9
9
  jobs:
10
10
  test:
11
11
  runs-on: ubuntu-latest
12
+ if: >-
13
+ ${{!(false
14
+ || contains(github.event.head_commit.message, '[DOC]')
15
+ || contains(github.event.pull_request.title, '[DOC]')
16
+ )}}
17
+
12
18
  strategy:
13
19
  matrix:
14
- ruby-version: ['3.1', '3.0', '2.7']
20
+ ruby-version: ['3.1', '3.2', '3.3', '3.4']
15
21
  steps:
16
- - uses: actions/checkout@v3
22
+ - uses: actions/checkout@v4
17
23
  - name: Set up Ruby ${{ matrix.ruby-version }}
18
- uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
24
+ uses: ruby/setup-ruby@v1
19
25
  with:
20
26
  ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true
21
28
  - name: Install dependencies
22
29
  run: bundle install
23
30
  - name: Run tests
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2025-02-03)
4
+
5
+ * Add `Enumerable#jabara_for` method.
6
+
7
+ ## 0.1.1 (2025-02-03)
8
+
9
+ * Add RBS file.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JabaraGroup
2
2
 
3
- This gem add Enumerable#jabara(n) for jabara grouping.
3
+ This gem add `Enumerable#jabara(n)` for jabara grouping.
4
4
 
5
5
  ```
6
6
  [*1..6].jabara(3) # => [[1, 6], [2, 5], [3, 4]]
@@ -1,3 +1,3 @@
1
1
  module JabaraGroup
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/jabara_group.rb CHANGED
@@ -37,4 +37,18 @@ module Enumerable
37
37
  index += direction
38
38
  end
39
39
  end
40
+
41
+ # Divides +self+ for +keys+.
42
+ #
43
+ # This method divides +self+ into +self.size+ groups and returns a +Hash+ with +keys+ as keys and groups as values.
44
+ #
45
+ # ("a".."l").jabara_for(%w(A B C)) # => { "A" => ["a", "f", "g", "l"], "B" => ["b", "e", "h", "k"], "C" => ["c", "d", "i", "j"] }
46
+ #
47
+ # @param keys [Enumerable]
48
+ # @return [Hash<Object, Array<Object>>]
49
+ def jabara_for(keys)
50
+ keys_array = keys.to_a
51
+ groups = jabara(keys_array.size)
52
+ keys_array.zip(groups).to_h
53
+ end
40
54
  end
data/sig/jabara_group.rbs CHANGED
@@ -4,4 +4,5 @@ end
4
4
 
5
5
  module Enumerable[unchecked out Elem]
6
6
  def jabara: (Integer n) -> Array[Array[Elem]]
7
+ def jabara_for: [T] (Enumerable[T]) -> Hash[T, Array[Elem]]
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jabara_group
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Yanagita
@@ -73,6 +73,7 @@ extra_rdoc_files: []
73
73
  files:
74
74
  - ".github/workflows/test.yml"
75
75
  - ".gitignore"
76
+ - CHANGELOG.md
76
77
  - Gemfile
77
78
  - LICENSE.txt
78
79
  - README.md