robust_excel_ole 1.25 → 1.26

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
  SHA256:
3
- metadata.gz: ec2281789116629bceb9d28bb49ea8c75f10306084d5d81348cd3d05f521e2ac
4
- data.tar.gz: 1adb8026858ed313c16dae70914448ce4c77a8cfc047fdf5fba15cdb41a9e448
3
+ metadata.gz: a2553a7622f9092b5067ad3f7e945d57a1dbfa6e540716b326c6b684a351cf79
4
+ data.tar.gz: e623c4a2f3e22ef1da88b6475d7f6dc277c9f3f4581db27427fd9ca6aa400f24
5
5
  SHA512:
6
- metadata.gz: f0daec2c817688fe78593042eefc2bd34c3d8e8d9eaed6cbcf1653892fc3d4e16e146832f7d9e8ddeac70d4d66bbaf22e7c72cb4e1aa27cfdf2ca2f04f29146b
7
- data.tar.gz: be997a68bd9b9c543b65c780779607210bd005db79bb448fec1c5f49cd05760213b01860555d8439ed7f91264e833e889034db7bc75e85681a77c0e224c0956a
6
+ metadata.gz: 9056cec7af1bf9c6c04ab2df83dd080bb63308f5c5a7d6af13286090d357441928d7dcb2dde2371940e36729fafb26460098d2063254f8809796a9dde87ddc85
7
+ data.tar.gz: d036c741ef593695e0fecfd8f1e34b1db5bec0e7e2430b5a88f1e16a297a804b1a9d95c8bc847bc993f0a1ea4b666cd56db200cc9cdfec38078dab6c5b4ef59b
data/Changelog CHANGED
@@ -1,6 +1,17 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.26] 2020-09-10
5
+
6
+ ### Added
7
+ - General#change_current_binding
8
+
9
+ ## [1.25] 2020-10-09]
10
+
11
+ ## [1.24] 2020-25-09
12
+
13
+ ## [1.23] 2020-02-09
14
+
4
15
  ## [1.22] 2020-10-08
5
16
 
6
17
  ### Added
@@ -64,15 +64,7 @@ If you want to start the console under jruby, and if you don't want to use a ver
64
64
 
65
65
  jreo
66
66
 
67
- The call of the console will include RobustExcelOle for you. The consoles require the ruby gem 'pry' and 'pry-bond' to enable the ruby shell 'pry' with filename and string completion. The ruby shell 'pry' allows, among other useful things, to change the value of 'self' in the console: Let 'object' be an (almost) arbitrary object, e.g. a workbook, then you can put
68
-
69
- object.pry
70
-
71
- or
72
-
73
- cd object
74
-
75
- to assign self to this object. The original pry console is adapted to preserve local variables.
67
+ The call of the console will include RobustExcelOle for you. The consoles require the ruby gem 'pry' and 'pry-bond' to enable the ruby shell 'pry' with filename and string completion.
76
68
 
77
69
  The following examples can be used for both scripts and console. If you have started the console in the gem path, you can just put these examples.
78
70
 
@@ -326,7 +318,21 @@ and set another value to that range.
326
318
  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]
327
319
 
328
320
 
329
- === More things
321
+ === More features
322
+
323
+ The ruby shell 'pry' allows, among other useful things, to change the value of 'self' in the console. For example,
324
+
325
+ object.pry
326
+
327
+ or
328
+
329
+ cd object
330
+
331
+ will set +object+ to self. However, this command also starts another pry repl (with another binding). Moreover, local variables in the previous binding are forgotten.
332
+
333
+ 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.
334
+
335
+ General.change_current_binding
330
336
 
331
337
  You can convert some Win32Ole objects into a RobustExcelOle object.
332
338
 
@@ -4,41 +4,34 @@ require '../robust_excel_ole/lib/robust_excel_ole'
4
4
  include REO
5
5
  include General
6
6
 
7
- # pry mit behalten lokaler Variablen
7
+ # change the current binding such that self is the current object in the pry-instance,
8
+ # preserve the local variables
8
9
 
9
10
  class Pry
10
11
 
11
- class REPL
12
+ class << self
13
+ attr_accessor :pry_instance
14
+ end
12
15
 
13
- def repl
14
- loop do
15
- case val = read
16
- when :control_c
17
- output.puts ""
18
- pry.reset_eval_string
19
- when :no_more_input
20
- output.puts "" if output.tty?
21
- break
22
- else
23
- output.puts "" if val.nil? && output.tty?
24
- # determine the local variables in the binding before evaluation
25
- bnd = pry.binding_stack.first
26
- exclude_vars = [:__, :_, :_dir, :_dir_, :_file, :_file_, :_in_, :_out_, :_ex, :_ex_, :pry_instance]
27
- local_vars = Pry.get_local_vars
28
- bnd.local_variables.each do |var|
29
- unless exclude_vars.include?(var)
30
- pry.add_sticky_local(var) do
31
- bnd.local_variable_get(var)
32
- end
33
- end
34
- end
35
- return pry.exit_value unless pry.eval(val)
36
- end
37
- end
16
+ def self.change_current_binding(current_object)
17
+ pry_instance = self.pry_instance
18
+ old_binding = pry_instance.binding_stack.pop
19
+ pry_instance.push_binding(current_object.__binding__)
20
+ exclude_vars = [:__, :_, :_dir, :_dir_, :_file, :_file_, :_in_, :_out_, :_ex, :_ex_, :pry_instance]
21
+ old_binding.local_variables.each do |var|
22
+ pry_instance.add_sticky_local(var) {old_binding.local_variable_get(var)} unless exclude_vars.include?(var)
38
23
  end
24
+ self.pry_instance = pry_instance
25
+ nil
39
26
  end
40
- end
41
27
 
28
+ def push_initial_binding(target = nil)
29
+ # memorize the current pry instance
30
+ self.class.pry_instance = self
31
+ push_binding(target || Pry.toplevel_binding)
32
+ end
33
+
34
+ end
42
35
 
43
36
  # some pry configuration
44
37
  Pry.config.windows_console_warning = false
@@ -48,20 +41,23 @@ Pry.config.prompt_name = "REO "
48
41
  #Pry.config.history_save = true
49
42
  #Pry.editor = 'notepad' # 'subl', 'vi'
50
43
 
51
- Pry.config.prompt = Pry::Prompt.new(
52
- "REO",
53
- "The RobustExcelOle Prompt. Besides the standard information it puts the current object",
54
- [
55
- proc { |target_self, nest_level, pry|
44
+ prompt_proc1 = proc { |target_self, nest_level, pry|
56
45
  "[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect)})#{":#{nest_level}" unless nest_level.zero?}> "
57
- },
46
+ }
58
47
 
59
- proc { |target_self, nest_level, pry|
48
+ prompt_proc2 = proc { |target_self, nest_level, pry|
60
49
  "[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect)})#{":#{nest_level}" unless nest_level.zero?}* "
61
50
  }
62
- ]
63
- )
64
51
 
52
+ Pry.config.prompt = if RUBY_PLATFORM =~ /java/
53
+ [prompt_proc1, prompt_proc2]
54
+ else
55
+ Pry::Prompt.new(
56
+ "REO",
57
+ "The RobustExcelOle Prompt. Besides the standard information it puts the current object",
58
+ [prompt_proc1, prompt_proc2]
59
+ )
60
+ end
65
61
 
66
62
  hooks = Pry::Hooks.new
67
63
 
@@ -76,7 +76,7 @@ module RobustExcelOle
76
76
  end
77
77
  connected = (not ole_xl.nil?) && win32ole_excel.nil?
78
78
  ole_xl ||= WIN32OLE.new('Excel.Application')
79
- hwnd = ole_xl.HWnd
79
+ hwnd = ole_xl.Hwnd
80
80
  stored = hwnd2excel(hwnd)
81
81
  if stored && stored.alive?
82
82
  result = stored
@@ -297,7 +297,7 @@ module RobustExcelOle
297
297
  finishing_living_excel = alive?
298
298
  if finishing_living_excel
299
299
  hwnd = (begin
300
- @ole_excel.HWnd
300
+ @ole_excel.Hwnd
301
301
  rescue
302
302
  nil
303
303
  end)
@@ -44,7 +44,7 @@ module General
44
44
  file[0,2] = './' if ::EXPANDPATH_JRUBY_BUG && file =~ /[A-Z]:[^\/]/
45
45
  file = File.expand_path(file)
46
46
  file = RobustExcelOle::Cygwin.cygpath('-w', file) if RUBY_PLATFORM =~ /cygwin/
47
- WIN32OLE.new('Scripting.FileSystemObject').GetAbsolutePathName(file).tr('/','\\')
47
+ WIN32OLE.new('Scripting.FileSystemObject').GetAbsolutePathName(file) #.tr('/','\\')
48
48
  end
49
49
 
50
50
  # @private
@@ -64,7 +64,11 @@ module General
64
64
  path
65
65
  end
66
66
 
67
- module_function :absolute_path, :canonize, :normalize
67
+ def change_current_binding(current_object)
68
+ Pry.change_current_binding(current_object)
69
+ end
70
+
71
+ module_function :absolute_path, :canonize, :normalize, :change_current_binding
68
72
 
69
73
  end
70
74
 
@@ -142,32 +146,36 @@ class WIN32OLE
142
146
  raise TypeREOError, "given object cannot be type-lifted to a RobustExcelOle object"
143
147
  end
144
148
 
149
+ =begin
150
+ def to_reo
151
+ case ole_type.name
152
+ when 'Range' then RobustExcelOle::Range.new(self)
153
+ when '_Worksheet' then RobustExcelOle::Worksheet.new(self)
154
+ when '_Workbook' then RobustExcelOle::Workbook.new(self)
155
+ when '_Application' then RobustExcelOle::Excel.new(self)
156
+ else
157
+ self
158
+ end
159
+ end
160
+ =end
145
161
 
146
- # def method_missing(name, *args, &blk)
147
- # puts "method_missing:"
148
- # puts "name: #{name.inspect}"
149
- # puts "self: #{self}"
150
- # puts "self.ole_type: #{self.ole_type}"
151
- # puts "self.to_reo: #{self.to_reo}"
152
- # begin
153
- # reo_obj = self.to_reo
154
- # rescue
155
- # puts "error: #{$!.message}"
156
- # raise # NoMethodError, "undefined method #{name.inspect} for #{self.inspect}"
157
- # end
158
- # reo_obj.send(name, *args, &blk)
159
- # end
160
-
161
- #alias method_missing_before_implicit_typelift method_missing
162
- #def method_missing(name, *args, &blk)
163
- # begin
164
- # reo_obj = self.to_reo
165
- # rescue
166
- # puts "$!.message: #{$!.message}"
167
- # method_missing_before_implicit_typelift(name, *args, &blk)
168
- # end
169
- # reo_obj.send(name, *args, &blk)
170
- #end
162
+ =begin
163
+ alias method_missing_before_implicit_typelift method_missing
164
+
165
+ def method_missing(name, *args, &blk)
166
+ puts "method_missing:"
167
+ puts "name: #{name.inspect}"
168
+ #raise NoMethodError if name.to_s == "Hwnd" or name.to_s == "FullName" or name.to_s == "UsedRange" or name.to_s == "Row" or name.to_s == "ListRows"
169
+ begin
170
+ reo_obj = self.to_reo
171
+ puts "reo_obj: #{reo_obj.inspect}"
172
+ rescue
173
+ puts "$!.message: #{$!.message}"
174
+ method_missing_before_implicit_typelift(name, *args, &blk)
175
+ end
176
+ reo_obj.send(name, *args, &blk)
177
+ end
178
+ =end
171
179
 
172
180
  end
173
181
 
@@ -293,7 +301,6 @@ module MethodHelpers
293
301
  super
294
302
  end
295
303
  end
296
-
297
304
  end
298
305
 
299
306
  REO = RobustExcelOle
@@ -1,3 +1,3 @@
1
1
  module RobustExcelOle
2
- VERSION = "1.25"
2
+ VERSION = "1.26"
3
3
  end
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.25'
4
+ version: '1.26'
5
5
  platform: ruby
6
6
  authors:
7
7
  - traths
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-30 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry