rubyXL-addressing 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 +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +80 -0
- data/.travis.yml +13 -0
- data/Appraisals +12 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +15 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gemfiles/2.1.gemfile +7 -0
- data/gemfiles/2.5.gemfile +7 -0
- data/gemfiles/3.0.gemfile +7 -0
- data/gemfiles/3.1.gemfile +7 -0
- data/gemfiles/3.2.gemfile +7 -0
- data/gemfiles/3.3.gemfile +7 -0
- data/lib/rubyXL/address.rb +213 -0
- data/lib/rubyXL/addressing/version.rb +7 -0
- data/lib/rubyXL/addressing.rb +26 -0
- data/rubyXL-addressing.gemspec +32 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a251d2a6809a53c0336e2f33fb94fe7f323a946a
|
4
|
+
data.tar.gz: 6456b655fb52580ef39afca0b0bcb2c91e4047df
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b7e5352f1a0e0630932b0f4e9683754db30d5c66cb649f9bdd03d6a47ca5183a7775634f75fcce00862b9e7875da001b8933525d5dc1dfbbac3c073d355d06f
|
7
|
+
data.tar.gz: e62d77e745c40b33311abe10c46c486f78579c81f91147b1107e954af432aa708b85c0e347a1b9ab09b575ca65ba9702182b3ea0f83946021868b5325d064450
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- "*.gemspec"
|
4
|
+
- Appraisals
|
5
|
+
- Gemfile
|
6
|
+
- Rakefile
|
7
|
+
TargetRubyVersion: 2.1
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Exclude:
|
11
|
+
- test/**/*_test.rb
|
12
|
+
|
13
|
+
Metrics/ClassLength:
|
14
|
+
Exclude:
|
15
|
+
- lib/rubyXL/address.rb
|
16
|
+
- test/**/*_test.rb
|
17
|
+
|
18
|
+
Metrics/LineLength:
|
19
|
+
Exclude:
|
20
|
+
- "*.gemspec"
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
23
|
+
Exclude:
|
24
|
+
- test/**/*_test.rb
|
25
|
+
|
26
|
+
Style/ClassVars:
|
27
|
+
Exclude:
|
28
|
+
- test/**/*_test.rb
|
29
|
+
|
30
|
+
Style/Documentation:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# does not consider `frozen_string_literal: true`
|
34
|
+
Style/MutableConstant:
|
35
|
+
Exclude:
|
36
|
+
- lib/rubyXL/addressing/version.rb
|
37
|
+
|
38
|
+
Style/TrailingCommaInLiteral:
|
39
|
+
EnforcedStyleForMultiline: comma
|
40
|
+
|
41
|
+
### disabled.yml
|
42
|
+
|
43
|
+
Style/AutoResourceCleanup:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
Style/CollectionMethods:
|
47
|
+
Enabled: true
|
48
|
+
|
49
|
+
Style/FirstArrayElementLineBreak:
|
50
|
+
Enabled: true
|
51
|
+
|
52
|
+
Style/FirstHashElementLineBreak:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
Style/MultilineArrayBraceLayout:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Style/MultilineAssignmentLayout:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Style/MultilineHashBraceLayout:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Style/MultilineMethodCallBraceLayout:
|
65
|
+
Enabled: true
|
66
|
+
|
67
|
+
Style/MultilineMethodDefinitionBraceLayout:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Style/OptionHash:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
Style/Send:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
Style/StringMethods:
|
77
|
+
Enabled: true
|
78
|
+
|
79
|
+
Style/SymbolArray:
|
80
|
+
Enabled: true
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.8
|
4
|
+
- 2.2.4
|
5
|
+
- 2.3.0
|
6
|
+
gemfile:
|
7
|
+
- gemfiles/2.1.gemfile
|
8
|
+
- gemfiles/2.5.gemfile
|
9
|
+
- gemfiles/3.0.gemfile
|
10
|
+
- gemfiles/3.1.gemfile
|
11
|
+
- gemfiles/3.2.gemfile
|
12
|
+
- gemfiles/3.3.gemfile
|
13
|
+
before_install: gem install bundler -v 1.11.2
|
data/Appraisals
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at m.ishihara@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Masaki Takeuchi
|
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,86 @@
|
|
1
|
+
# rubyXL-addressing
|
2
|
+
|
3
|
+
Addressing for [rubyXL](https://github.com/weshatheleopard/rubyXL)
|
4
|
+
|
5
|
+
[](https://travis-ci.org/m4i/rubyXL-addressing)
|
6
|
+
[](https://codeclimate.com/github/m4i/rubyXL-addressing/coverage)
|
7
|
+
[](https://gemnasium.com/m4i/rubyXL-addressing)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'rubyXL-addressing'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install rubyXL-addressing
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### calculate C3 + F3
|
28
|
+
|
29
|
+
#### rubyXL
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
row_index, column_index_c = RubyXL::Reference.ref2ind('C3')
|
33
|
+
_, column_index_f = RubyXL::Reference.ref2ind('F3')
|
34
|
+
row = worksheet[row_index]
|
35
|
+
if row
|
36
|
+
cell_c = row[column_index_c]
|
37
|
+
cell_f = row[column_index_f]
|
38
|
+
if cell_c && cell_f
|
39
|
+
cell_c.value + cell_f.value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
#### rubyXL-addressing
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
c3 = worksheet.addr(:C3)
|
48
|
+
f3 = c3.column(:F) # or c3.right(3)
|
49
|
+
if c3.cell && f3.cell # or c3.exists?
|
50
|
+
c3.value + f3.value
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
### set value to C3
|
55
|
+
|
56
|
+
#### rubyXL
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
row_index, column_index = RubyXL::Reference.ref2ind('C3')
|
60
|
+
row = worksheet[row_index]
|
61
|
+
if row && row[column_index]
|
62
|
+
row[column_index].change_contents('foobar')
|
63
|
+
else
|
64
|
+
worksheet.add_cell(row_index, column_index, 'foobar')
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
#### rubyXL-addressing
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
worksheet.addr('C3').value = 'foobar'
|
72
|
+
```
|
73
|
+
|
74
|
+
## Development
|
75
|
+
|
76
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
77
|
+
|
78
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubyXL-addressing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'appraisal'
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.libs << 'test'
|
7
|
+
t.libs << 'lib'
|
8
|
+
t.test_files = FileList['test/**/*_test.rb']
|
9
|
+
end
|
10
|
+
|
11
|
+
if ENV['APPRAISAL_INITIALIZED'] || ENV['TRAVIS']
|
12
|
+
task default: :test
|
13
|
+
else
|
14
|
+
task default: :appraisal
|
15
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rubyXL/addressing'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyXL
|
4
|
+
class Address
|
5
|
+
ROW_REF_FORMAT = /\A[1-9]\d*\z/
|
6
|
+
COLUMN_REF_FORMAT = /\A[A-Z]+\z/
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# @param [Integer] ind
|
10
|
+
# @return [String]
|
11
|
+
def row_ind2ref(ind)
|
12
|
+
message = "invalid row #{ind.inspect}"
|
13
|
+
raise TypeError, message unless ind.is_a?(Integer)
|
14
|
+
raise ArgumentError, message unless ind >= 0
|
15
|
+
|
16
|
+
(ind + 1).to_s.freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [Integer] ind
|
20
|
+
# @return [String]
|
21
|
+
def column_ind2ref(ind)
|
22
|
+
message = "invalid column #{ind.inspect}"
|
23
|
+
raise TypeError, message unless ind.is_a?(Integer)
|
24
|
+
raise ArgumentError, message unless ind >= 0
|
25
|
+
|
26
|
+
ref = ''.dup
|
27
|
+
loop do
|
28
|
+
ref.prepend((ind % 26 + 65).chr)
|
29
|
+
ind /= 26
|
30
|
+
break if (ind -= 1) < 0
|
31
|
+
end
|
32
|
+
ref.freeze
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param [String, Symbol] ref
|
36
|
+
# @return [Integer]
|
37
|
+
def row_ref2ind(ref)
|
38
|
+
message = "invalid row #{ref.inspect}"
|
39
|
+
raise ArgumentError, message unless ROW_REF_FORMAT =~ ref
|
40
|
+
|
41
|
+
ref.to_s.to_i - 1
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param [String, Symbol] ref
|
45
|
+
# @return [Integer]
|
46
|
+
def column_ref2ind(ref)
|
47
|
+
message = "invalid column #{ref.inspect}"
|
48
|
+
raise ArgumentError, message unless COLUMN_REF_FORMAT =~ ref
|
49
|
+
|
50
|
+
ref.to_s.each_byte.reduce(0) { |a, e| a * 26 + (e - 64) } - 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param [RubyXL::Worksheet] worksheet
|
55
|
+
# @return [RubyXL::Worksheet]
|
56
|
+
attr_writer :worksheet
|
57
|
+
|
58
|
+
# @param [RubyXL::Worksheet] worksheet
|
59
|
+
# @param [String, Symbol] ref
|
60
|
+
# @param [Integer, String, Symbol] row
|
61
|
+
# @param [Integer, String, Symbol] column
|
62
|
+
def initialize(worksheet, ref: nil, row: nil, column: nil)
|
63
|
+
@worksheet = worksheet
|
64
|
+
|
65
|
+
row, column = Reference.ref2ind(ref) if ref
|
66
|
+
self.row = row
|
67
|
+
self.column = column
|
68
|
+
end
|
69
|
+
|
70
|
+
# @param [RubyXL::Worksheet, nil] worksheet
|
71
|
+
# @return [RubyXL::Workbook, RubyXL::Address]
|
72
|
+
def worksheet(worksheet = nil)
|
73
|
+
if worksheet.nil?
|
74
|
+
@worksheet
|
75
|
+
else
|
76
|
+
self.class.new(worksheet, row: @row, column: @column)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# @param [Integer, String, Symbol, nil] row
|
81
|
+
# @return [Integer, RubyXL::Address]
|
82
|
+
def row(row = nil)
|
83
|
+
if row.nil?
|
84
|
+
@row
|
85
|
+
else
|
86
|
+
self.class.new(@worksheet, row: row, column: @column)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# @param [Integer, String, Symbol, nil] column
|
91
|
+
# @return [Integer, RubyXL::Address]
|
92
|
+
def column(column = nil)
|
93
|
+
if column.nil?
|
94
|
+
@column
|
95
|
+
else
|
96
|
+
self.class.new(@worksheet, row: @row, column: column)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# @param [Integer, String, Symbol] row
|
101
|
+
# @return [Integer, String, Symbol]
|
102
|
+
def row=(row)
|
103
|
+
case row
|
104
|
+
when Integer
|
105
|
+
return @row = row if row >= 0
|
106
|
+
when String, Symbol
|
107
|
+
return self.row = self.class.row_ref2ind(row)
|
108
|
+
end
|
109
|
+
|
110
|
+
raise ArgumentError, "invalid row #{row.inspect}"
|
111
|
+
end
|
112
|
+
|
113
|
+
# @param [Integer, String, Symbol] column
|
114
|
+
# @return [Integer, String, Symbol]
|
115
|
+
def column=(column)
|
116
|
+
case column
|
117
|
+
when Integer
|
118
|
+
return @column = column if column >= 0
|
119
|
+
when String, Symbol
|
120
|
+
return self.column = self.class.column_ref2ind(column)
|
121
|
+
end
|
122
|
+
|
123
|
+
raise ArgumentError, "invalid column #{column.inspect}"
|
124
|
+
end
|
125
|
+
|
126
|
+
# @return [String]
|
127
|
+
def ref
|
128
|
+
Reference.ind2ref(@row, @column)
|
129
|
+
end
|
130
|
+
|
131
|
+
# @return [String]
|
132
|
+
def inspect
|
133
|
+
format('#<%s %s!%s>', self.class.name, @worksheet.sheet_name, ref)
|
134
|
+
end
|
135
|
+
|
136
|
+
# @param [Integer] amount
|
137
|
+
# @return [RubyXL::Address]
|
138
|
+
def up(amount = 1)
|
139
|
+
row(@row - amount)
|
140
|
+
end
|
141
|
+
|
142
|
+
# @param [Integer] amount
|
143
|
+
# @return [RubyXL::Address]
|
144
|
+
def down(amount = 1)
|
145
|
+
row(@row + amount)
|
146
|
+
end
|
147
|
+
|
148
|
+
# @param [Integer] amount
|
149
|
+
# @return [RubyXL::Address]
|
150
|
+
def left(amount = 1)
|
151
|
+
column(@column - amount)
|
152
|
+
end
|
153
|
+
|
154
|
+
# @param [Integer] amount
|
155
|
+
# @return [RubyXL::Address]
|
156
|
+
def right(amount = 1)
|
157
|
+
column(@column + amount)
|
158
|
+
end
|
159
|
+
|
160
|
+
# @param [Integer] amount
|
161
|
+
# @return [self]
|
162
|
+
def up!(amount = 1)
|
163
|
+
self.row -= amount
|
164
|
+
self
|
165
|
+
end
|
166
|
+
|
167
|
+
# @param [Integer] amount
|
168
|
+
# @return [self]
|
169
|
+
def down!(amount = 1)
|
170
|
+
self.row += amount
|
171
|
+
self
|
172
|
+
end
|
173
|
+
|
174
|
+
# @param [Integer] amount
|
175
|
+
# @return [self]
|
176
|
+
def left!(amount = 1)
|
177
|
+
self.column -= amount
|
178
|
+
self
|
179
|
+
end
|
180
|
+
|
181
|
+
# @param [Integer] amount
|
182
|
+
# @return [self]
|
183
|
+
def right!(amount = 1)
|
184
|
+
self.column += amount
|
185
|
+
self
|
186
|
+
end
|
187
|
+
|
188
|
+
# @return [RubyXL::Cell, nil]
|
189
|
+
def cell
|
190
|
+
(row = @worksheet[@row]) && row[@column]
|
191
|
+
end
|
192
|
+
|
193
|
+
# @return [Boolean]
|
194
|
+
def exists?
|
195
|
+
!cell.nil?
|
196
|
+
end
|
197
|
+
|
198
|
+
# @return [Object]
|
199
|
+
def value
|
200
|
+
cell && cell.value
|
201
|
+
end
|
202
|
+
|
203
|
+
# @param [Object] value
|
204
|
+
# @return [Object]
|
205
|
+
def value=(value)
|
206
|
+
if cell
|
207
|
+
cell.change_contents(value)
|
208
|
+
else
|
209
|
+
@worksheet.add_cell(@row, @column, value)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubyXL/addressing/version'
|
4
|
+
require 'rubyXL'
|
5
|
+
|
6
|
+
module RubyXL
|
7
|
+
autoload :Address, 'rubyXL/address'
|
8
|
+
|
9
|
+
module Addressing
|
10
|
+
# @param [String, Symbol, Integer] ref_or_row is ref `'A1'`
|
11
|
+
# or row index `0`
|
12
|
+
# or row label `'1'`
|
13
|
+
# @param [String, Symbol, Integer] column is column index `0`
|
14
|
+
# or column label `'A'`
|
15
|
+
# @return [RubyXL::Address]
|
16
|
+
def addr(ref_or_row, column = nil)
|
17
|
+
if column.nil?
|
18
|
+
Address.new(self, ref: ref_or_row)
|
19
|
+
else
|
20
|
+
Address.new(self, row: ref_or_row, column: column)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Worksheet.prepend(Addressing)
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rubyXL/addressing/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rubyXL-addressing'
|
9
|
+
spec.version = RubyXL::Addressing::VERSION
|
10
|
+
spec.authors = ['Masaki Takeuchi']
|
11
|
+
spec.email = ['m.ishihara@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Addressing for rubyXL.'
|
14
|
+
spec.description = 'rubyXL-addressing provides addressing for rubyXL.'
|
15
|
+
spec.homepage = 'https://github.com/m4i/rubyXL-addressing'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.required_ruby_version = '>= 2.1.0'
|
24
|
+
|
25
|
+
spec.add_dependency 'rubyXL', '>= 2.1.1'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
30
|
+
spec.add_development_dependency 'appraisal'
|
31
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyXL-addressing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masaki Takeuchi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubyXL
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: rubyXL-addressing provides addressing for rubyXL.
|
98
|
+
email:
|
99
|
+
- m.ishihara@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Appraisals
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- gemfiles/2.1.gemfile
|
116
|
+
- gemfiles/2.5.gemfile
|
117
|
+
- gemfiles/3.0.gemfile
|
118
|
+
- gemfiles/3.1.gemfile
|
119
|
+
- gemfiles/3.2.gemfile
|
120
|
+
- gemfiles/3.3.gemfile
|
121
|
+
- lib/rubyXL/address.rb
|
122
|
+
- lib/rubyXL/addressing.rb
|
123
|
+
- lib/rubyXL/addressing/version.rb
|
124
|
+
- rubyXL-addressing.gemspec
|
125
|
+
homepage: https://github.com/m4i/rubyXL-addressing
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.1.0
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.5.1
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Addressing for rubyXL.
|
149
|
+
test_files: []
|