spreadsheet_goodies 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cb1da443d319f91e093023601d1688081db8344
4
- data.tar.gz: 10d6c084df8ae3da6ba1a1322805750d52191a3d
3
+ metadata.gz: 179fded79581bca98e1f46e8773d57eef7c37339
4
+ data.tar.gz: fe362c12b5c63564b34d93a0a8d43678929e56ec
5
5
  SHA512:
6
- metadata.gz: ec886820ca483030f181f1d82542660aa9f54a898f9d0c97478648937c7e4ea9f44cf5086a508efe4442acc4ed6f002b941e8c4f3680912fe77ee031f95a1078
7
- data.tar.gz: 434ed1a593759e605e34f18f345245a78ea7c208c64f9f9a1f9dbdd3d1f719f093b6d638a3dfb15e47b206aaecfb3965da89e0ad37bdf8f969b7fa1529267fe9
6
+ metadata.gz: fb5663b69d10c0c2f85c1d844e4db62615ffd2401cd0d98d95c0f5f6c61bfb6a0e3a15d9832ef7b1d250791d03a93667572b8f39debc56b65ba8fb1196bd7ad0
7
+ data.tar.gz: c3f50a46110f3360a776b5f215f27ec97f27d7c4de9cff4e7659d1438b9318d9c70b6105132990804481a6784b51e5310e19ef51aca52edf7ae0efa9ce0c0d22
@@ -16,7 +16,7 @@ module SpreadsheetGoodies::Excel
16
16
  end
17
17
 
18
18
  def add_worksheet(sheet_name)
19
- @current_sheet = @workbook.add_worksheet(name: sheet_name)
19
+ @current_sheet = workbook.add_worksheet(name: sheet_name)
20
20
  setup_current_sheet_styles
21
21
  freeze_top_row
22
22
  @current_sheet
@@ -1,8 +1,7 @@
1
1
  module SpreadsheetGoodies
2
2
 
3
-
4
- # Sobrecarrega método [] da Array para permitir acessar células passando
5
- # o título da coluna como índice. Ex: row['Data formal do pedido']
3
+ # Override Array#[] and Array#[]= to allow indexing by the column title.
4
+ # E.g.: row['Employee name']
6
5
  class Row < Array
7
6
  attr_reader :header_row, :row_number, :parent_worksheet
8
7
 
@@ -14,20 +13,32 @@ module SpreadsheetGoodies
14
13
  end
15
14
 
16
15
  def [](locator)
17
- cell_index = (locator.is_a?(String) ? @header_row.index(locator) : locator)
18
-
19
- # queries local cache only
20
- super(cell_index)
16
+ if locator.is_a?(String)
17
+ if column_index = @header_row.find_index(locator)
18
+ super(column_index) # queries local cache only
19
+ else
20
+ raise "Column with title '#{locator}' does not exist in header row"
21
+ end
22
+ else
23
+ super(locator) # queries local cache only
24
+ end
21
25
  end
22
26
 
23
27
  def []=(locator, value)
24
- cell_index = (locator.is_a?(String) ? @header_row.index(locator) : locator)
28
+ if locator.is_a?(String)
29
+ column_index = @header_row.find_index(locator)
30
+ if column_index.nil?
31
+ raise "Column with title '#{locator}' does not exist in header row"
32
+ end
33
+ else
34
+ column_index = locator
35
+ end
25
36
 
26
37
  # propagates change to real worksheet
27
- @parent_worksheet.write_to_cell(@row_number, cell_index+1, value)
38
+ @parent_worksheet.write_to_cell(@row_number, column_index+1, value)
28
39
 
29
40
  # updates local cache
30
- super(cell_index, value)
41
+ super(column_index, value)
31
42
  end
32
43
  end
33
44
  end
@@ -1,3 +1,3 @@
1
1
  module SpreadsheetGoodies
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |gemspec|
16
16
  "on other gems to do the actual work of reading and writing to " +
17
17
  "spreadsheet documents. It main features are:"
18
18
  " * Read a spreadseet to an array of arrays, to allow accessing its data " +
19
- " without using the original document"
19
+ " without using the original document/file/object"
20
20
  " * Access a row's elements using the column titles as keys"
21
21
  gemspec.homepage = 'https://github.com/ricardo-jasinski/spreadsheet_goodies'
22
22
  gemspec.license = 'Unlicense'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadsheet_goodies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Jasinski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-08-17 00:00:00.000000000 Z
12
+ date: 2019-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.6.8
169
+ rubygems_version: 2.6.6
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: SpreadsheetGoodies is a collection of tools to help work with Excel and Google