curl_ffi 0.0.6 → 0.0.8
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/.gitignore +2 -0
- data/lib/bindings.rb +3 -1
- data/lib/curl_ffi/easy.rb +18 -17
- data/lib/curl_ffi/version.rb +1 -1
- metadata +3 -3
    
        data/lib/bindings.rb
    CHANGED
    
    | @@ -934,7 +934,9 @@ module CurlFFI | |
| 934 934 | 
             
                elsif option >= OPTION_FUNCTIONPOINT
         | 
| 935 935 | 
             
                  self.easy_setopt_pointer(handle, option, value)
         | 
| 936 936 | 
             
                elsif option >= OPTION_OBJECTPOINT
         | 
| 937 | 
            -
                  if value. | 
| 937 | 
            +
                  if value.is_a?(Proc)
         | 
| 938 | 
            +
                    self.easy_setopt_pointer(handle, option, value)
         | 
| 939 | 
            +
                  elsif value.respond_to?(:to_str)
         | 
| 938 940 | 
             
                    self.easy_setopt_string(handle, option, value.to_str)
         | 
| 939 941 | 
             
                  else
         | 
| 940 942 | 
             
                    self.easy_setopt_pointer(handle, option, value)
         | 
    
        data/lib/curl_ffi/easy.rb
    CHANGED
    
    | @@ -3,33 +3,39 @@ require "curl_ffi" | |
| 3 3 | 
             
            module CurlFFI
         | 
| 4 4 | 
             
              class Easy
         | 
| 5 5 |  | 
| 6 | 
            -
                attr_reader :pointer
         | 
| 6 | 
            +
                attr_reader :pointer, :options
         | 
| 7 7 |  | 
| 8 8 | 
             
                def initialize
         | 
| 9 9 | 
             
                  @pointer = FFI::AutoPointer.new(CurlFFI.easy_init, CurlFFI.method(:easy_cleanup))
         | 
| 10 | 
            +
                  @options = {}
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def reset_options
         | 
| 14 | 
            +
                  @options = {}
         | 
| 10 15 | 
             
                end
         | 
| 11 16 |  | 
| 12 17 | 
             
                def reset
         | 
| 13 18 | 
             
                  CurlFFI.easy_reset(@pointer)
         | 
| 19 | 
            +
                  @options = {}
         | 
| 14 20 | 
             
                end
         | 
| 15 21 |  | 
| 16 22 | 
             
                def initialize_copy(other)
         | 
| 17 23 | 
             
                  @pointer = FFI::AutoPointer.new(CurlFFI.easy_duphandle(other.pointer), CurlFFI.method(:easy_cleanup))
         | 
| 18 24 | 
             
                end
         | 
| 19 25 |  | 
| 20 | 
            -
                def escape( | 
| 21 | 
            -
                  str_pointer = CurlFFI.easy_escape(@pointer,  | 
| 22 | 
            -
                   | 
| 26 | 
            +
                def escape(_string)
         | 
| 27 | 
            +
                  str_pointer = CurlFFI.easy_escape(@pointer, _string, _string.length)
         | 
| 28 | 
            +
                  @escaped    = str_pointer.null? ? nil : str_pointer.read_string.dup
         | 
| 23 29 | 
             
                  CurlFFI.free(str_pointer)
         | 
| 24 | 
            -
                   | 
| 30 | 
            +
                  return(@escaped)
         | 
| 25 31 | 
             
                end
         | 
| 26 32 |  | 
| 27 33 | 
             
                def unescape(string)
         | 
| 28 34 | 
             
                  int_pointer = FFI::MemoryPointer.new(:int)
         | 
| 29 35 | 
             
                  str_pointer = CurlFFI.easy_unescape(@pointer, string, string.length, int_pointer)
         | 
| 30 | 
            -
                   | 
| 36 | 
            +
                  @unescaped  = str_pointer.read_string(int_pointer.read_int).dup
         | 
| 31 37 | 
             
                  CurlFFI.free(str_pointer)
         | 
| 32 | 
            -
                   | 
| 38 | 
            +
                  @unescaped
         | 
| 33 39 | 
             
                end
         | 
| 34 40 |  | 
| 35 41 | 
             
                def error_string(error_code)
         | 
| @@ -37,19 +43,16 @@ module CurlFFI | |
| 37 43 | 
             
                end
         | 
| 38 44 |  | 
| 39 45 | 
             
                def perform
         | 
| 40 | 
            -
                  check_code(CurlFFI.easy_perform(@pointer))
         | 
| 46 | 
            +
                  check_code(@_code = CurlFFI.easy_perform(@pointer))
         | 
| 41 47 | 
             
                end
         | 
| 42 48 |  | 
| 43 49 | 
             
                def setopt(option, value)
         | 
| 44 | 
            -
                   | 
| 45 | 
            -
             | 
| 50 | 
            +
                  @_option = option
         | 
| 51 | 
            +
                  @_value  = value
         | 
| 46 52 |  | 
| 47 | 
            -
             | 
| 48 | 
            -
                  check_code(CurlFFI.easy_setopt_handler(@pointer, option, value))
         | 
| 49 | 
            -
                end
         | 
| 53 | 
            +
                  check_code(@_code = CurlFFI.easy_setopt(@pointer, @_option, @_value))
         | 
| 50 54 |  | 
| 51 | 
            -
             | 
| 52 | 
            -
                  check_code(CurlFFI.easy_setopt_handler_string(@pointer, option, value))
         | 
| 55 | 
            +
                  @options[@_option] = @_value
         | 
| 53 56 | 
             
                end
         | 
| 54 57 |  | 
| 55 58 | 
             
                def getinfo(info)
         | 
| @@ -68,11 +71,9 @@ module CurlFFI | |
| 68 71 |  | 
| 69 72 | 
             
                protected
         | 
| 70 73 | 
             
                  def check_code(result)
         | 
| 71 | 
            -
                    
         | 
| 72 74 | 
             
                    if result != :OK
         | 
| 73 75 | 
             
                      raise "Error - #{result}" unless result.nil?
         | 
| 74 76 | 
             
                    end
         | 
| 75 | 
            -
                    return result
         | 
| 76 77 | 
             
                  end
         | 
| 77 78 |  | 
| 78 79 | 
             
                  def getinfo_double(info)
         | 
    
        data/lib/curl_ffi/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version | |
| 5 5 | 
             
              segments: 
         | 
| 6 6 | 
             
              - 0
         | 
| 7 7 | 
             
              - 0
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: 0.0. | 
| 8 | 
            +
              - 8
         | 
| 9 | 
            +
              version: 0.0.8
         | 
| 10 10 | 
             
            platform: ruby
         | 
| 11 11 | 
             
            authors: 
         | 
| 12 12 | 
             
            - Arthur Schreiber
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2010-11- | 
| 18 | 
            +
            date: 2010-11-12 00:00:00 -08:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         |