a1ify 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ab37b36a6bf0695d227790ba376d909fc1d24e0033c9b92dce98de3844caca2
4
+ data.tar.gz: 79b464f67bcb2a77cf28f3131e2d4b9ce5b0418c27c3d9edd95582e22da4e9d3
5
+ SHA512:
6
+ metadata.gz: d1d6c33a39a929703d7b917a5a5e06b16e7a742baaa2366750008154608243b7143409a0f67e123ad9c5ac77d7c36bd130d2508657c93ac1a02d07de2ed8b12e
7
+ data.tar.gz: 10739e88d0f3b7523d843cc5354f48a825a0465d38f45cac40560bb3fdc3c818b08a16c46b7eb890b80b04d69c592eb57943130b732e16abed3e444c0402588e
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in a1ify.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ a1ify (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ json (2.7.2)
11
+ language_server-protocol (3.17.0.4)
12
+ minitest (5.24.1)
13
+ parallel (1.25.1)
14
+ parser (3.3.3.0)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.8.0)
18
+ rainbow (3.1.1)
19
+ rake (13.2.1)
20
+ regexp_parser (2.9.2)
21
+ rexml (3.3.1)
22
+ strscan
23
+ rubocop (1.64.1)
24
+ json (~> 2.3)
25
+ language_server-protocol (>= 3.17.0)
26
+ parallel (~> 1.10)
27
+ parser (>= 3.3.0.2)
28
+ rainbow (>= 2.2.2, < 4.0)
29
+ regexp_parser (>= 1.8, < 3.0)
30
+ rexml (>= 3.2.5, < 4.0)
31
+ rubocop-ast (>= 1.31.1, < 2.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (>= 2.4.0, < 3.0)
34
+ rubocop-ast (1.31.3)
35
+ parser (>= 3.3.1.0)
36
+ ruby-progressbar (1.13.0)
37
+ strscan (3.1.0)
38
+ unicode-display_width (2.5.0)
39
+
40
+ PLATFORMS
41
+ x86_64-linux
42
+
43
+ DEPENDENCIES
44
+ a1ify!
45
+ minitest (~> 5.0)
46
+ rake (~> 13.0)
47
+ rubocop (~> 1.21)
48
+
49
+ BUNDLED WITH
50
+ 2.4.12
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Hokuto Shimura
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.ja.md ADDED
@@ -0,0 +1,47 @@
1
+ # A1ify
2
+
3
+ A1ify は、Excel の R1C1 形式のセル参照を標準的な A1 形式に変換する Ruby gem です。
4
+ 単一の値だけでなく、行と列の配列にも対応しており、あらゆる組み合わせの変換をサポートします。
5
+
6
+ ## 特徴
7
+
8
+ - **シンプルな変換:**
9
+ Excel の R1C1 参照を A1 形式にシンプルな API で簡単に変換できます。
10
+ - **柔軟な入力:**
11
+ 単一の値はもちろん、配列での入力も受け付け、すべての組み合わせを変換します。
12
+
13
+ ## インストール
14
+
15
+ ### RubyGems を使用する場合
16
+
17
+ ```bash
18
+ gem install a1ify
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ A1ify は、 A1ify::Converter クラスを通じて変換機能を提供します。
24
+
25
+ ### 単一の値の変換
26
+
27
+ ```ruby
28
+ require 'a1ify'
29
+
30
+ # 例: 行 3、列 3 のセル参照を変換("C3" となる)
31
+ result = A1ify::Converter.rc_to_a(3, 3)
32
+ puts result # => "C3"
33
+ ```
34
+ ### 配列での変換
35
+
36
+ ```ruby
37
+ require 'a1ify'
38
+
39
+
40
+ # 例: 行と列の配列を指定して、すべてのセル参照の組み合わせを変換
41
+ results = A1ify::Converter.rc_to_a([1, 2], [1, 2])
42
+ puts results.inspect # => ["A1", "A2", "B1", "B2"](列のアルファベット順にソートされた結果)
43
+ ```
44
+
45
+ ## License
46
+
47
+ A1ify は MIT ライセンスの下でリリースされています。
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # A1ify
2
+
3
+ [日本語版 READMEはこちら](README.ja.md)
4
+
5
+ A1ify is a Ruby gem that converts Excel R1C1 cell references to the standard A1 format. It supports conversion for both single values and arrays of rows and columns, handling all possible combinations.
6
+
7
+ ## Features
8
+
9
+ - **Simple Conversion:** Easily convert Excel R1C1 references to A1 format with a straightforward API.
10
+ - **Flexible Input:** Accepts both single values and arrays, converting every combination when arrays are provided.
11
+
12
+ ## Installation
13
+
14
+ ### Using RubyGems
15
+
16
+ ```bash
17
+ gem install a1ify
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ A1ify provides conversion functionality through the A1ify::Converter class.
23
+
24
+ ### Single Value Conversion
25
+
26
+ ```ruby
27
+ require 'a1ify'
28
+
29
+ # Convert a single cell reference (e.g., row 3, column 3 converts to "C3")
30
+ result = A1ify::Converter.rc_to_a(3, 3)
31
+ puts result # => "C3"
32
+ ```
33
+ ### Array Conversion
34
+
35
+ ```ruby
36
+ require 'a1ify'
37
+
38
+ # Convert multiple cell references by specifying arrays of rows and columns
39
+ results = A1ify::Converter.rc_to_a([1, 2], [1, 2])
40
+ puts results.inspect # => ["A1", "A2", "B1", "B2"] (sorted alphabetically by column)
41
+ ```
42
+
43
+ ## License
44
+
45
+ A1ify is released under the MIT License.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/a1ify.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/a1ify/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "a1ify"
7
+ spec.version = A1ify::VERSION
8
+ spec.authors = ["Hokuto Shimura"]
9
+ spec.email = ["hoqqun@gmail.com"]
10
+ spec.summary = "A Ruby gem for converting Excel R1C1 references to A1 format."
11
+ spec.description = <<~DESC
12
+ A1ify is a Ruby gem that converts Excel's R1C1 cell references into the standard A1 format.
13
+ It supports single or multiple references, handles boundary cases up to Excel's maximum
14
+ supported row and column, and returns sorted references for convenience. Whether you need
15
+ to generate or display cell references, A1ify provides a simple, efficient, and reliable solution.
16
+ DESC
17
+ spec.homepage = "https://github.com/hoqqun/a1ify"
18
+ spec.license = "MIT"
19
+ spec.required_ruby_version = ">= 2.6.0"
20
+
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+
23
+ spec.metadata["homepage_uri"] = spec.homepage
24
+ spec.metadata["source_code_uri"] = "https://github.com/hoqqun/a1ify"
25
+ spec.metadata["changelog_uri"] = "https://github.com/hoqqun/a1ify"
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(__dir__) do
30
+ `git ls-files -z`.split("\x0").reject do |f|
31
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
32
+ end
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
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, check out our
42
+ # guide at: https://bundler.io/guides/creating_gem.html
43
+ end
@@ -0,0 +1,33 @@
1
+ module A1ify
2
+ class Converter
3
+ # R1C1 → A1変換メソッド(単一値と配列の両方に対応)
4
+ def self.rc_to_a(rows, cols)
5
+ # 単一の値の場合、そのまま変換して返す
6
+ unless rows.is_a?(Array) || cols.is_a?(Array)
7
+ return convert_single_r1c1_to_a1(rows, cols)
8
+ end
9
+
10
+ # 配列で渡された場合、すべての組み合わせを処理
11
+ rows = [rows] unless rows.is_a?(Array)
12
+ cols = [cols] unless cols.is_a?(Array)
13
+
14
+ # 各 row, col の組み合わせを処理して変換
15
+ results = rows.product(cols).map { |row, col| convert_single_r1c1_to_a1(row, col) }
16
+
17
+ # アルファベット順(列優先)でソートして返す
18
+ results.sort
19
+ end
20
+
21
+ private
22
+
23
+ # 1つの R1C1 を A1形式に変換(再帰処理)
24
+ def self.convert_single_r1c1_to_a1(row, col, col_letter = "")
25
+ return "#{col_letter}#{row}" if col <= 0
26
+
27
+ col -= 1
28
+ current_char = (65 + (col % 26)).chr
29
+ convert_single_r1c1_to_a1(row, col / 26, current_char + col_letter)
30
+ end
31
+ private_class_method :convert_single_r1c1_to_a1
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A1ify
4
+ VERSION = "0.1.0"
5
+ end
data/lib/a1ify.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "a1ify/version"
4
+ require "a1ify/converter"
data/sig/a1ify.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module A1ify
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: a1ify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hokuto Shimura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-02-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ A1ify is a Ruby gem that converts Excel's R1C1 cell references into the standard A1 format.
15
+ It supports single or multiple references, handles boundary cases up to Excel's maximum
16
+ supported row and column, and returns sorted references for convenience. Whether you need
17
+ to generate or display cell references, A1ify provides a simple, efficient, and reliable solution.
18
+ email:
19
+ - hoqqun@gmail.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - ".rubocop.yml"
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.ja.md
29
+ - README.md
30
+ - Rakefile
31
+ - a1ify.gemspec
32
+ - lib/a1ify.rb
33
+ - lib/a1ify/converter.rb
34
+ - lib/a1ify/version.rb
35
+ - sig/a1ify.rbs
36
+ homepage: https://github.com/hoqqun/a1ify
37
+ licenses:
38
+ - MIT
39
+ metadata:
40
+ allowed_push_host: https://rubygems.org
41
+ homepage_uri: https://github.com/hoqqun/a1ify
42
+ source_code_uri: https://github.com/hoqqun/a1ify
43
+ changelog_uri: https://github.com/hoqqun/a1ify
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.6.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.4.10
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: A Ruby gem for converting Excel R1C1 references to A1 format.
63
+ test_files: []