Sha256: 1629902259d1077d4ad62f54f3c9bbc6870e0ce23d42be8ff280769774d9081d

Contents?: true

Size: 460 Bytes

Versions: 14

Compression:

Stored size: 460 Bytes

Contents

require "open-uri"
require "yajl/json_gem"

module Kurchatov
  module Mixin
    module Http

      # /path/to/file, https://ya.ru, http://a:a@yandex.ru
      def rest_get(url)
        uri = URI(url)
        if uri.userinfo
          open("#{uri.scheme}://#{uri.hostname}:#{uri.port}#{uri.request_uri}",
               :http_basic_authentication => [uri.user, uri.password]).read
        else
          open(url).read
        end
      end

    end 
  end 
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kurchatov-0.0.5.pre5 lib/kurchatov/mixin/http.rb
kurchatov-0.0.5.pre4 lib/kurchatov/mixin/http.rb
kurchatov-0.0.5.pre2 lib/kurchatov/mixin/http.rb
kurchatov-0.0.5.pre1 lib/kurchatov/mixin/http.rb
kurchatov-0.0.4 lib/kurchatov/mixin/http.rb
kurchatov-0.0.4d lib/kurchatov/mixin/http.rb
kurchatov-0.0.4c lib/kurchatov/mixin/http.rb
kurchatov-0.0.4b lib/kurchatov/mixin/http.rb
kurchatov-0.0.3 lib/kurchatov/mixin/http.rb
kurchatov-0.0.3b lib/kurchatov/mixin/http.rb
kurchatov-0.0.3a lib/kurchatov/mixin/http.rb
kurchatov-0.0.2 lib/kurchatov/mixin/http.rb
kurchatov-0.0.2b lib/kurchatov/mixin/http.rb
kurchatov-0.0.1 lib/kurchatov/mixin/http.rb