Sha256: 091e8215194b469f4d546c4a6b27d7c244ea11fb23bf250de7e8b769922cd27b

Contents?: true

Size: 734 Bytes

Versions: 13

Compression:

Stored size: 734 Bytes

Contents

module Highrise
  class CurlHelper 
    
    # thanks mislav ;) http://github.com/mislav/curly/tree/master
    
    def initialize
      @curly = Curly.new
      @curly.http_auth_types = Curl::CURLAUTH_BASIC
    end
    
    def get_userpwd_from_url(url)
      userpwd_from_url_regex = /(http|https):\/\/((?:[\w\.\-\+%!$&'\(\)*\+,;=]+:)*[\w\.\-\+%!$&'\(\)*\+,;=]+)?/
      match = userpwd_from_url_regex.match(url)
      match.captures[1] unless match.nil?
    end
    
    def get_document(url)
      @curly.userpwd = get_userpwd_from_url(url)
      @curly.get(url).doc
    end
    
    def get_document_from_id(collection_name_and_id)
      get_document("#{Highrise::Base.site.to_s}#{collection_name_and_id}")
    end
    
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
kmayer-highrise-0.11.0 lib/highrise/curlhelper.rb
kmayer-highrise-0.11.1 lib/highrise/curlhelper.rb
kmayer-highrise-0.12.0 lib/highrise/curlhelper.rb
kmayer-highrise-0.13.0 lib/highrise/curlhelper.rb
kmayer-highrise-0.7.0 lib/highrise/curlhelper.rb
kmayer-highrise-0.7.1 lib/highrise/curlhelper.rb
kmayer-highrise-0.8.0 lib/highrise/curlhelper.rb
kmayer-highrise-0.8.1 lib/highrise/curlhelper.rb
kmayer-highrise-0.9.0 lib/highrise/curlhelper.rb
kmayer-highrise-0.9.1 lib/highrise/curlhelper.rb
kmayer-highrise-0.9.2 lib/highrise/curlhelper.rb
tapajos-highrise-0.8.0 lib/highrise/curlhelper.rb
soleone-highrise-0.13.3 lib/highrise/curlhelper.rb