robust_excel_ole 0.3.2 → 0.3.3
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.
- data/README.rdoc +24 -18
- data/README_detail.rdoc +46 -40
- data/lib/robust_excel_ole/book.rb +23 -16
- data/lib/robust_excel_ole/book_store.rb +9 -3
- data/lib/robust_excel_ole/robustexcelole.sublime-workspace +419 -347
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +48 -11
- data/spec/book_store_spec.rb +10 -9
- metadata +4 -4
data/spec/book_spec.rb
CHANGED
@@ -41,15 +41,6 @@ describe Book do
|
|
41
41
|
@book.should be_a Book
|
42
42
|
@book.close
|
43
43
|
end
|
44
|
-
|
45
|
-
it "create a new file" do
|
46
|
-
File.delete @simple_save_file rescue nil
|
47
|
-
Book.create(@simple_save_file)
|
48
|
-
book = Book.open(@simple_save_file, :if_absent => :raise)
|
49
|
-
book.should be_a Book
|
50
|
-
book.close
|
51
|
-
File.exist?(@simple_save_file).should be_true
|
52
|
-
end
|
53
44
|
end
|
54
45
|
end
|
55
46
|
|
@@ -468,7 +459,7 @@ describe Book do
|
|
468
459
|
@key_sender.puts "{right}{enter}"
|
469
460
|
expect{
|
470
461
|
Book.open(@simple_file, :if_unsaved => :alert)
|
471
|
-
}.to raise_error(
|
462
|
+
}.to raise_error(ExcelErrorOpen, "open: user canceled or open error")
|
472
463
|
@book.should be_alive
|
473
464
|
end
|
474
465
|
end
|
@@ -808,7 +799,7 @@ describe Book do
|
|
808
799
|
end
|
809
800
|
|
810
801
|
it "should create and use a hidden Excel instance" do
|
811
|
-
book2 = Book.open(@simple_file, :force_excel => @book.book_store.
|
802
|
+
book2 = Book.open(@simple_file, :force_excel => @book.book_store.hidden_excel)
|
812
803
|
book2.excel.should_not == @book.excel
|
813
804
|
book2.excel.Visible.should be_false
|
814
805
|
book2.excel.DisplayAlerts.should be_false
|
@@ -856,6 +847,17 @@ describe Book do
|
|
856
847
|
book.excel.should_not == new_excel
|
857
848
|
end
|
858
849
|
end
|
850
|
+
|
851
|
+
it "should open unobtrusively in a given Excel" do
|
852
|
+
excel = Excel.new(:reuse => false)
|
853
|
+
new_excel = Excel.new(:reuse => false)
|
854
|
+
Book.unobtrusively(@simple_file, :if_closed => new_excel) do |book|
|
855
|
+
book.should be_a Book
|
856
|
+
book.should be_alive
|
857
|
+
book.excel.should_not == excel
|
858
|
+
end
|
859
|
+
end
|
860
|
+
|
859
861
|
end
|
860
862
|
|
861
863
|
context "with an open book" do
|
@@ -1025,6 +1027,41 @@ describe Book do
|
|
1025
1027
|
sheet = new_book[0]
|
1026
1028
|
sheet[0,0].value.should_not == old_cell_value
|
1027
1029
|
end
|
1030
|
+
|
1031
|
+
it "should use a given Excel" do
|
1032
|
+
@book.close
|
1033
|
+
excel = Excel.new(:reuse => false)
|
1034
|
+
new_excel = Excel.new(:reuse => false)
|
1035
|
+
Book.unobtrusively(@simple_file, :if_closed => new_excel) do |book|
|
1036
|
+
book.should be_a Book
|
1037
|
+
book.excel.should_not == @book.excel
|
1038
|
+
book.excel.should == new_excel
|
1039
|
+
end
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
it "should use not the given excel if the Excels are closed" do
|
1043
|
+
excel = Excel.new(:reuse => false)
|
1044
|
+
sheet = @book[0]
|
1045
|
+
old_cell_value = sheet[0,0].value
|
1046
|
+
old_excel = @book.excel
|
1047
|
+
@book.close
|
1048
|
+
@book.should_not be_alive
|
1049
|
+
Excel.close_all
|
1050
|
+
Book.unobtrusively(@simple_file, :if_closed => excel, :keep_open => true) do |book|
|
1051
|
+
book.should be_a Book
|
1052
|
+
book.excel.should_not == old_excel
|
1053
|
+
book.excel.should == @book.excel
|
1054
|
+
book.excel.should_not == excel
|
1055
|
+
sheet = book[0]
|
1056
|
+
cell = sheet[0,0]
|
1057
|
+
sheet[0,0] = cell.value == "simple" ? "complex" : "simple"
|
1058
|
+
book.Saved.should be_false
|
1059
|
+
end
|
1060
|
+
@book.should be_alive
|
1061
|
+
new_book = Book.open(@simple_file)
|
1062
|
+
sheet = new_book[0]
|
1063
|
+
sheet[0,0].value.should_not == old_cell_value
|
1064
|
+
end
|
1028
1065
|
end
|
1029
1066
|
|
1030
1067
|
|
data/spec/book_store_spec.rb
CHANGED
@@ -15,7 +15,7 @@ $VERBOSE = nil
|
|
15
15
|
include RobustExcelOle
|
16
16
|
|
17
17
|
module RobustExcelOle
|
18
|
-
class MockBookstore
|
18
|
+
class MockBookstore # :nodoc: #
|
19
19
|
def fetch(filename, options = { })
|
20
20
|
nil
|
21
21
|
end
|
@@ -387,6 +387,10 @@ describe BookStore do
|
|
387
387
|
book_new = Book.open(@different_file)
|
388
388
|
@bookstore.store(book_new)
|
389
389
|
@book = nil
|
390
|
+
@book = "Bla"
|
391
|
+
@book = Book.open(@simple_file)
|
392
|
+
@bookstore.store(@book)
|
393
|
+
@book = nil
|
390
394
|
GC.start
|
391
395
|
@bookstore.fetch(@simple_file).should == nil
|
392
396
|
@bookstore.fetch(@different_file).should == book_new
|
@@ -407,30 +411,27 @@ describe BookStore do
|
|
407
411
|
end
|
408
412
|
|
409
413
|
it "should create and use a hidden Excel instance" do
|
410
|
-
|
411
|
-
h_excel0.should == nil
|
412
|
-
h_excel1 = @bookstore.ensure_hidden_excel
|
413
|
-
h_excel1.should == @bookstore.try_hidden_excel
|
414
|
+
h_excel1 = @bookstore.hidden_excel
|
414
415
|
h_excel1.should_not == @book.excel
|
415
416
|
h_excel1.Visible.should be_false
|
416
417
|
h_excel1.DisplayAlerts.should be_false
|
417
|
-
book1 = Book.open(@simple_file, :force_excel => @bookstore.
|
418
|
+
book1 = Book.open(@simple_file, :force_excel => @bookstore.hidden_excel)
|
418
419
|
book1.excel.should === h_excel1
|
419
420
|
book1.excel.should_not === @book.excel
|
420
421
|
Excel.close_all
|
421
|
-
h_excel2 = @bookstore.
|
422
|
+
h_excel2 = @bookstore.hidden_excel
|
422
423
|
h_excel2.should_not == @book.excel
|
423
424
|
h_excel2.should_not == book1.excel
|
424
425
|
h_excel2.Visible.should be_false
|
425
426
|
h_excel2.DisplayAlerts.should be_false
|
426
|
-
book2 = Book.open(@simple_file, :force_excel => @bookstore.
|
427
|
+
book2 = Book.open(@simple_file, :force_excel => @bookstore.hidden_excel)
|
427
428
|
book2.excel.should === h_excel2
|
428
429
|
book2.excel.should_not === @book.excel
|
429
430
|
book2.excel.should_not === book1.excel
|
430
431
|
end
|
431
432
|
|
432
433
|
it "should exclude hidden excel" do
|
433
|
-
book1 = Book.open(@simple_file, :force_excel => @bookstore.
|
434
|
+
book1 = Book.open(@simple_file, :force_excel => @bookstore.hidden_excel)
|
434
435
|
@bookstore.store(book1)
|
435
436
|
book1.close
|
436
437
|
book2 = @bookstore.fetch(@simple_file)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robust_excel_ole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- traths
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2015-06-
|
18
|
+
date: 2015-06-10 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|