Sha256: 7e1752c588fc45ed19c34e54e6d7c62fb24c97a38731af2ee16b62501d895749

Contents?: true

Size: 834 Bytes

Versions: 40

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'avm/instances/base'
require 'httpclient'

module EhbrsRubyUtils
  module WebUtils
    class Instance < ::Avm::Instances::Base
      def root_url
        read_entry(:url)
      end

      def resource_url(resource_url_suffix)
        root_url + '/' + resource_url_suffix.gsub(%r{\A/+}, '')
      end

      def http_request(resource_url_suffix, options = {})
        method = options.delete(:method) || 'get'
        url = resource_url(resource_url_suffix)
        http_client.request(method, url, options)
      end

      def http_client_uncached
        client = HTTPClient.new
        client.force_basic_auth = true
        client.set_basic_auth(root_url, read_entry(:admin_username), read_entry(:admin_password))
        client
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
ehbrs_ruby_utils-0.13.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.12.2 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.28.3 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.12.1 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.28.2 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.28.1 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.12.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.28.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.11.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.27.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.10.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.26.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.9.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.8.1 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.25.1 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.8.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.25.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.7.0 lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs-tools-0.24.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb
ehbrs_ruby_utils-0.6.1 lib/ehbrs_ruby_utils/web_utils/instance.rb