source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/os_match.rb | Ruby | mit | 296 | main | 410 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents a match for a specific {OS}.
#
# @since 1.0.0
#
class OSMatch < Struct.new(:name, :accuracy)
#
# Converts the OS match to a String.
#
# @return [String]
# The String form of the OS match.
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/run_stat.rb | Ruby | mit | 296 | main | 445 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents the runstats of a scan.
#
# @since 1.0.0
#
class RunStat < Struct.new(:end_time, :elapsed, :summary, :exit_status)
#
# Converts the stats to a String.
#
# @return [String]
# The String form of ... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/uptime.rb | Ruby | mit | 296 | main | 417 | # frozen_string_literal: true
module Nmap
class XML
#
# Wraps a `uptime` XML element.
#
# @since 1.0.0
#
class Uptime < Struct.new(:seconds, :last_boot)
#
# Converts the uptime object to a String.
#
# @return [String]
# The String form of the Uptime.
#
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/postscript.rb | Ruby | mit | 296 | main | 453 | # frozen_string_literal: true
require_relative 'scripts'
module Nmap
class XML
#
# Represents the `postscript` element.
#
# @since 1.0.0
#
class Postscript
include Scripts
#
# Initializes the Postscript object.
#
# @param [Nokogiri::XML::Node] node
# T... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/port.rb | Ruby | mit | 296 | main | 2,190 | # frozen_string_literal: true
require_relative 'service'
require_relative 'scripts'
module Nmap
class XML
#
# Wraps a `port` XML element.
#
# @since 1.0.0
#
class Port
include Scripts
#
# Creates a new Port object.
#
# @param [Nokogiri::XML::Element] node
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/scan_task.rb | Ruby | mit | 296 | main | 1,201 | # frozen_string_literal: true
module Nmap
class XML
#
# @since 1.0.0
#
class ScanTask < Struct.new(:name, :start_time, :end_time, :extra_info)
#
# Creates a new ScanTask object.
#
# @param [String] name
# The name of the scan task.
#
# @param [Time] start_... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/status.rb | Ruby | mit | 296 | main | 373 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents the Status of a {Host}.
#
# @since 1.0.0
#
class Status < Struct.new(:state, :reason, :reason_ttl)
#
# Converts the status to a String.
#
# @return [String]
# The state.
#
def to_s
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/script.rb | Ruby | mit | 296 | main | 2,547 | # frozen_string_literal: true
module Nmap
class XML
#
# Wraps a `script` XML element.
#
# @since 1.0.0
#
class Script
#
# Initializes a new Script object.
#
# @param [Nokogiri::XML::Node] node
# The XML node that contains the host information.
#
de... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/ip_id_sequence.rb | Ruby | mit | 296 | main | 469 | # frozen_string_literal: true
require_relative 'sequence'
module Nmap
class XML
#
# Represents an IP ID.
#
# @since 1.0.0
#
class IpIdSequence < Sequence
#
# Converts the IpidSequence class to a String.
#
# @return [String]
# The String form of the object.
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/hop.rb | Ruby | mit | 296 | main | 377 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents a hop in a traceroute.
#
# @since 1.0.0
#
class Hop < Struct.new(:addr, :host, :ttl, :rtt)
#
# Converts the hop to a String.
#
# @return [String]
# The IP address of the hop.
#
def ... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/hostname.rb | Ruby | mit | 296 | main | 738 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents a hostname.
#
# @since 1.0.0
#
class Hostname < Struct.new(:type, :name)
#
# Determines if the hostname was specified by the user.
#
# @return [Boolean]
#
# @since 0.8.0
#
def u... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/service.rb | Ruby | mit | 296 | main | 3,400 | # frozen_string_literal: true
require_relative 'cpe'
module Nmap
class XML
#
# Wraps a `service` XML element.
#
# @since 1.0.0
#
class Service
include CPE
#
# Creates a new OS object.
#
# @param [Nokogiri::XML::Node] node
# The node that contains the O... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/prescript.rb | Ruby | mit | 296 | main | 450 | # frozen_string_literal: true
require_relative 'scripts'
module Nmap
class XML
#
# Represents the `prescript` element.
#
# @since 1.0.0
#
class Prescript
include Scripts
#
# Initializes the Prescript object.
#
# @param [Nokogiri::XML::Node] node
# The ... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/sequence.rb | Ruby | mit | 296 | main | 1,058 | # frozen_string_literal: true
module Nmap
class XML
#
# Base class for all Sequence classes.
#
# @since 1.0.0
#
class Sequence
#
# Creates a new sequence object.
#
# @param [Nokogiri::XML::Node] node
# The node that contains the sequence information.
#
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/tcp_sequence.rb | Ruby | mit | 296 | main | 941 | # frozen_string_literal: true
require_relative 'sequence'
module Nmap
class XML
#
# Represents a TCP sequence number.
#
# @since 1.0.0
#
class TcpSequence < Sequence
#
# @return [Numeric]
# The difficulty index from nmap
#
# @since 0.5.0
#
def ind... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/cpe.rb | Ruby | mit | 296 | main | 1,034 | # frozen_string_literal: true
require_relative 'cpe/url'
module Nmap
class XML
#
# Mixins that adds methods for parsing [Common Platform Enumeration
# (CPE)][CPE] information.
#
# [CPE]: http://nmap.org/book/output-formats-cpe.html
#
# @since 1.0.0
#
module CPE
#
# Pa... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/tcp_ts_sequence.rb | Ruby | mit | 296 | main | 478 | # frozen_string_literal: true
require_relative 'sequence'
module Nmap
class XML
#
# Represents a TCP timestamp.
#
# @since 1.0.0
#
class TcpTsSequence < Sequence
#
# Converts the TcpTsSequence class to a String.
#
# @return [String]
# The String form of the o... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/address.rb | Ruby | mit | 296 | main | 721 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents an IP or MAC address and Vendor name.
#
# @since 1.0.0
#
class Address < Struct.new(:type, :addr, :vendor)
#
# Initializes the address.
#
# @param [Symbol] type
# The type of address.
#
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/scan.rb | Ruby | mit | 296 | main | 783 | # frozen_string_literal: true
module Nmap
class XML
#
# Represents an Nmap scan.
#
# @since 1.0.0
#
class Scan < Struct.new(:type, :protocol, :services)
#
# Creates a new Scan object.
#
# @param [Symbol] type
# The type of the scan.
#
# @param [Sym... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/host_script.rb | Ruby | mit | 296 | main | 453 | # frozen_string_literal: true
require_relative 'scripts'
module Nmap
class XML
#
# Represents the `hostscript` element.
#
# @since 1.0.0
#
class HostScript
include Scripts
#
# Initializes the HostScript object.
#
# @param [Nokogiri::XML::Node] node
# T... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/os.rb | Ruby | mit | 296 | main | 2,842 | # frozen_string_literal: true
require_relative 'os_class'
require_relative 'os_match'
module Nmap
class XML
#
# Wraps the `os` XML element.
#
# @since 1.0.0
#
class OS
include Enumerable
#
# Creates a new OS object.
#
# @param [Nokogiri::XML::Node] node
... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/os_class.rb | Ruby | mit | 296 | main | 1,580 | # frozen_string_literal: true
require_relative 'cpe'
module Nmap
class XML
#
# Represents an {OS} class.
#
# @since 1.0.0
#
class OSClass
include CPE
#
# Initializes the OS.
#
# @param [Nokogiri::XML::Node] node
# The node that contains the OS Class in... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/scanner.rb | Ruby | mit | 296 | main | 420 | # frozen_string_literal: true
module Nmap
class XML
#
# Describes the `nmap` command.
#
# @since 1.0.0
#
class Scanner < Struct.new(:name, :version, :arguments, :start_time)
#
# Converts the scanner to a String.
#
# @return [String]
# The scanner name and argu... |
github | postmodern/ruby-nmap | https://github.com/postmodern/ruby-nmap | lib/nmap/xml/cpe/url.rb | Ruby | mit | 296 | main | 1,724 | # frozen_string_literal: true
module Nmap
class XML
module CPE
#
# Represents a [Common Platform Enumeration (CPE)][CPE] URL.
#
# [CPE]: http://nmap.org/book/output-formats-cpe.html
#
# @since 1.0.0
#
class URL < Struct.new(:part,:vendor,:product,:version,:update,:... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | Gemfile | Ruby | mit | 249 | main | 353 | # frozen_string_literal: true
source 'https://rubygems.org'
# Specify your gem's dependencies in duckdb.gemspec
gemspec
gem 'bundler', '~> 4.0'
gem 'csv'
gem 'minitest', '~> 6.0'
gem 'rake', '~> 13.0'
gem 'rake-compiler'
gem 'parallel', '< 2.0'
gem 'rubocop', require: false
gem 'rubocop-minitest', require: false
ge... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | duckdb.gemspec | Ruby | mit | 249 | main | 1,523 | # frozen_string_literal: true
require_relative 'lib/duckdb/version'
Gem::Specification.new do |spec|
spec.name = 'duckdb'
spec.version = DuckDB::VERSION
spec.authors = ['Masaki Suketa']
spec.email = ['masaki.suketa@nifty.ne.jp']
spec.homepage = 'https://github.com/suketa/ru... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | Rakefile | Ruby | mit | 249 | main | 836 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
ruby_memcheck_avaiable = begin
require 'ruby_memcheck'
true
rescue LoadError
false
end
if ruby_memcheck_avaiable
RubyMemcheck.config(
binary_name: 'duckdb/duckdb_native',
valgrind_options: ['--max-threads=1000']
)
end
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | sample/async_query.rb | Ruby | mit | 249 | main | 754 | # frozen_string_literal: true
require 'duckdb'
DuckDB::Database.open do |db|
db.connect do |con|
con.query('SET threads=1')
con.query('CREATE TABLE tbl as SELECT range a, mod(range, 10) b FROM range(10000)')
con.query('CREATE TABLE tbl2 as SELECT range a, mod(range, 10) b FROM range(10000)')
# con.q... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | sample/issue930_benchmark.rb | Ruby | mit | 249 | main | 1,960 | # frozen_string_literal: true
require 'duckdb'
require 'csv'
require 'stringio'
class CSVTableAdapter
def call(csv, name, columns: nil)
columns ||= infer_columns(csv)
DuckDB::TableFunction.create(name:, columns:) do |_func_info, output|
write_row(csv, output)
end
end
private
def write_row(... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | sample/issue930.rb | Ruby | mit | 249 | main | 1,160 | # frozen_string_literal: true
require 'duckdb'
require 'csv'
require 'stringio'
class CSVTableAdapter
def call(csv, name, columns: nil)
columns ||= infer_columns(csv)
DuckDB::TableFunction.create(name:, columns:) do |_func_info, output|
write_row(csv, output)
end
end
private
def write_row(... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | sample/issue922_benchmark.rb | Ruby | mit | 249 | main | 5,456 | # frozen_string_literal: true
# rubocop:disable Style/OneClassPerFile
require 'duckdb'
require 'polars-df'
require 'tmpdir'
class PolarsDataFrameTableAdapter
def call(data_frame, name, columns: nil)
columns ||= infer_columns(data_frame)
DuckDB::TableFunction.create(name:, columns:, &execute_block(data_frame... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | sample/issue922.rb | Ruby | mit | 249 | main | 1,225 | # frozen_string_literal: true
require 'duckdb'
require 'polars-df'
class PolarsDataFrameTableAdapter
def call(data_frame, name, columns: nil)
columns ||= infer_columns(data_frame)
DuckDB::TableFunction.create(name:, columns:, &execute_block(data_frame))
end
private
def execute_block(data_frame)
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | benchmark/appender_ips.rb | Ruby | mit | 249 | main | 5,151 | # frozen_string_literal: true
# Benchmark: append_data_chunk vs row-based append methods
#
# Compares four approaches for bulk-inserting ROWS rows into DuckDB:
#
# 1. append_row - generic dispatch (append) + end_row per row
# 2. append_typed - typed methods (append_int32 / append_varchar) + end_row per r... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | benchmark/get_converter_module_ips.rb | Ruby | mit | 249 | main | 709 | # frozen_string_literal: true
require 'bundler/setup'
require 'duckdb'
require 'benchmark/ips'
db = DuckDB::Database.open
con = db.connect
con.query('CREATE TABLE hugeints (hugeint_val HUGEINT)')
con.query('INSERT INTO hugeints VALUES (1234567890123456789012345678901234)')
result = con.query('SELECT hugeint_val FROM ... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | benchmark/to_intern_ips.rb | Ruby | mit | 249 | main | 1,645 | # frozen_string_literal: true
require 'bundler/setup'
require 'duckdb'
require 'benchmark/ips'
db = DuckDB::Database.open
con = db.connect
con.query(<<~SQL
CREATE TABLE t (
date_value DATE,
time_value TIME,
timestamp_value TIMESTAMP,
interval_value INTERVAL,
hugeint_value HUGEINT,
uuid_value... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | benchmark/converter_hugeint_ips.rb | Ruby | mit | 249 | main | 814 | # frozen_string_literal: true
require 'bundler/setup'
require 'duckdb'
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('hugeint_convert') { DuckDB::Converter._to_hugeint_from_vector(123_456_789, 123_456_789) }
end
__END__
## before
```
✦ ❯ ruby benchmark/converter_hugeint_ips.rb
Warming up -----------------... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb.rb | Ruby | mit | 249 | main | 2,491 | # frozen_string_literal: true
require 'duckdb/duckdb_native'
require 'duckdb/library_version'
require 'duckdb/version'
require 'duckdb/converter'
require 'duckdb/database'
require 'duckdb/connection'
require 'duckdb/extracted_statements'
require 'duckdb/result'
require 'duckdb/prepared_statement'
require 'duckdb/pendi... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/database.rb | Ruby | mit | 249 | main | 3,214 | # frozen_string_literal: true
module DuckDB
# The Database class encapsulates a DuckDB database.
#
# The usage is as follows:
#
# require 'duckdb'
#
# db = DuckDB::Database.open # database in memory
# con = db.connect
#
# con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
#
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/function_type_validation.rb | Ruby | mit | 249 | main | 1,015 | # frozen_string_literal: true
module DuckDB
# Shared type-checking mixin for DuckDB function classes.
# Provides +SUPPORTED_TYPES+ and the private +check_supported_type!+ guard
# used by +ScalarFunction+ and +AggregateFunction+.
module FunctionTypeValidation
SUPPORTED_TYPES = %i[
any
bigint
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/column.rb | Ruby | mit | 249 | main | 639 | # frozen_string_literal: true
module DuckDB
class Column
# returns column type symbol
# `:unknown` means that the column type is unknown/unsupported by ruby-duckdb.
# `:invalid` means that the column type is invalid in duckdb.
#
# require 'duckdb'
# db = DuckDB::Database.open
# con ... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/connection.rb | Ruby | mit | 249 | main | 12,871 | # frozen_string_literal: true
module DuckDB
# The DuckDB::Connection encapsulates connection with DuckDB database.
#
# require 'duckdb'
# db = DuckDB::Database.open
# con = db.connect
# con.query(sql)
class Connection
# executes sql with args.
# The first argument sql must be SQL string.
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/prepared_statement.rb | Ruby | mit | 249 | main | 13,549 | # frozen_string_literal: true
require 'date'
require 'bigdecimal'
require_relative 'converter'
module DuckDB
# The DuckDB::PreparedStatement encapsulates connection with DuckDB prepared
# statement.
#
# require 'duckdb'
# db = DuckDB::Database.open('duckdb_database')
# con = db.connect
# sql ='S... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/data_chunk.rb | Ruby | mit | 249 | main | 4,317 | # frozen_string_literal: true
module DuckDB
#
# The DuckDB::DataChunk represents a chunk of data for table function output.
#
# During table function execution, data chunks are used to return rows.
#
# Example:
#
# done = false
# table_function.init { |_init_info| done = false }
#
# table_f... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/table_description.rb | Ruby | mit | 249 | main | 2,881 | # frozen_string_literal: true
module DuckDB
if defined?(DuckDB::TableDescription)
# DuckDB::TableDescription provides metadata about a table in DuckDB.
#
# Use it to retrieve column descriptions — including name, logical type, and
# whether a column has a default value — for any accessible table.
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/converter.rb | Ruby | mit | 249 | main | 6,431 | # frozen_string_literal: true
require 'date'
require_relative 'interval'
require_relative 'converter/int_to_sym'
module DuckDB
QueryProgress = Struct.new(:percentage, :rows_processed, :total_rows_to_process)
module Converter # :nodoc: all
RANGE_INT8 = -128..127
RANGE_INT16 = -32_768..32_767
RANGE_INT... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/instance_cache.rb | Ruby | mit | 249 | main | 675 | # frozen_string_literal: true
module DuckDB
# The DuckDB::InstanceCache is necessary if a client/program (re)opens
# multiple databases to the same file within the same statement.
#
# require 'duckdb'
# cache = DuckDB::InstanceCache.new
# db1 = cache.get(path: 'db.duckdb')
# db2 = cache.get(path:... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/table_function.rb | Ruby | mit | 249 | main | 6,597 | # frozen_string_literal: true
module DuckDB
#
# The DuckDB::TableFunction encapsulates a DuckDB table function.
#
# NOTE: DuckDB::TableFunction is experimental now.
#
# require 'duckdb'
#
# db = DuckDB::Database.new
# conn = db.connect
#
# # Low-level API:
# tf = DuckDB::TableFunction... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/value.rb | Ruby | mit | 249 | main | 8,925 | # frozen_string_literal: true
require 'bigdecimal'
module DuckDB
class Value
class << self
include DuckDB::Converter
# Creates a new DuckDB::Value with a boolean value.
#
# require 'duckdb'
# value = DuckDB::Value.create_bool(true)
#
# @param value [TrueClass, Fals... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/expression.rb | Ruby | mit | 249 | main | 808 | # frozen_string_literal: true
module DuckDB
# DuckDB::Expression represents a DuckDB expression object.
#
# Instances are returned by DuckDB::ScalarFunction::BindInfo#get_argument
# during the bind phase of a scalar function.
class Expression
# Evaluates the expression at planning time and returns a Duck... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/pending_result.rb | Ruby | mit | 249 | main | 1,655 | # frozen_string_literal: true
module DuckDB
# The DuckDB::PendingResult encapsulates connection with DuckDB pending
# result.
# PendingResult provides methods to execute SQL asynchronousely and check
# if the result is ready and to get the result.
#
# require 'duckdb'
#
# db = DuckDB::Database.open... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/logical_type.rb | Ruby | mit | 249 | main | 10,883 | # frozen_string_literal: true
module DuckDB
class LogicalType # rubocop:disable Metrics/ClassLength
alias :alias get_alias
alias :alias= set_alias
@logical_types = {}
{
boolean: 1,
tinyint: 2,
smallint: 3,
integer: 4,
bigint: 5,
utinyint: 6,
usmallint: 7,
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/config.rb | Ruby | mit | 249 | main | 2,049 | # frozen_string_literal: true
module DuckDB
# The DuckDB::Config encapsulates DuckDB Configuration.
#
# require 'duckdb'
# config = DuckDB::Config.new
# config['default_order'] = 'DESC'
# db = DuckDB::Database.open(nil, config)
# con = db.connect
# con.query('CREATE TABLE numbers (number IN... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/scalar_function.rb | Ruby | mit | 249 | main | 7,925 | # frozen_string_literal: true
module DuckDB
# DuckDB::ScalarFunction encapsulates DuckDB's scalar function
#
# @note DuckDB::ScalarFunction is experimental.
class ScalarFunction
# Create and configure a scalar function in one call
#
# @param name [String, Symbol, nil] the function name; use +nil+ w... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/column_description.rb | Ruby | mit | 249 | main | 1,184 | # frozen_string_literal: true
module DuckDB
if defined?(DuckDB::TableDescription)
# DuckDB::ColumnDescription is an immutable value object describing a single
# column returned by DuckDB::TableDescription#column_descriptions.
#
# It is defined using +Data.define+ and exposes three attributes:
#
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/aggregate_function.rb | Ruby | mit | 249 | main | 10,286 | # frozen_string_literal: true
module DuckDB
# DuckDB::AggregateFunction lets you register a custom aggregate function
# written in Ruby and call it from SQL.
#
# An aggregate function folds many rows into a single value. You define its
# behaviour with four callbacks:
#
# * +set_init+ — called once pe... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/interval.rb | Ruby | mit | 249 | main | 5,641 | # frozen_string_literal: true
module DuckDB
# Interval class represents DuckDB's interval type value.
#
# The usage is as follows:
#
# require 'duckdb'
#
# interval = DuckDB::Interval.new(interval_months: 14, interval_days: 3, interval_micros: 14706123456)
# # or
# # interval = DuckDB::Interv... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/vector.rb | Ruby | mit | 249 | main | 499 | # frozen_string_literal: true
module DuckDB
#
# The DuckDB::Vector represents a column vector in a data chunk.
#
# Vectors store the actual data for table function output.
#
# Example:
#
# vector = output.get_vector(0)
# vector.assign_string_element(0, 'hello')
# vector.assign_string_element(... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/scalar_function_set.rb | Ruby | mit | 249 | main | 1,129 | # frozen_string_literal: true
module DuckDB
# DuckDB::ScalarFunctionSet encapsulates DuckDB's scalar function set,
# which allows registering multiple overloads of a scalar function under one name.
#
# @note DuckDB::ScalarFunctionSet is experimental.
class ScalarFunctionSet
# @param name [String, Symbol]... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/client_context.rb | Ruby | mit | 249 | main | 310 | # frozen_string_literal: true
module DuckDB
# DuckDB::ClientContext represents a DuckDB client context object.
#
# Instances are returned by DuckDB::ScalarFunction::BindInfo#client_context
# during the bind phase of a scalar function.
class ClientContext # rubocop:disable Lint/EmptyClass
end
end |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/result.rb | Ruby | mit | 249 | main | 2,939 | # frozen_string_literal: true
require 'bigdecimal'
module DuckDB
# The Result class encapsulates a execute result of DuckDB database.
#
# The usage is as follows:
#
# require 'duckdb'
#
# db = DuckDB::Database.open # database in memory
# con = db.connect
#
# con.execute('CREATE TABLE users... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/appender.rb | Ruby | mit | 249 | main | 21,550 | # frozen_string_literal: true
require 'date'
require 'time'
require_relative 'converter'
module DuckDB
# The DuckDB::Appender encapsulates DuckDB Appender.
#
# require 'duckdb'
# db = DuckDB::Database.open
# con = db.connect
# con.query('CREATE TABLE users (id INTEGER, name VARCHAR)')
# append... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/casting.rb | Ruby | mit | 249 | main | 762 | # frozen_string_literal: true
module DuckDB
module Casting
def cast(value, type) # rubocop:disable Metrics/MethodLength
type = type.type if type.is_a?(DuckDB::LogicalType)
case type
when :integer, :bigint, :hugeint
Integer(value)
when :float, :double
Float(value)
whe... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/library_version.rb | Ruby | mit | 249 | main | 220 | # frozen_string_literal: true
module DuckDB
# represents the version of the DuckDB library.
# If DuckDB.library_version is v0.2.0, then DuckDB::LIBRARY_VERSION is 0.2.0.
LIBRARY_VERSION = library_version[1..]
end |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/extracted_statements.rb | Ruby | mit | 249 | main | 350 | # frozen_string_literal: true
module DuckDB
class ExtractedStatements
include Enumerable
def initialize(con, sql)
@con = con
_initialize(con, sql)
end
def each
return to_enum(__method__) { size } unless block_given?
size.times do |i|
yield prepared_statement(@con, i... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/scalar_function/bind_info.rb | Ruby | mit | 249 | main | 1,030 | # frozen_string_literal: true
module DuckDB
class ScalarFunction
# DuckDB::ScalarFunction::BindInfo encapsulates the bind phase of a scalar function.
#
# An instance is passed to the block given to ScalarFunction#set_bind.
# The bind phase runs once at query planning time (before execution).
#
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/table_function/bind_info.rb | Ruby | mit | 249 | main | 982 | # frozen_string_literal: true
module DuckDB
class TableFunction
#
# The DuckDB::TableFunction::BindInfo encapsulates information for the bind phase of table functions.
#
# During the bind phase, you can:
# - Access parameters passed to the function
# - Define the output schema (columns)
#... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/table_function/init_info.rb | Ruby | mit | 249 | main | 678 | # frozen_string_literal: true
module DuckDB
class TableFunction
#
# The DuckDB::TableFunction::InitInfo provides context during table function initialization.
#
# It is passed to the init callback to set up execution state.
#
# Example:
#
# table_function.init do |init_info|
# ... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/table_function/function_info.rb | Ruby | mit | 249 | main | 654 | # frozen_string_literal: true
module DuckDB
class TableFunction
#
# The DuckDB::TableFunction::FunctionInfo provides context during table function execution.
#
# It is passed to the execute callback along with the output DataChunk.
#
# Example:
#
# table_function.execute do |func_in... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | lib/duckdb/converter/int_to_sym.rb | Ruby | mit | 249 | main | 1,920 | # frozen_string_literal: true
module DuckDB
module Converter
module IntToSym # :nodoc: all
STATEMENT_TYPES = %i[
invalid
select
insert
update
explain
delete
prepare
create
execute
alter
transaction
copy
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/test_helper.rb | Ruby | mit | 249 | main | 393 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'duckdb'
require_relative 'duckdb_test/duckdb_version'
GC.verify_compaction_references(expand_heap: true, toward: :empty)
module DuckDBTest
def duckdb_library_version
Gem::Version.new(DuckDB::LIBRARY_VERSION)
end
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test.rb | Ruby | mit | 249 | main | 440 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class DuckDBTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::DuckDB::VERSION
end
def test_that_it_has_a_library_version_number
refute_nil ::DuckDB::LIBRARY_VERSION
end
def test_vector_size... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/table_description_test.rb | Ruby | mit | 249 | main | 2,898 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
if defined?(DuckDB::TableDescription)
class TableDescriptionTest < Minitest::Test # rubocop:disable Layout/IndentationWidth
def setup
@db = DuckDB::Database.open
@con = @db.connect
@con.query('CREATE TABLE t (i INTEGER, j ... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_each_test.rb | Ruby | mit | 249 | main | 19,732 | # frozen_string_literal: true
require 'test_helper'
require 'securerandom'
require 'time'
module DuckDBTest
class ResultEach < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def teardown
@db.close
end
UUID = SecureRandom.uuid
ENUM_SQL = "CREAT... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/connection_test.rb | Ruby | mit | 249 | main | 16,145 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ConnectionTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def test_query
assert_instance_of(DuckDB::Result, @con.query('CREATE TABLE table1 (id INTEGER)'))
end
def t... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/table_function_csv_test.rb | Ruby | mit | 249 | main | 2,358 | # frozen_string_literal: true
require 'test_helper'
require 'csv'
require 'stringio'
module DuckDBTest
class TableFunctionCSVTest < Minitest::Test
class CSVTableAdapter
def initialize(columns: nil)
@columns = columns
end
def call(csv, name, columns: nil)
columns ||= @columns
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/casting_test.rb | Ruby | mit | 249 | main | 2,258 | # frozen_string_literal: true
require 'test_helper'
require 'date'
module DuckDBTest
class CastingTest < Minitest::Test
def test_cast_integer
assert_equal(2_147_483_647, DuckDB.cast('2147483647', :integer))
assert_equal(2_147_483_647, DuckDB.cast(2_147_483_647, :integer))
end
def test_cast_... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_bit_test.rb | Ruby | mit | 249 | main | 1,785 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultBitTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.execute('DROP TABLE test;')
@conn.close
@db.close
end
def test_result_bit
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/interval_test.rb | Ruby | mit | 249 | main | 5,552 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class IntervalTest < Minitest::Test
def test_s_iso8601_parse_positive_full
assert_equal(
DuckDB::Interval.new(interval_months: 14, interval_days: 3, interval_micros: 14_706_700_000),
DuckDB::Interval.iso8601_parse('P1Y2M... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/database_new_test.rb | Ruby | mit | 249 | main | 2,508 | # frozen_string_literal: true
require 'securerandom'
require 'test_helper'
module DuckDBTest
class DatabaseNewTest < Minitest::Test
def setup
@path = "#{Time.now.strftime('%Y%m%d%H%M%S')}-#{Process.pid}-#{SecureRandom.hex(8)}"
end
def teardown
FileUtils.rm_f(@path)
FileUtils.rm_f("#{@... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/pending_result_test.rb | Ruby | mit | 249 | main | 2,653 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class PendingResultTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
# @con.query('CREATE TABLE int_vals (int_val INTEGER)')
# @con.query('INSERT INTO int_vals VALUES (1), (2), (3), (4), (5... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_test.rb | Ruby | mit | 249 | main | 7,798 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultTest < Minitest::Test
def setup
@con = create_data
@result = @con.query('SELECT * from table1')
# fix for using duckdb_fetch_chunk in Result#chunk_each
@all_records = @result.to_a
@ary = first_recor... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/gc_stress_test.rb | Ruby | mit | 249 | main | 4,974 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
# Tests for GC stress and compaction safety
class GCStressTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def teardown
@con&.close
@db&.close
end
def test_multiple... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/database_test.rb | Ruby | mit | 249 | main | 4,611 | # frozen_string_literal: true
require 'test_helper'
require 'tempfile'
require 'securerandom'
module DuckDBTest
class DatabaseTest < Minitest::Test
def setup
@path = create_path
end
def teardown
@con&.close
@db&.close
FileUtils.rm_f(@path)
walf = "#{@path}.wal"
File... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/expression_test.rb | Ruby | mit | 249 | main | 11,053 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ExpressionTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.disconnect
@db.close
end
# --- foldable? ---
# Expression#foldable? returns t... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_timestamp_default_timezone_test.rb | Ruby | mit | 249 | main | 3,514 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultTimestampDefaultTimezoneTest < Minitest::Test
def setup
@original_tz = ENV.fetch('TZ', nil)
@original_default_timezone = DuckDB.default_timezone
@db = DuckDB::Database.open
@conn = @db.connect
ENV['TZ... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_list_test.rb | Ruby | mit | 249 | main | 2,397 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultListTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.execute('DROP TABLE test;')
@conn.close
@db.close
end
def test_result_list
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/table_function_test.rb | Ruby | mit | 249 | main | 5,683 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class TableFunctionTest < Minitest::Test
# Test 1: Create using new
def test_new
tf = DuckDB::TableFunction.new
assert_instance_of DuckDB::TableFunction, tf
end
# Test: Create function with set_value (high-level API)... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_map_test.rb | Ruby | mit | 249 | main | 1,654 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultMapTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.execute('DROP TABLE test;')
@conn.close
@db.close
end
def test_result_map
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/duckdb_version.rb | Ruby | mit | 249 | main | 736 | # frozen_string_literal: true
module DuckDBTest
class DuckDBVersion
include Comparable
def self.duckdb_version
return @duckdb_version if @duckdb_version
DuckDB::Database.open('version.duckdb') do |db|
db.connect do |con|
r = con.query('SELECT VERSION();')
@duckdb_ver... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_timestamp_ns_test.rb | Ruby | mit | 249 | main | 657 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultTimestampNsTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.execute('DROP TABLE test;')
@conn.close
@db.close
end
def test_resul... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/bind_hugeint_internal_test.rb | Ruby | mit | 249 | main | 1,679 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class DuckDBBindHugeintInternalTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
@con.query('CREATE TABLE hugeints (hugeint_value HUGEINT)')
end
def prepare_test_value(value)
@con.... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/data_chunk_test.rb | Ruby | mit | 249 | main | 15,744 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class DataChunkTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.disconnect
@db.close
end
# Test 1: DataChunk API exists (actual testing deferred t... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/prepared_statement_bind_value_test.rb | Ruby | mit | 249 | main | 3,166 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class PreparedStatementBindValueTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def teardown
@con&.close
@db&.close
end
def test_bind_value_with_string_raises_argume... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/value_test.rb | Ruby | mit | 249 | main | 22,994 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ValueTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def teardown
@con&.close
@db&.close
end
def test_create_bool_with_true
value = DuckDB::Value.create_... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/column_description_test.rb | Ruby | mit | 249 | main | 1,208 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
if defined?(DuckDB::TableDescription)
class ColumnDescriptionTest < Minitest::Test # rubocop:disable Layout/IndentationWidth
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def teardown
@con&.close
... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_struct_test.rb | Ruby | mit | 249 | main | 1,871 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultStructTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.execute('DROP TABLE test;')
@conn.close
@db.close
end
def test_result_str... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/aggregate_function_test.rb | Ruby | mit | 249 | main | 17,258 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class AggregateFunctionTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@con = @db.connect
end
def teardown
@con&.close
@db&.close
end
def test_s_create
af = DuckDB::AggregateFunction... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/result_array_test.rb | Ruby | mit | 249 | main | 1,598 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class ResultArrayTest < Minitest::Test
def setup
@db = DuckDB::Database.open
@conn = @db.connect
end
def teardown
@conn.execute('DROP TABLE test;')
@conn.close
@db.close
end
def test_result_arra... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/column_test.rb | Ruby | mit | 249 | main | 3,295 | # frozen_string_literal: true
require 'test_helper'
require 'securerandom'
module DuckDBTest
class ColumnTest < Minitest::Test
CREATE_TYPE_ENUM_SQL = <<~SQL
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy', '𝘾𝝾օɭ 😎');
SQL
CREATE_TABLE_SQL = <<~SQL
CREATE TABLE table1(
boolean_col B... |
github | suketa/ruby-duckdb | https://github.com/suketa/ruby-duckdb | test/duckdb_test/table_function_integration_test.rb | Ruby | mit | 249 | main | 7,011 | # frozen_string_literal: true
require 'test_helper'
module DuckDBTest
class TableFunctionIntegrationTest < Minitest::Test
def setup
@database = DuckDB::Database.open
@connection = @database.connect
end
def teardown
@connection.disconnect
@database.close
end
# Test 1: Si... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.