robust_excel_ole 1.1.6 → 1.2
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/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +8 -8
- data/spec/book_specs/book_misc_spec.rb +1 -1
- data/spec/book_specs/book_open_spec.rb +24 -80
- data/spec/book_specs/book_save_spec.rb +8 -7
- data/spec/helpers/key_sender.rb +2 -1
- data/spec/sheet_spec.rb +1 -1
- 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: 11b718a2903204d3521cdfad3ef539537841dd06
|
4
|
+
data.tar.gz: 07a2911b36560a7f505c17914ed441c3ee2add3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7086927359fd13e8f573ab33eb7aa81ba8d7f19ffcdf1b42d2a61fdfa02414bcfbeabc6846114a0eebddf30b8f28f5d14682f756222122b404bf237bc784a217
|
7
|
+
data.tar.gz: eb1e7673ba0fbb4402e8fd81669a2f9d80b75f7305044aa8093ca15260d3573178c6e30c79e671e9ed6997b6e1b79bbf30301b86ca78e60124faed430b82c4c2
|
data/spec/book_spec.rb
CHANGED
@@ -375,7 +375,7 @@ describe Book do
|
|
375
375
|
|
376
376
|
context "with :if_unsaved => :alert or :if_unsaved => :excel" do
|
377
377
|
before do
|
378
|
-
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft
|
378
|
+
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
379
379
|
end
|
380
380
|
|
381
381
|
after do
|
@@ -398,9 +398,9 @@ describe Book do
|
|
398
398
|
@key_sender.puts "{right}{enter}"
|
399
399
|
@key_sender.puts "{right}{enter}"
|
400
400
|
@key_sender.puts "{right}{enter}"
|
401
|
-
|
402
|
-
|
403
|
-
|
401
|
+
expect{
|
402
|
+
Book.open(@simple_file, :if_unsaved => :alert)
|
403
|
+
}.to raise_error(UnexpectedREOError)
|
404
404
|
@book.should be_alive
|
405
405
|
end
|
406
406
|
|
@@ -420,9 +420,9 @@ describe Book do
|
|
420
420
|
@key_sender.puts "{right}{enter}"
|
421
421
|
@key_sender.puts "{right}{enter}"
|
422
422
|
@key_sender.puts "{right}{enter}"
|
423
|
-
|
424
|
-
|
425
|
-
|
423
|
+
expect{
|
424
|
+
Book.open(@simple_file, :if_unsaved => :excel)
|
425
|
+
}.to raise_error(UnexpectedREOError)
|
426
426
|
@book.should be_alive
|
427
427
|
end
|
428
428
|
|
@@ -1223,7 +1223,7 @@ describe Book do
|
|
1223
1223
|
context "with focus" do
|
1224
1224
|
|
1225
1225
|
before do
|
1226
|
-
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft
|
1226
|
+
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
1227
1227
|
@book = Book.open(@simple_file, :visible => true)
|
1228
1228
|
@book2 = Book.open(@another_simple_file, :visible => true)
|
1229
1229
|
end
|
@@ -1044,7 +1044,7 @@ describe Book do
|
|
1044
1044
|
context "with focus" do
|
1045
1045
|
|
1046
1046
|
before do
|
1047
|
-
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft
|
1047
|
+
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
1048
1048
|
@book = Book.open(@simple_file, :visible => true)
|
1049
1049
|
@book.excel.displayalerts = false
|
1050
1050
|
@book2 = Book.open(@another_simple_file, :visible => true)
|
@@ -1599,60 +1599,34 @@ describe Book do
|
|
1599
1599
|
context "with :if_unsaved" do
|
1600
1600
|
|
1601
1601
|
before do
|
1602
|
-
@book = Book.open(@
|
1603
|
-
sheet = @book.sheet(1)
|
1604
|
-
|
1605
|
-
@old_value = sheet[1,1].Value
|
1606
|
-
sheet[1,1] = (sheet[1,1].value == "foo" ? "bar" : "foo")
|
1607
|
-
@new_value = sheet[1,1].Value
|
1608
|
-
@book.Saved.should be false
|
1602
|
+
@book = Book.open(@simple_file)
|
1603
|
+
@sheet = @book.sheet(1)
|
1604
|
+
@book.add_sheet(@sheet, :as => 'a_name')
|
1609
1605
|
end
|
1610
1606
|
|
1611
1607
|
after do
|
1612
1608
|
@book.close(:if_unsaved => :forget)
|
1613
|
-
|
1614
|
-
|
1615
|
-
it "should open the book in a new excel instance, if :if_unsaved is :new_excel" do
|
1616
|
-
new_book = Book.open(@simple_file1, :if_unsaved => :new_excel)
|
1617
|
-
new_book.excel.should_not == @book.excel
|
1618
|
-
@book.should be_alive
|
1619
|
-
@book.Saved.should be false
|
1620
|
-
new_book.should be_alive
|
1621
|
-
new_book.Saved.should be true
|
1622
|
-
new_book.sheet(1)[1,1].Value.should == @old_value
|
1623
|
-
#new_book.filename.should == @book.filename
|
1624
|
-
new_book.excel.should_not == @book.excel
|
1625
|
-
new_book.close
|
1609
|
+
@new_book.close rescue nil
|
1626
1610
|
end
|
1627
1611
|
|
1628
1612
|
it "should raise an error, if :if_unsaved is :raise" do
|
1629
1613
|
expect {
|
1630
|
-
new_book = Book.open(@
|
1614
|
+
@new_book = Book.open(@simple_file, :if_unsaved => :raise)
|
1631
1615
|
}.to raise_error(WorkbookNotSaved, /workbook is already open but not saved: "workbook.xls"/)
|
1632
1616
|
end
|
1633
1617
|
|
1634
1618
|
it "should let the book open, if :if_unsaved is :accept" do
|
1635
|
-
|
1619
|
+
expect {
|
1620
|
+
@new_book = Book.open(@simple_file, :if_unsaved => :accept)
|
1621
|
+
}.to_not raise_error
|
1636
1622
|
@book.should be_alive
|
1637
|
-
new_book.should be_alive
|
1638
|
-
new_book.
|
1639
|
-
@book.Saved.should be false
|
1640
|
-
new_book.sheet(1)[1,1].Value.should == @new_value
|
1641
|
-
new_book.should == @book
|
1642
|
-
end
|
1643
|
-
|
1644
|
-
it "should open book and close old book, if :if_unsaved is :forget" do
|
1645
|
-
new_book = Book.open(@simple_file1, :if_unsaved => :forget)
|
1646
|
-
@book.should_not be_alive
|
1647
|
-
new_book.should be_alive
|
1648
|
-
new_book.Saved.should be true
|
1649
|
-
new_book.sheet(1)[1,1].Value.should == @old_value
|
1650
|
-
#@new_book.filename.downcase.should == @simple_file.downcase
|
1623
|
+
@new_book.should be_alive
|
1624
|
+
@new_book.should == @book
|
1651
1625
|
end
|
1652
1626
|
|
1653
|
-
context "with :if_unsaved => :alert" do
|
1627
|
+
context "with :if_unsaved => :alert or :if_unsaved => :excel" do
|
1654
1628
|
before do
|
1655
|
-
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft
|
1629
|
+
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
1656
1630
|
end
|
1657
1631
|
|
1658
1632
|
after do
|
@@ -1662,16 +1636,12 @@ describe Book do
|
|
1662
1636
|
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
1663
1637
|
# "Yes" is the default. --> language independent
|
1664
1638
|
@key_sender.puts "{enter}"
|
1665
|
-
new_book = Book.open(@simple_file1, :if_unsaved => :alert)
|
1666
|
-
new_book.should be_alive
|
1667
|
-
|
1668
|
-
|
1669
|
-
new_book.Saved.should be true
|
1670
|
-
new_book.sheet(1)[1,1].Value.should == @old_value
|
1639
|
+
@new_book = Book.open(@simple_file1, :if_unsaved => :alert)
|
1640
|
+
@new_book.should be_alive
|
1641
|
+
@new_book.filename.downcase.should == @simple_file1.downcase
|
1642
|
+
@book.should_not be_alive
|
1671
1643
|
end
|
1672
|
-
|
1673
|
-
=begin
|
1674
|
-
# only for Excel2007:
|
1644
|
+
|
1675
1645
|
it "should not open the new book and not close the unsaved book, if user answers 'no'" do
|
1676
1646
|
# "No" is right to "Yes" (the default). --> language independent
|
1677
1647
|
# strangely, in the "no" case, the question will sometimes be repeated three times
|
@@ -1680,33 +1650,20 @@ describe Book do
|
|
1680
1650
|
@key_sender.puts "{right}{enter}"
|
1681
1651
|
@key_sender.puts "{right}{enter}"
|
1682
1652
|
expect{
|
1683
|
-
Book.open(@
|
1684
|
-
}.to raise_error(
|
1653
|
+
Book.open(@simple_file, :if_unsaved => :alert)
|
1654
|
+
}.to raise_error(UnexpectedREOError)
|
1685
1655
|
@book.should be_alive
|
1686
1656
|
end
|
1687
|
-
|
1688
|
-
=end
|
1689
|
-
|
1690
|
-
context "with :if_unsaved => :excel" do
|
1691
|
-
before do
|
1692
|
-
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft Office Excel" ' , "w"
|
1693
|
-
end
|
1694
|
-
|
1695
|
-
after do
|
1696
|
-
@key_sender.close
|
1697
|
-
end
|
1698
1657
|
|
1699
1658
|
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
1700
1659
|
# "Yes" is the default. --> language independent
|
1701
1660
|
@key_sender.puts "{enter}"
|
1702
|
-
new_book = Book.open(@simple_file1, :if_unsaved => :excel)
|
1703
|
-
new_book.should be_alive
|
1661
|
+
@new_book = Book.open(@simple_file1, :if_unsaved => :excel)
|
1662
|
+
@new_book.should be_alive
|
1663
|
+
@new_book.filename.downcase.should == @simple_file1.downcase
|
1704
1664
|
#@book.should_not be_alive
|
1705
|
-
new_book.Saved.should be true
|
1706
|
-
new_book.sheet(1)[1,1].Value.should == @old_value
|
1707
1665
|
end
|
1708
1666
|
|
1709
|
-
=begin
|
1710
1667
|
it "should not open the new book and not close the unsaved book, if user answers 'no'" do
|
1711
1668
|
# "No" is right to "Yes" (the default). --> language independent
|
1712
1669
|
# strangely, in the "no" case, the question will sometimes be repeated three times
|
@@ -1715,24 +1672,11 @@ describe Book do
|
|
1715
1672
|
@key_sender.puts "{right}{enter}"
|
1716
1673
|
@key_sender.puts "{right}{enter}"
|
1717
1674
|
expect{
|
1718
|
-
Book.open(@
|
1719
|
-
|
1675
|
+
Book.open(@simple_file, :if_unsaved => :excel)
|
1676
|
+
}.to raise_error(UnexpectedREOError)
|
1720
1677
|
@book.should be_alive
|
1721
1678
|
end
|
1722
|
-
=end
|
1723
|
-
|
1724
|
-
end
|
1725
|
-
|
1726
|
-
it "should raise an error, if :if_unsaved is default" do
|
1727
|
-
expect {
|
1728
|
-
new_book = Book.open(@simple_file1, :if_unsaved => :raise)
|
1729
|
-
}.to raise_error(WorkbookNotSaved, /workbook is already open but not saved: "workbook.xls"/)
|
1730
|
-
end
|
1731
1679
|
|
1732
|
-
it "should raise an error, if :if_unsaved is invalid option" do
|
1733
|
-
expect {
|
1734
|
-
new_book = Book.open(@simple_file1, :if_unsaved => :invalid_option)
|
1735
|
-
}.to raise_error(OptionInvalid, ":if_unsaved: invalid option: :invalid_option")
|
1736
1680
|
end
|
1737
1681
|
end
|
1738
1682
|
|
@@ -36,7 +36,7 @@ describe Book do
|
|
36
36
|
|
37
37
|
after do
|
38
38
|
Excel.kill_all
|
39
|
-
|
39
|
+
#rm_tmp(@dir)
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "save" do
|
@@ -380,7 +380,9 @@ describe Book do
|
|
380
380
|
|
381
381
|
it "should save if user answers 'yes'" do
|
382
382
|
# "Yes" is to the left of "No", which is the default. --> language independent
|
383
|
-
@key_sender.puts "{
|
383
|
+
@key_sender.puts "{right}{right}{right}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
|
384
|
+
#@key_sender.puts "{left}{enter}"
|
385
|
+
#@key_sender.puts "{left}{enter}"
|
384
386
|
@book.save_as(@simple_save_file1, :if_exists => :alert)
|
385
387
|
File.exist?(@simple_save_file1).should be true
|
386
388
|
File.size?(@simple_save_file1).should > @garbage_length
|
@@ -390,14 +392,12 @@ describe Book do
|
|
390
392
|
new_book.close
|
391
393
|
@book.excel.DisplayAlerts.should == displayalert_value
|
392
394
|
end
|
393
|
-
|
394
395
|
it "should not save if user answers 'no'" do
|
395
396
|
# Just give the "Enter" key, because "No" is the default. --> language independent
|
396
397
|
# strangely, in the "no" case, the question will sometimes be repeated three times
|
397
398
|
@key_sender.puts "{enter}"
|
398
399
|
@key_sender.puts "{enter}"
|
399
400
|
@key_sender.puts "{enter}"
|
400
|
-
#@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
|
401
401
|
@book.save_as(@simple_save_file1, :if_exists => :alert)
|
402
402
|
File.exist?(@simple_save_file1).should be true
|
403
403
|
File.size?(@simple_save_file1).should == @garbage_length
|
@@ -410,7 +410,6 @@ describe Book do
|
|
410
410
|
@key_sender.puts "{right}{enter}"
|
411
411
|
@key_sender.puts "{right}{enter}"
|
412
412
|
@key_sender.puts "{right}{enter}"
|
413
|
-
#@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
|
414
413
|
@book.save_as(@simple_save_file1, :if_exists => :alert)
|
415
414
|
File.exist?(@simple_save_file1).should be true
|
416
415
|
File.size?(@simple_save_file1).should == @garbage_length
|
@@ -435,7 +434,9 @@ describe Book do
|
|
435
434
|
|
436
435
|
it "should save if user answers 'yes'" do
|
437
436
|
# "Yes" is to the left of "No", which is the default. --> language independent
|
438
|
-
@key_sender.puts "{
|
437
|
+
@key_sender.puts "{right}{right}{right}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
|
438
|
+
#@key_sender.puts "{left}{enter}"
|
439
|
+
#@key_sender.puts "{left}{enter}"
|
439
440
|
@book.save_as(@simple_save_file1, :if_exists => :excel)
|
440
441
|
File.exist?(@simple_save_file1).should be true
|
441
442
|
File.size?(@simple_save_file1).should > @garbage_length
|
@@ -443,6 +444,7 @@ describe Book do
|
|
443
444
|
new_book = Book.open(@simple_save_file1, :excel => :new)
|
444
445
|
new_book.should be_a Book
|
445
446
|
new_book.close
|
447
|
+
|
446
448
|
@book.excel.DisplayAlerts.should == displayalert_value
|
447
449
|
end
|
448
450
|
|
@@ -452,7 +454,6 @@ describe Book do
|
|
452
454
|
@key_sender.puts "{enter}"
|
453
455
|
@key_sender.puts "{enter}"
|
454
456
|
@key_sender.puts "{enter}"
|
455
|
-
#@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
|
456
457
|
@book.save_as(@simple_save_file1, :if_exists => :excel)
|
457
458
|
File.exist?(@simple_save_file1).should be true
|
458
459
|
File.size?(@simple_save_file1).should == @garbage_length
|
data/spec/helpers/key_sender.rb
CHANGED
@@ -60,7 +60,8 @@ class KeySender # :nodoc: #
|
|
60
60
|
end
|
61
61
|
|
62
62
|
if __FILE__ == $0
|
63
|
-
key_sender = KeySender.new(ARGV[
|
63
|
+
key_sender = KeySender.new(ARGV[0])
|
64
|
+
#key_sender = KeySender.new(ARGV[1])
|
64
65
|
while not $stdin.eof? do
|
65
66
|
key_sequence = $stdin.gets.chomp
|
66
67
|
key_sender.send key_sequence
|
data/spec/sheet_spec.rb
CHANGED
@@ -35,7 +35,7 @@ describe Sheet do
|
|
35
35
|
describe ".initialize" do
|
36
36
|
context "when open sheet protected(with password is 'protect')" do
|
37
37
|
before do
|
38
|
-
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft
|
38
|
+
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
39
39
|
@book_protect = Book.open(@protected_file, :visible => true, :read_only => true, :force_excel => :new)
|
40
40
|
@book_protect.excel.displayalerts = false
|
41
41
|
@key_sender.puts "{p}{r}{o}{t}{e}{c}{t}{enter}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robust_excel_ole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- traths
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|