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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 497175de91508cfae61cef9c418d19368fe40db9
4
- data.tar.gz: c9b36a3fb2bb4ed670eff42935cd0a49f169bc40
3
+ metadata.gz: 5049cc83b275a96858474dff192d8a82d00482d8
4
+ data.tar.gz: bd781b1577a1f3938f87f2d607e99a86792bf656
5
5
  SHA512:
6
- metadata.gz: 5f50059616af9ab743c24c7e9baf3b13c32d1b6203c8c300a4bced7d16e389438889f446af0c1f71f7295afd55d05c609ee46527f7307ced5cc750521044e444
7
- data.tar.gz: 30e21e0646c7cf9f34850656069bdae2bc27b6db433ff665e77ef3f19947b316a7cd0a2cda74f21b1df4ab57686e8ea972920b911830817a20d711328d1ad85a
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
- ### Parse
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
@@ -1,3 +1,3 @@
1
1
  module ESV
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-05 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spreadsheet