rspreadsheet 0.2.11 → 0.2.12
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 +4 -4
- data/CONFIGURATION.md +7 -0
- data/README.md +2 -1
- data/lib/rspreadsheet/cell.rb +8 -2
- data/lib/rspreadsheet/version.rb +1 -1
- data/spec/cell_spec.rb +12 -0
- data/spec/testfile1.ods +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e934c460d044d82af82b8cb6aa7fb8d9336ef961
|
4
|
+
data.tar.gz: fc75adfff414efcfbf0649b9262c4faf23bfb292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d61b752404f07748c738225895d61d5bfe11aeb2512042e272075a48b6b44112cb849671231d05bcbffe70fa74b188fd92c18f52545aa95dbe488ce0c1e374
|
7
|
+
data.tar.gz: ae2c7fe343d5a75c469a36b594ead4551faf341bcb2c2ade99c3cf4c046c54aa66074d08cb689bcd4cd3fa042ce430543133cf7dc5af066513370255a81cd501
|
data/CONFIGURATION.md
ADDED
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
|
data/lib/rspreadsheet/cell.rb
CHANGED
@@ -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
|
data/lib/rspreadsheet/version.rb
CHANGED
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.
|
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-
|
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
|