rspreadsheet 0.2.11 → 0.2.12

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: 63cd4006cec7642ea6755fe2c2fde09943c67a17
4
- data.tar.gz: dbc0b88c94998ae407fb909219a1832d5ab4c00f
3
+ metadata.gz: e934c460d044d82af82b8cb6aa7fb8d9336ef961
4
+ data.tar.gz: fc75adfff414efcfbf0649b9262c4faf23bfb292
5
5
  SHA512:
6
- metadata.gz: 25885b830e8a23088c9d7171117f270d5fb191f08147409be703f93e63354331ab7e016a0666ffccb296266513e3d0688b4b44c20ba79424652908f81728fb49
7
- data.tar.gz: 4ad5a10753aaf548d31861d028da97d81ace87d1df753f9e350c393d67a0d9b34ab9e2c0ac5cd420d48a4e76600cadf6edbbeb489c6b4cbe0e7c9dc1d20e4fe1
6
+ metadata.gz: 35d61b752404f07748c738225895d61d5bfe11aeb2512042e272075a48b6b44112cb849671231d05bcbffe70fa74b188fd92c18f52545aa95dbe488ce0c1e374
7
+ data.tar.gz: ae2c7fe343d5a75c469a36b594ead4551faf341bcb2c2ade99c3cf4c046c54aa66074d08cb689bcd4cd3fa042ce430543133cf7dc5af066513370255a81cd501
data/CONFIGURATION.md ADDED
@@ -0,0 +1,7 @@
1
+ # Configuration
2
+
3
+ By
4
+
5
+ Rspreadsheet.raise_on_negative_coordinates = false
6
+
7
+ you turn off errors when you use zero or negative coordinates for referencing rows or cells. From this point on, it just returns nil.
data/README.md CHANGED
@@ -53,7 +53,7 @@ This is also pubished as Gist **where you can leave you comments and suggestions
53
53
  * [extended examples](https://gist.github.com/gorn/b432e6a69e82628349e6) of lots of alternative syntax
54
54
  * [GUIDE.md](GUIDE.md) some other notes
55
55
 
56
- ## Installation
56
+ ## Installation and Configuration
57
57
 
58
58
  Gem is on [Rubygems](https://rubygems.org/gems/rspreadsheet) so you can install it by
59
59
 
@@ -98,6 +98,7 @@ One of the main ideas is that the manipulation with OpenDOcument files should be
98
98
  ## Further reading
99
99
 
100
100
  * [Advanced Guide](GUIDE.md) how to use the gem
101
+ * [Configuration](CONFIGURATION.md) of the gem
101
102
  * [Code documentation](http://www.rubydoc.info/github/gorn/rspreadsheet) is hosted on [rubydoc.info](http://www.rubydoc.info/)
102
103
  * [Changelog](CHANGELOG.md)
103
104
  * [Documentation for developers](DEVEL_BLOG.md) containing ideas for future development and documentation on testing tools
@@ -5,8 +5,8 @@
5
5
  require 'andand'
6
6
  require 'rspreadsheet/xml_tied'
7
7
  require 'date'
8
-
9
-
8
+ require 'bigdecimal'
9
+ require 'bigdecimal/util' # for to_d method
10
10
 
11
11
  module Rspreadsheet
12
12
 
@@ -60,6 +60,7 @@ class Cell < XMLTiedItem
60
60
  when gt == String then xmlnode.elements.first.andand.content.to_s
61
61
  when gt == Date then Date.strptime(xmlnode.attributes['date-value'].to_s, '%Y-%m-%d')
62
62
  when gt == :percentage then xmlnode.attributes['value'].to_f
63
+ when gt == :currency then xmlnode.attributes['value'].to_d
63
64
  end
64
65
  elsif self.mode == :outbound
65
66
  nil
@@ -121,6 +122,7 @@ class Cell < XMLTiedItem
121
122
  when gct == Date then :date
122
123
  when gct == :percentage then :percentage
123
124
  when gct == :unassigned then :unassigned
125
+ when gct == :currency then :currency
124
126
  when gct == NilClass then :empty
125
127
  when gct == nil then :unknown
126
128
  else :unknown
@@ -146,6 +148,7 @@ class Cell < XMLTiedItem
146
148
  when 'date' then Date
147
149
  when 'percentage' then :percentage
148
150
  when 'N/A' then :unassigned
151
+ when 'currency' then :currency
149
152
  else
150
153
  if xmlnode.children.size == 0
151
154
  nil
@@ -294,6 +297,9 @@ class CellFormat
294
297
  return nil if cellnode.nil?
295
298
  cellnode.doc.root.find("./office:automatic-styles#{xpath}").first
296
299
  end
300
+ def currency
301
+ Tools.get_ns_attribute_value(cellnode,'office','currency',nil)
302
+ end
297
303
  end
298
304
 
299
305
  end
@@ -1,3 +1,3 @@
1
1
  module Rspreadsheet
2
- VERSION = "0.2.11"
2
+ VERSION = "0.2.12"
3
3
  end
data/spec/cell_spec.rb CHANGED
@@ -94,6 +94,8 @@ describe Rspreadsheet::Cell do
94
94
  @sheet2.cells(3,1).type.should eq :float
95
95
  @sheet2.cells(3,2).type.should eq :percentage
96
96
  @sheet2.cells(4,2).type.should eq :string
97
+ @sheet2.cells('B22').type.should eq :currency
98
+ @sheet2.cells('B23').type.should eq :currency
97
99
  @sheet2.cells(200,200).type.should eq :unassigned
98
100
  end
99
101
  it 'returns value of correct type' do
@@ -311,6 +313,16 @@ describe Rspreadsheet::Cell do
311
313
  @cell.type.should eq :string
312
314
  @cell.formula.should be_nil
313
315
  end
316
+ it 'works well with currency types' do
317
+ @usdcell = @sheet2.cells('B22')
318
+ @usdcell.type.should eq :currency
319
+ @usdcell.value.should == -147984.84
320
+ @usdcell.format.currency.should == 'USD'
321
+
322
+ @czkcell = @sheet2.cells('B23')
323
+ @czkcell.value.should == 344.to_d
324
+ @czkcell.format.currency.should == 'CZK'
325
+ end
314
326
  end
315
327
 
316
328
 
data/spec/testfile1.ods CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub A.Těšínský
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libxml-ruby
@@ -166,6 +166,7 @@ files:
166
166
  - ".travis.yml"
167
167
  - ".yardopts"
168
168
  - CHANGELOG.md
169
+ - CONFIGURATION.md
169
170
  - COPYING.txt
170
171
  - DEVEL_BLOG.md
171
172
  - GUIDE.md