excel-esv 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/lib/esv/version.rb +1 -1
- data/lib/esv.rb +6 -0
- data/spec/esv_spec.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5049cc83b275a96858474dff192d8a82d00482d8
|
4
|
+
data.tar.gz: bd781b1577a1f3938f87f2d607e99a86792bf656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d875ee2efd7c203d1f2499d6da0155992453c06a1bb2bbb664e2c039b92a848a0df114c1f7d01069f15985afb42c67b4ae24b2d615f406e0e071102f7cdd593
|
7
|
+
data.tar.gz: f04a30dac8cf0c0d8c83bd5d982e7d91a6af39619483036ea9b3b8b7d3d6909a36d811c3e38266972335d220c72f103605c0cb20d009e1f2ffb0abd2aee41008
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ CSVs can be difficult to open correctly, e.g. in Excel on Mac.
|
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
|
12
|
-
### Generate
|
12
|
+
### Generate data
|
13
13
|
|
14
14
|
``` ruby
|
15
15
|
require "esv"
|
@@ -22,7 +22,18 @@ end
|
|
22
22
|
File.write("/tmp/test.xls", data)
|
23
23
|
```
|
24
24
|
|
25
|
-
###
|
25
|
+
### Generate file
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
require "esv"
|
29
|
+
|
30
|
+
ESV.generate_file("/tmp/test.xls") do |esv|
|
31
|
+
esv << [ "Name", "Dogs", "Cats" ]
|
32
|
+
esv << [ "Victor", 1, 4 ]
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
### Parse data
|
26
37
|
|
27
38
|
``` ruby
|
28
39
|
require "esv"
|
data/lib/esv/version.rb
CHANGED
data/lib/esv.rb
CHANGED
@@ -10,6 +10,12 @@ module ESV
|
|
10
10
|
generator.render
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.generate_file(path, &block)
|
14
|
+
File.open(path, "w") do |file|
|
15
|
+
file.write generate(&block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
13
19
|
def self.parse(data)
|
14
20
|
fake_file = StringIO.new(data)
|
15
21
|
book = Spreadsheet.open(fake_file)
|
data/spec/esv_spec.rb
CHANGED
@@ -36,3 +36,31 @@ describe ESV, ".parse" do
|
|
36
36
|
data
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe ESV, ".generate_file" do
|
41
|
+
before do
|
42
|
+
@file = Tempfile.new("esv")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "works" do
|
46
|
+
path = @file.path
|
47
|
+
|
48
|
+
ESV.generate_file(path) do |esv|
|
49
|
+
esv << [ "Dogs", "Cats" ]
|
50
|
+
esv << [ 1, 2 ]
|
51
|
+
end
|
52
|
+
|
53
|
+
data = File.read(path)
|
54
|
+
output = ESV.parse(data)
|
55
|
+
|
56
|
+
expect(output).to eq [
|
57
|
+
[ "Dogs", "Cats" ],
|
58
|
+
[ 1, 2 ],
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
@file.close
|
64
|
+
@file.unlink
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel-esv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spreadsheet
|