Sha256: 749d62270576c93dbc3b66b141b96e2f913fffbddfe0203c3e9858b8c28acdfa

Contents?: true

Size: 685 Bytes

Versions: 4

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

require_relative 'query_builder'

module RSpec
  module Hive
    module QueryBuilderHelper
      HiveConnectionNotFound = Class.new(StandardError)

      def into_hive(schema)
        hive_connection_guard!
        ::RSpec::Hive::QueryBuilder.new(schema, connection)
      end

      private

      def hive_connection_present?
        respond_to?(:connection) &&
          (connection.is_a?(RBHive::TCLIConnection) ||
            connection.is_a?(RSpec::Hive::ConnectionDelegator))
      end

      def hive_connection_guard!
        raise HiveConnectionNotFound, 'Include WithHiveConnection' unless hive_connection_present?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-hive-0.6.3 lib/rspec/hive/query_builder_helper.rb
rspec-hive-0.6.2 lib/rspec/hive/query_builder_helper.rb
rspec-hive-0.6.1 lib/rspec/hive/query_builder_helper.rb
rspec-hive-0.6.0 lib/rspec/hive/query_builder_helper.rb