robust_excel_ole 1.27 → 1.32
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/Changelog +36 -2
- data/README.rdoc +121 -19
- data/___dummy_workbook.xls +0 -0
- data/benchmarking/creek_example.rb +1 -1
- data/benchmarking/reo_example.rb +1 -1
- data/benchmarking/reo_example1.rb +1 -1
- data/benchmarking/reo_example2.rb +1 -1
- data/benchmarking/roo_example.rb +1 -1
- data/benchmarking/simple_xlsx_reader_example.rb +1 -1
- data/benchmarking/spreadsheet_example.rb +1 -1
- data/bin/jreo +19 -0
- data/bin/reo +19 -0
- data/docs/README_excel.rdoc +16 -24
- data/docs/README_listobjects.rdoc +176 -0
- data/docs/README_open.rdoc +20 -16
- data/docs/README_ranges.rdoc +72 -55
- data/docs/README_save_close.rdoc +3 -3
- data/docs/README_sheet.rdoc +19 -20
- data/examples/example_ruby_library.rb +2 -2
- data/examples/introductory_examples/example_open.rb +11 -0
- data/examples/introductory_examples/example_range.rb +2 -2
- data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
- data/examples/modifying_sheets/example_add_names.rb +1 -1
- data/examples/modifying_sheets/example_concating.rb +1 -1
- data/examples/modifying_sheets/example_copying.rb +2 -2
- data/examples/modifying_sheets/example_listobjects.rb +86 -0
- data/examples/modifying_sheets/example_naming.rb +1 -1
- data/examples/modifying_sheets/example_ranges.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
- data/examples/open_save_close/example_read_only.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +3 -3
- data/lib/robust_excel_ole.rb +19 -16
- data/lib/robust_excel_ole/address_tool.rb +54 -44
- data/lib/robust_excel_ole/base.rb +9 -6
- data/lib/robust_excel_ole/bookstore.rb +3 -17
- data/lib/robust_excel_ole/cell.rb +17 -22
- data/lib/robust_excel_ole/cygwin.rb +2 -0
- data/lib/robust_excel_ole/excel.rb +136 -201
- data/lib/robust_excel_ole/general.rb +249 -238
- data/lib/robust_excel_ole/list_object.rb +186 -210
- data/lib/robust_excel_ole/list_row.rb +155 -0
- data/lib/robust_excel_ole/range.rb +130 -94
- data/lib/robust_excel_ole/range_owners.rb +54 -135
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +230 -196
- data/lib/robust_excel_ole/worksheet.rb +254 -133
- data/lib/spec_helper.rb +1 -1
- data/robust_excel_ole.gemspec +4 -3
- data/spec/address_tool_spec.rb +2 -2
- data/spec/base_spec.rb +19 -17
- data/spec/bookstore_spec.rb +3 -4
- data/spec/cell_spec.rb +10 -10
- data/spec/cygwin_spec.rb +1 -1
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +133 -86
- data/spec/general_spec.rb +79 -18
- data/spec/list_object_spec.rb +259 -81
- data/spec/list_row_spec.rb +218 -0
- data/spec/range_spec.rb +75 -41
- data/spec/spec_helper.rb +16 -2
- data/spec/workbook_spec.rb +87 -46
- data/spec/workbook_specs/workbook_all_spec.rb +9 -28
- data/spec/workbook_specs/workbook_close_spec.rb +1 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +52 -45
- data/spec/workbook_specs/workbook_open_spec.rb +103 -50
- data/spec/workbook_specs/workbook_save_spec.rb +22 -23
- data/spec/workbook_specs/workbook_sheet_spec.rb +4 -4
- data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
- data/spec/workbook_specs/workbook_unobtr_spec.rb +553 -395
- data/spec/worksheet_spec.rb +544 -308
- metadata +38 -3
- data/lib/reo_console.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56e6aaeeeec6c073cc4f871ea99185428523959c420e1165d199792979074c5
|
4
|
+
data.tar.gz: 79dd7f6ea160e0045592a3dd8ae31a5b8a162c71b6986dcbcef157eba54c93b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 894959ff3e8c48c8413bbb137013cf8ad7612bb991292f1461b1df9b3371d15c16132ecf0df0dbf78403171381064cfb43d9400604bc2155214f8aa2a514ea7c
|
7
|
+
data.tar.gz: 508b37f27ef7c0e554b565f21263386e1b180cb5269f6a843b2da927eaa3f6eebe5a111a362d5dc96de4726a1c3648673b062b02589739eb7e5ff2a0bb7f59cc
|
data/Changelog
CHANGED
@@ -1,7 +1,41 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [1.
|
4
|
+
## [1.32] 2021-23-04
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- Excel#each
|
8
|
+
- ListObject#each, value, rows_number, position, ==
|
9
|
+
- ListObject#[] extended with options
|
10
|
+
- ListRow#to_h, to_a, values=, keys_values, ==
|
11
|
+
- RangeOwners#names
|
12
|
+
- Worksheet#each_cell
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Worksheet#[]: returning range values given address or defined name (instead of returning a cell when giving address)
|
16
|
+
- Worksheet#each traversing row values instead of cells
|
17
|
+
- Excel#excels_number renamed to #instance_count
|
18
|
+
- Excel#known_excels_number renamed to #known_instance_count
|
19
|
+
- Excel#known_excel_instance renamed to #known_running_instance
|
20
|
+
- Excel#known_excel_instances renamed to #known_running_instances
|
21
|
+
- RangeOwners#rename_range renamed to #rename_name
|
22
|
+
|
23
|
+
## [1.31] 2021-14-01
|
24
|
+
|
25
|
+
### Added
|
26
|
+
- Worksheet#table
|
27
|
+
|
28
|
+
## [1.30] 2020-18-11
|
29
|
+
|
30
|
+
## [1.29] 2020-05-11
|
31
|
+
|
32
|
+
### Added
|
33
|
+
- Workbook.open can also take a Pathname object
|
34
|
+
- General#init_reo_for_win32ole
|
35
|
+
|
36
|
+
## [1.28] 2020-23-10
|
37
|
+
|
38
|
+
## [1.27] 2020-16-10
|
5
39
|
|
6
40
|
## [1.26] 2020-09-10
|
7
41
|
|
@@ -177,7 +211,7 @@ All notable changes to this project will be documented in this file.
|
|
177
211
|
## [1.1.4] - 2018-10-6
|
178
212
|
|
179
213
|
### Added
|
180
|
-
- Book#open: for the options:
|
214
|
+
- Book#open: for the options: simplifiction: :force can be left out
|
181
215
|
- Excel#for_this_instance
|
182
216
|
- Excel#for_all_workbooks
|
183
217
|
- Book#for_this_workbooks
|
data/README.rdoc
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
= News
|
2
|
+
|
3
|
+
== New Interface of #[]
|
4
|
+
|
5
|
+
Worksheet#[] now returns a value instead of a range, e.g.
|
6
|
+
|
7
|
+
worksheet[1,1]
|
8
|
+
# => "foo"
|
9
|
+
|
10
|
+
Transformation: To yield the range, write range() instead of (). For example,
|
11
|
+
|
12
|
+
worksheet.range(1,1)
|
13
|
+
|
14
|
+
or
|
15
|
+
|
16
|
+
worksheet.range([1,1])
|
17
|
+
|
18
|
+
This returns the range of cell with address 1,1.
|
19
|
+
|
20
|
+
With this new interface, we want to be compatible with the standard syntax of other known Excel libraries, e.g. +spreadsheet+ or +axlsx+.
|
21
|
+
|
22
|
+
== Using own WIN32OLE objects
|
23
|
+
|
24
|
+
If you use WIN32OLE objects and define your own methods, please use upper-case method names.
|
25
|
+
The reason is that we extend the class WIN32OLE such that RobustExcelOle methods can be applied to WIN32OLE objects, such the RobustExcelOle objects and their wrapped WIN32OLE objects are interchangeable. We want to develop a refinement such that the name space is not being desturbed.
|
26
|
+
|
1
27
|
= RobustExcelOle
|
2
28
|
|
3
29
|
RobustExcelOle helps controlling Excel.
|
@@ -123,7 +149,7 @@ RobustExcelOle allows unobtrusively reading and modifying workbooks, i.e. access
|
|
123
149
|
|
124
150
|
We can also create a new, empty workbook.
|
125
151
|
|
126
|
-
Workbook.create('spec/data/new_workbook.xls', :
|
152
|
+
Workbook.create('spec/data/new_workbook.xls', visible: true)
|
127
153
|
|
128
154
|
Moreover, we can open the workbook using a block, similar to, e.g., +File.open+.
|
129
155
|
|
@@ -133,15 +159,15 @@ Moreover, we can open the workbook using a block, similar to, e.g., +File.open+.
|
|
133
159
|
|
134
160
|
Once we have a workbook, we can set some options, e.g.
|
135
161
|
|
136
|
-
workbook.for_this_workbook(:
|
162
|
+
workbook.for_this_workbook(visible: true, read_only: false)
|
137
163
|
|
138
164
|
We can also open the workbook and provide the options in one step, e.g.
|
139
165
|
|
140
|
-
workbook = Workbook.open('spec/data/workbook.xls', :
|
166
|
+
workbook = Workbook.open('spec/data/workbook.xls', visible: true)
|
141
167
|
|
142
168
|
or, using abbreviations,
|
143
169
|
|
144
|
-
workbook = Workbook.open('spec/data/workbook.xls', :
|
170
|
+
workbook = Workbook.open('spec/data/workbook.xls', v: true)
|
145
171
|
|
146
172
|
Note that +Workbook.open+ can also connect to workbooks which were not opened via RobustExcelOle (but had been opened before by some user).
|
147
173
|
|
@@ -161,7 +187,7 @@ Finally we can close the workbook
|
|
161
187
|
|
162
188
|
or save and close the workbook in one step.
|
163
189
|
|
164
|
-
workbook.close(:
|
190
|
+
workbook.close(if_unsaved: :save)
|
165
191
|
|
166
192
|
For more details about saving and closing workbooks see
|
167
193
|
{README_save_close}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_save_close.rdoc]
|
@@ -175,7 +201,7 @@ We can start a new Excel instance with
|
|
175
201
|
|
176
202
|
or
|
177
203
|
|
178
|
-
excel1 = Excel.new(:
|
204
|
+
excel1 = Excel.new(reuse: false)
|
179
205
|
|
180
206
|
We can also obtain an Excel object by connecting to the already running Excel instance.
|
181
207
|
|
@@ -183,7 +209,7 @@ We can also obtain an Excel object by connecting to the already running Excel in
|
|
183
209
|
|
184
210
|
or
|
185
211
|
|
186
|
-
excel2 = Excel.new(:
|
212
|
+
excel2 = Excel.new(reuse: true)
|
187
213
|
|
188
214
|
We close the Excel instance using
|
189
215
|
|
@@ -191,11 +217,11 @@ We close the Excel instance using
|
|
191
217
|
|
192
218
|
Closed Excel instances can be reopened.
|
193
219
|
|
194
|
-
excel1.recreate(:
|
220
|
+
excel1.recreate(reopen_workbooks: true, visible: true)
|
195
221
|
|
196
222
|
Closing all Excel instances is done by
|
197
223
|
|
198
|
-
Excel.close_all(:
|
224
|
+
Excel.close_all(if_unsaved: :forget)
|
199
225
|
|
200
226
|
For hard terminating all Excel processes we can use
|
201
227
|
|
@@ -214,12 +240,12 @@ For example, suppose we want to open a workbook.
|
|
214
240
|
|
215
241
|
Now we want to open another workbook in a different Excel instance.
|
216
242
|
|
217
|
-
workbook2 = Workbook.open('spec/data/different_workbook.xls', :
|
243
|
+
workbook2 = Workbook.open('spec/data/different_workbook.xls', excel: :new)
|
218
244
|
|
219
245
|
We can also create a third Excel instance and open another workbook in this instance.
|
220
246
|
|
221
247
|
excel1 = Excel.create
|
222
|
-
workbook3 = Workbook.open('spec/data/another_workbook.xls', :
|
248
|
+
workbook3 = Workbook.open('spec/data/another_workbook.xls', excel: excel1)
|
223
249
|
|
224
250
|
A workbook is opened by default in the Excel instance where it was open before most recently.
|
225
251
|
|
@@ -228,11 +254,11 @@ A workbook is opened by default in the Excel instance where it was open before m
|
|
228
254
|
|
229
255
|
If this Excel instance is damaged or closed, then options control whether the workbook shall be opened in the current (active), a new or a given Excel instance.
|
230
256
|
|
231
|
-
workbook1 = Workbook.open('spec/data/workbook.xls', :
|
257
|
+
workbook1 = Workbook.open('spec/data/workbook.xls', default: {excel: new})
|
232
258
|
|
233
259
|
Without the option +:default+, the workbook can be forced to be opened in the current, new or given Excel instance, no matter if and where it was opened before, e.g.
|
234
260
|
|
235
|
-
workbook2 = Workbook.open('spec/data/workbook.xls', :
|
261
|
+
workbook2 = Workbook.open('spec/data/workbook.xls', excel: excel1)
|
236
262
|
|
237
263
|
=== Managing conflicts with unsaved and blocking workbooks
|
238
264
|
|
@@ -240,13 +266,13 @@ RobustExcelOle enables processing workbooks, while still supporting user's inter
|
|
240
266
|
|
241
267
|
For example, suppose we want to process a list of workbooks. RobustExcelOle allows to rapidly open, manipulate, close and save these workbooks. Now assume, the workbook "workbook.xls" is being processed, while the user has already opened this workbook, has modified but not saved it yet. Excel would prompt a message and ask the user what to do. RobustExcelOle solves this conflict by using an option that states whether the changes of the user should be saved (accepted) or discarded (forgotten) before opening the workbook, e.g.
|
242
268
|
|
243
|
-
workbook = Workbook.open('workbook.xls', :
|
269
|
+
workbook = Workbook.open('workbook.xls', if_unsaved: :accept)
|
244
270
|
|
245
271
|
Similarly, if the user has opened a workbook that has the same name but a different path, the conflict can be solved via an option.
|
246
272
|
|
247
273
|
workbook1 = Workbook.open('spec/data/workbook.xls')
|
248
274
|
# do something
|
249
|
-
workbook2 = Workbook.open('spec/data/more/workbook.xls', :
|
275
|
+
workbook2 = Workbook.open('spec/data/more/workbook.xls', if_blocked: :forget)
|
250
276
|
|
251
277
|
For more details about opening and closing workbooks in Excel instances see {README_open}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_open.rdoc]
|
252
278
|
|
@@ -277,7 +303,7 @@ We can read and change the worksheet name.
|
|
277
303
|
|
278
304
|
We can copy the first worksheet, name it and add it before the third worksheet.
|
279
305
|
|
280
|
-
workbook.add_or_copy_sheet(sheet, :
|
306
|
+
workbook.add_or_copy_sheet(sheet, as: "copied_name, before: workbook.last_sheet)
|
281
307
|
|
282
308
|
For more details about processing worksheets see {README_sheet}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_sheet.rdoc]
|
283
309
|
|
@@ -297,7 +323,7 @@ and the third column
|
|
297
323
|
|
298
324
|
We can read the first cell, using
|
299
325
|
|
300
|
-
worksheet[1,1].
|
326
|
+
worksheet[1,1]. # => "foo"
|
301
327
|
|
302
328
|
or
|
303
329
|
|
@@ -318,6 +344,76 @@ and set another value to that range.
|
|
318
344
|
For more details about reading and writing contents of cells and ranges see {README_ranges}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_ranges.rdoc]
|
319
345
|
|
320
346
|
|
347
|
+
=== List Objects (Tables)
|
348
|
+
|
349
|
+
We can define a list object (or table) from scratch
|
350
|
+
|
351
|
+
table = ListObject.new(worksheet, "table 1", [1,1], 3, ["Person","AmountSales"])
|
352
|
+
|
353
|
+
or get a given list object in a worksheet given its table number or name.
|
354
|
+
|
355
|
+
table = worksheet.table(1)
|
356
|
+
|
357
|
+
or
|
358
|
+
|
359
|
+
table = worksheet.table("table1")
|
360
|
+
|
361
|
+
A list row can be accessed by providing either the row number or a key, i.e. hash of column name - value pairs, e.g.
|
362
|
+
|
363
|
+
row1 = table[1]
|
364
|
+
|
365
|
+
row1 = table[{"Number": 1, "Person": "John"}]
|
366
|
+
|
367
|
+
You can get all or a maximal number of list rows matching the key.
|
368
|
+
|
369
|
+
rows = table[{"Number": 1}, limit: 2]
|
370
|
+
rows = table[{"Number": 1}, limit: nil]
|
371
|
+
|
372
|
+
Now we can set value of a cell of the table with help of methods that are equal to or are underscored variants of the column names, e.g.
|
373
|
+
|
374
|
+
row1.person = "John"
|
375
|
+
|
376
|
+
or
|
377
|
+
|
378
|
+
row1["Person"] = "John"
|
379
|
+
|
380
|
+
Similarly you can get the values. We can also read all values in a row.
|
381
|
+
|
382
|
+
table[1].to_a
|
383
|
+
# => ["John", 40]
|
384
|
+
|
385
|
+
table[1].to_h
|
386
|
+
# => {"Person": "John", "AmountSales": 40}
|
387
|
+
|
388
|
+
We can set the values in a whole row.
|
389
|
+
|
390
|
+
table[1].values = ["Herber", 80]
|
391
|
+
|
392
|
+
Similarly, we can read and set the values in a whole column, e.g.
|
393
|
+
|
394
|
+
table.column_values("Person")
|
395
|
+
# => ["John", "Peter"]
|
396
|
+
|
397
|
+
and
|
398
|
+
|
399
|
+
table.set_column_values(1, ["Herbert","Paul"])
|
400
|
+
|
401
|
+
We can add and delete rows and columns, supplying optionally their name, the position and contents.
|
402
|
+
|
403
|
+
table.add_column("column_name", 3, ["John", "Paul"])
|
404
|
+
table.add_row(3, ["John", 40, 2, 2004])
|
405
|
+
|
406
|
+
table.delete_column_values("column_name")
|
407
|
+
table[2].delete_values
|
408
|
+
|
409
|
+
Finally we can delete empty rows and columns.
|
410
|
+
|
411
|
+
table.delete_empty_rows
|
412
|
+
table.delete_empty_columns
|
413
|
+
|
414
|
+
For more details about using and processing list objects see {README_listobjects}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_listobjects.rdoc]
|
415
|
+
|
416
|
+
|
321
417
|
=== More features
|
322
418
|
|
323
419
|
1. The method +General.change_current_binding+ allows to change the value of self within the current binding, while preserving the local variables, without starting another repl. Assume, +object+ shall be the self, then you would put
|
@@ -335,14 +431,20 @@ or
|
|
335
431
|
However, this command also starts another pry repl (with another binding). Moreover, local variables in the previous binding are forgotten.
|
336
432
|
|
337
433
|
|
338
|
-
2. The
|
434
|
+
2. The class Win32Ole is being extended such that RobustExcelOle methods can be applied to WIN32OLE objects. As mentioned above, the RobustExcelOle objects are wrapper of corresponding WIN32OLE objects. So the RobustExcelOle objects and their wrapped WIN32OLE objects are interchangeable. One example would be
|
339
435
|
|
340
436
|
range.ole_range.copy([4,3])
|
341
437
|
|
342
|
-
Likewise it is possible to convert ("type-lift") Win32Ole objects into the corresponding RobustExcelOle object, using
|
438
|
+
Likewise it is possible to convert ("type-lift") Win32Ole objects into the corresponding RobustExcelOle object, using the method +to_reo+. It is a refinement of the class WIN32OLE. So you can write
|
439
|
+
|
440
|
+
using ToReoRefinement
|
343
441
|
|
344
442
|
range = sheet.Names.Item("firstcell").to_reo
|
345
443
|
|
444
|
+
=== Design issues
|
445
|
+
|
446
|
+
We don't consider active worksheets or workbooks in our implementation, because this has been proven to be very error-prone.
|
447
|
+
|
346
448
|
=== Examples
|
347
449
|
|
348
450
|
You can run the examples included in the directory +examples+, e.g.
|
data/___dummy_workbook.xls
CHANGED
Binary file
|
@@ -10,7 +10,7 @@ start_time = Time.now
|
|
10
10
|
workbook = Creek::Book.new './sample_excel_files/xlsx_500_rows.xlsx'
|
11
11
|
|
12
12
|
worksheets = workbook.sheets
|
13
|
-
puts "Found #{worksheets.
|
13
|
+
puts "Found #{worksheets.size} worksheets"
|
14
14
|
|
15
15
|
worksheets.each do |worksheet|
|
16
16
|
puts "Reading: #{worksheet.name}"
|
data/benchmarking/reo_example.rb
CHANGED
data/benchmarking/roo_example.rb
CHANGED
@@ -9,7 +9,7 @@ start_time = Time.now
|
|
9
9
|
workbook = Roo::Spreadsheet.open './sample_excel_files/xlsx_500_rows.xlsx'
|
10
10
|
|
11
11
|
worksheets = workbook.sheets
|
12
|
-
puts "Found #{worksheets.
|
12
|
+
puts "Found #{worksheets.size} worksheets"
|
13
13
|
|
14
14
|
worksheets.each do |worksheet|
|
15
15
|
puts "Reading: #{worksheet}"
|
@@ -10,7 +10,7 @@ start_time = Time.now
|
|
10
10
|
workbook = SimpleXlsxReader.open './sample_excel_files/xlsx_500_rows.xlsx'
|
11
11
|
|
12
12
|
worksheets = workbook.sheets
|
13
|
-
puts "Found #{worksheets.
|
13
|
+
puts "Found #{worksheets.size} worksheets"
|
14
14
|
|
15
15
|
worksheets.each do |worksheet|
|
16
16
|
puts "Reading: #{worksheet.name}"
|
@@ -11,7 +11,7 @@ start_time = Time.now
|
|
11
11
|
workbook = Spreadsheet.open './sample_excel_files/xls_25000_rows.xls'
|
12
12
|
|
13
13
|
worksheets = workbook.worksheets
|
14
|
-
puts "Found #{worksheets.
|
14
|
+
puts "Found #{worksheets.size} worksheets"
|
15
15
|
|
16
16
|
|
17
17
|
worksheets.each do |worksheet|
|
data/bin/jreo
CHANGED
@@ -15,10 +15,29 @@ Pry.config.prompt_name = "REO "
|
|
15
15
|
#Pry.config.history_save = true
|
16
16
|
#Pry.editor = 'notepad' # 'subl', 'vi'
|
17
17
|
|
18
|
+
prompt_proc1 = proc { |target_self, nest_level, pry|
|
19
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
|
20
|
+
}
|
21
|
+
|
22
|
+
prompt_proc2 = proc { |target_self, nest_level, pry|
|
23
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect.gsub(/\"/, ''))})})#{":#{nest_level}" unless nest_level.zero?}* "
|
24
|
+
}
|
25
|
+
|
26
|
+
Pry.config.prompt = if RUBY_PLATFORM =~ /java/
|
27
|
+
[prompt_proc1, prompt_proc2]
|
28
|
+
else
|
29
|
+
Pry::Prompt.new(
|
30
|
+
"REO",
|
31
|
+
"The RobustExcelOle Prompt. Besides the standard information it puts the current object",
|
32
|
+
[prompt_proc1, prompt_proc2]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
18
36
|
hooks = Pry::Hooks.new
|
19
37
|
|
20
38
|
hooks.add_hook :when_started, :hook12 do
|
21
39
|
puts 'REO console started'
|
22
40
|
puts
|
23
41
|
end
|
42
|
+
|
24
43
|
Pry.start(nil, hooks: hooks)
|
data/bin/reo
CHANGED
@@ -15,10 +15,29 @@ Pry.config.prompt_name = "REO "
|
|
15
15
|
#Pry.config.history_save = true
|
16
16
|
#Pry.editor = 'notepad' # 'subl', 'vi'
|
17
17
|
|
18
|
+
prompt_proc1 = proc { |target_self, nest_level, pry|
|
19
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
|
20
|
+
}
|
21
|
+
|
22
|
+
prompt_proc2 = proc { |target_self, nest_level, pry|
|
23
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
|
24
|
+
}
|
25
|
+
|
26
|
+
Pry.config.prompt = if RUBY_PLATFORM =~ /java/
|
27
|
+
[prompt_proc1, prompt_proc2]
|
28
|
+
else
|
29
|
+
Pry::Prompt.new(
|
30
|
+
"REO",
|
31
|
+
"The RobustExcelOle Prompt. Besides the standard information it puts the current object",
|
32
|
+
[prompt_proc1, prompt_proc2]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
18
36
|
hooks = Pry::Hooks.new
|
19
37
|
|
20
38
|
hooks.add_hook :when_started, :hook12 do
|
21
39
|
puts 'REO console started'
|
22
40
|
puts
|
23
41
|
end
|
42
|
+
|
24
43
|
Pry.start(nil, hooks: hooks)
|