robust_excel_ole 0.2.0.6 → 0.2.0.7

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 CHANGED
@@ -47,7 +47,7 @@ Options are the following:
47
47
  [:displayalerts] boolean (default: false). allow display alerts in Excel
48
48
  [:visible] boolean (default: false). make visibe in Excel
49
49
  [:if_unsaved] :raise (default), :accept, :forget, :new_app, :excel
50
- [:if_unsaved_other_book] :raise (default), :save, :forget, :new_app
50
+ [:if_blocked_other_book] :raise (default), :save, :forget, :new_app
51
51
 
52
52
 
53
53
  The option :if_unsaved :
@@ -60,13 +60,12 @@ If an unsaved book with the same name is open, then
60
60
  [:new_app] Open the new book in a new Excel application
61
61
  [:excel] Give control to Excel.
62
62
 
63
- The option :if_unsaved_other_book :
63
+ The option :if_blocked_other_book :
64
64
 
65
- If an unsaved book with same name in a different path is open, then
65
+ If a book with same name in a different path is open, then
66
66
 
67
67
  [:raise] Raise an exception. Don't open the book.
68
- [:save] Save and close the unsaved book and open the new book.
69
- [:forget] Close the unsaved book, open the new book.
68
+ [:forget] Close the old book, open the new book.
70
69
  [:new_app] Open the new book in a new Excel application.
71
70
 
72
71
 
@@ -22,9 +22,8 @@ module RobustExcelOle
22
22
  # :forget -> close the unsaved book, open the new book
23
23
  # :excel -> give control to excel
24
24
  # :new_app -> open the new book in a new excel application
25
- # :if_unsaved_other_book if an unsaved book with the same name in a different path is open, then
25
+ # :if_blocked_other_book if a book with the same name in a different path is open, then
26
26
  # :raise -> raise an exception (default)
27
- # :save -> save and close the unsaved book and open the new book
28
27
  # :forget -> close the unsaved book, open the new book
29
28
  # :new_app -> open the new book in a new excel application
30
29
  def open(file, options={ :reuse => true}, &block)
@@ -38,10 +37,10 @@ module RobustExcelOle
38
37
  :reuse => true,
39
38
  :read_only => false,
40
39
  :if_unsaved => :raise,
41
- :if_unsaved_other_book => :raise
40
+ :if_blocked_other_book => :raise
42
41
  }.merge(opts)
43
42
  excel_app_options = {:reuse => true}.merge(opts).delete_if{|k,v|
44
- k== :read_only || k== :if_unsaved || k == :if_unsaved_other_book}
43
+ k== :read_only || k== :if_unsaved || k == :if_blocked_other_book}
45
44
  if not File.exist?(file)
46
45
  raise ExcelErrorOpen, "file #{file} not found"
47
46
  end
@@ -51,13 +50,10 @@ module RobustExcelOle
51
50
  if @workbook then
52
51
  blocked_by_other_book = (File.basename(file) == File.basename(@workbook.Fullname)) &&
53
52
  (not (absolute_path(file) == @workbook.Fullname))
54
- #(not (file == @workbook.Fullname.gsub("\\","/")))
55
53
  if blocked_by_other_book then
56
- case @options[:if_unsaved_other_book]
54
+ case @options[:if_blocked_other_book]
57
55
  when :raise
58
56
  raise ExcelErrorOpen, "blocked by an unsaved book with the same name in a different path"
59
- when :save
60
- #nothing
61
57
  when :forget
62
58
  @workbook.Close
63
59
  when :new_app
@@ -65,7 +61,7 @@ module RobustExcelOle
65
61
  @excel_app = ExcelApp.new(excel_app_options)
66
62
  @workbook = nil
67
63
  else
68
- raise ExcelErrorOpen, ":if_unsaved_other_book: invalid option"
64
+ raise ExcelErrorOpen, ":if_blocked_other_book: invalid option"
69
65
  end
70
66
  else
71
67
  # book open, not saved, not blocked by other book
@@ -1,3 +1,3 @@
1
1
  module RobustExcelOle
2
- VERSION = "0.2.0.6"
2
+ VERSION = "0.2.0.7"
3
3
  end
data/spec/book_spec.rb CHANGED
@@ -252,13 +252,11 @@ describe RobustExcelOle::Book do
252
252
  end
253
253
  end
254
254
 
255
- context "with an unsaved book in a different path" do
255
+ context "with a book in a different path" do
256
256
 
257
257
  before do
258
258
  simple_file_other_path = @dir + '/more_data/simple.xls'
259
259
  @book = RobustExcelOle::Book.open(simple_file_other_path)
260
- @sheet = @book[0]
261
- @book.add_sheet(@sheet, :as => 'a_name')
262
260
  end
263
261
 
264
262
  after do
@@ -266,30 +264,21 @@ describe RobustExcelOle::Book do
266
264
  @new_book.close rescue nil
267
265
  end
268
266
 
269
- it "should raise an error, if :if_unsaved_other_book is :raise" do
267
+ it "should raise an error, if :if_blocked_other_book is :raise" do
270
268
  expect {
271
- @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved_other_book => :raise)
269
+ @new_book = RobustExcelOle::Book.open(@simple_file, :if_blocked_other_book => :raise)
272
270
  }.to raise_error(ExcelErrorOpen, "blocked by an unsaved book with the same name in a different path")
273
271
  end
274
272
 
275
- it "should let the book open, if :if_unsaved_other_book is :save" do
276
- expect {
277
- @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved_other_book => :save)
278
- }.to_not raise_error
279
- @book.should be_alive
280
- @new_book.should be_alive
281
- @new_book.filename.should == @book.filename
282
- end
283
-
284
- it "should close the other book and open the new book, if :if_unsaved_other_book is :forget" do
285
- @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved_other_book => :forget)
273
+ it "should close the other book and open the new book, if :if_blocked_other_book is :forget" do
274
+ @new_book = RobustExcelOle::Book.open(@simple_file, :if_blocked_other_book => :forget)
286
275
  @book.should_not be_alive
287
276
  @new_book.should be_alive
288
277
  @new_book.filename.downcase.should == @simple_file.downcase
289
278
  end
290
279
 
291
- it "should open the book in a new excel application, if :if_unsaved_other_book is :new_app" do
292
- @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved_other_book => :new_app)
280
+ it "should open the book in a new excel application, if :if_blocked_other_book is :new_app" do
281
+ @new_book = RobustExcelOle::Book.open(@simple_file, :if_blocked_other_book => :new_app)
293
282
  @book.should be_alive
294
283
  @new_book.should be_alive
295
284
  @new_book.filename.should_not == @book.filename
@@ -297,16 +286,16 @@ describe RobustExcelOle::Book do
297
286
  @new_book.close
298
287
  end
299
288
 
300
- it "should raise an error, if :if_unsaved_other_book is default" do
289
+ it "should raise an error, if :if_blocked_other_book is default" do
301
290
  expect {
302
291
  @new_book = RobustExcelOle::Book.open(@simple_file)
303
292
  }.to raise_error(ExcelErrorOpen, "blocked by an unsaved book with the same name in a different path")
304
293
  end
305
294
 
306
- it "should raise an error, if :if_unsaved_other_book is invalid option" do
295
+ it "should raise an error, if :if_blocked_other_book is invalid option" do
307
296
  expect {
308
- @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved_other_book => :invalid_option)
309
- }.to raise_error(ExcelErrorOpen, ":if_unsaved_other_book: invalid option")
297
+ @new_book = RobustExcelOle::Book.open(@simple_file, :if_blocked_other_book => :invalid_option)
298
+ }.to raise_error(ExcelErrorOpen, ":if_blocked_other_book: invalid option")
310
299
  end
311
300
 
312
301
  end
data/spec/data/simple.xls CHANGED
Binary file
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
- hash: 83
4
+ hash: 81
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
- - 6
11
- version: 0.2.0.6
10
+ - 7
11
+ version: 0.2.0.7
12
12
  platform: ruby
13
13
  authors:
14
14
  - traths
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-09-28 00:00:00 +02:00
19
+ date: 2014-09-29 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency