mini_readline 0.7.3 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 793eb879f57f816dab6f1477f3002b6960f12334
4
- data.tar.gz: cd10a35a578e18486ac007110415aa180f4411a6
3
+ metadata.gz: b4f4d133f9c4b1b125c72e46f6fc975765bdfc84
4
+ data.tar.gz: 7d4998a8f1e72d332dabf336d3c18d5dc3fc046a
5
5
  SHA512:
6
- metadata.gz: 38ea7f6fe11aa30e9efa69fc239b937447ba0ac1355824eb77bd8e807611e4c6b83c4d04decf57ec0aba32867b1f6b59843cd8f45d28bdd91b33f0b169df6093
7
- data.tar.gz: c239271af20834e7a64324a677225ac9784cabbbbb32ab788a33083e6ad10d7ce8187f26f545a81bb3c583b50172ef02a492eb59b3eced33172aee9953041310
6
+ metadata.gz: 804e9995ed300252cd50c0afdbd102d92c32b50e72a1264d264e7beeaba04acd76425d2e219411402ae558fcc529f43162f83100d6d2f5628027efdc6160db50
7
+ data.tar.gz: 923e4575825fac2d9862daf90742100e0cafe14519142424ef6408806f7a5c069a691a2d26ee183b4a521d6279f393e9b8ebdab9086ccf64db0d825e3b94cbfe
data/README.md CHANGED
@@ -9,6 +9,12 @@ of Ruby programs. It will also try to correct a number of irritating issues
9
9
  encountered when running cross platform environments. See Cross Platform
10
10
  Portability Progress below for more details.
11
11
 
12
+ Finally, I know this code must seem to give off a sort of angry birds vibe
13
+ against the original rb-readline gem. This sort of thing is not good. I owe
14
+ a great debt of gratitude to the authors and maintainers of that vital code.
15
+ Their getting around the whole Win32API, dl obsolescence debacle saved me so
16
+ much time and frustration that words do not suffice. Thanks!
17
+
12
18
  ## Installation
13
19
 
14
20
  Add this line to your application's Gemfile:
@@ -3,38 +3,28 @@
3
3
  #* windows/win_32_api.rb - Support for selected low level Win32 API entry points.
4
4
  module MiniReadline
5
5
 
6
- require 'dl'
6
+ require 'fiddle'
7
7
 
8
- #The classic \Win32API gem is deprecated, so we emulate it with DL.
8
+ #The classic \Win32API gem is deprecated, so we emulate it with fiddle.
9
9
  class Win32API
10
10
 
11
- #A hash of DLL files used for one or more API entry points.
12
11
  DLL = {}
12
+ TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}
13
+ CALL_TYPE_TO_ABI = {:stdcall => 1, :cdecl => 1, nil => 1} #Taken from Fiddle::Importer
13
14
 
14
- #Type mappings
15
- TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
16
-
17
- #Set up an API entry point.
18
15
  def initialize(dllname, func, import, export = "0", calltype = :stdcall)
19
- @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
20
- handle = DLL[dllname] ||= DL.dlopen(dllname)
21
- @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func, calltype)
16
+ @proto = import.join.tr("VPpNnLlIi", "0SSI").chomp('0').split('')
17
+ handle = DLL[dllname] ||= Fiddle.dlopen(dllname)
18
+ @func = Fiddle::Function.new(handle[func], TYPEMAP.values_at(*@proto), CALL_TYPE_TO_ABI[calltype])
22
19
  end
23
20
 
24
- #Call the Win 32 API entry point with appropriate arguments.
25
- #<br>Endemic Code Smells
26
- #* :reek:FeatureEnvy
27
21
  def call(*args)
28
- args.each_with_index do |arg, index|
29
- case @proto[index]
30
- when "S"
31
- args[index], = [arg == 0 ? nil : arg].pack("p").unpack("l!*")
32
- when "I"
33
- args[index], = [arg].pack("I").unpack("i")
34
- end
22
+ args.each_with_index do |x, i|
23
+ args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if @proto[i] == "S" && !x.is_a?(Fiddle::Pointer)
24
+ args[i], = [x].pack("I").unpack("i") if @proto[i] == "I"
35
25
  end
36
26
 
37
- @func.call(args).to_i || 0
27
+ @func.call(*args).to_i || 0
38
28
  end
39
29
 
40
30
  end
@@ -1,4 +1,4 @@
1
1
  module MiniReadline
2
2
  #The current version of the mini_readline gem.
3
- VERSION = "0.7.3"
3
+ VERSION = "0.8.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_readline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -185,9 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.2.3
188
+ rubygems_version: 2.5.2
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: A simplified replacement for readline.
192
192
  test_files: []
193
- has_rdoc: