repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/forecasting_test.rb | test/forecasting_test.rb | require_relative "test_helper"
class ForecastingTest < ActionDispatch::IntegrationTest
def setup
Blazer::Query.delete_all
end
def test_prophet
skip unless ENV["TEST_PROPHET"]
assert_forecast("prophet")
end
def test_trend
skip unless ENV["TEST_TREND"]
assert_forecast("trend")
end
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/queries_test.rb | test/queries_test.rb | require_relative "test_helper"
class QueriesTest < ActionDispatch::IntegrationTest
def setup
Blazer::Audit.delete_all
Blazer::Query.delete_all
end
def test_index
get blazer.root_path
assert_response :success
end
def test_create
post blazer.queries_path, params: {query: {name: "Test", st... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/checks_test.rb | test/checks_test.rb | require_relative "test_helper"
class ChecksTest < ActionDispatch::IntegrationTest
def setup
Blazer::Check.delete_all
Blazer::Query.delete_all
end
def test_index
get blazer.checks_path
assert_response :success
end
def test_bad_data
query = create_query
check = create_check(query: que... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/test_helper.rb | test/test_helper.rb | require "bundler/setup"
require "combustion"
Bundler.require(:default)
require "minitest/autorun"
logger = ActiveSupport::Logger.new(ENV["VERBOSE"] ? STDERR : nil)
Combustion.path = "test/internal"
Combustion.initialize! :active_record, :action_controller, :action_mailer, :active_job do
config.load_defaults Rails::... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/cohort_analysis_test.rb | test/cohort_analysis_test.rb | require_relative "test_helper"
class CohortAnalysisTest < ActionDispatch::IntegrationTest
def test_works
run_query "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */", query_id: 1
assert_match "1 cohort", response.body
end
def test_cohort_time
run_query "SELECT 1 AS user_id, NOW() ... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/charts_test.rb | test/charts_test.rb | require_relative "test_helper"
class ChartsTest < ActionDispatch::IntegrationTest
def test_line_chart_format1
run_query "SELECT NOW(), 1"
assert_match "LineChart", response.body
end
def test_line_chart_format2
run_query "SELECT NOW(), 'Label', 1"
assert_match "LineChart", response.body
end
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/archive_test.rb | test/archive_test.rb | require_relative "test_helper"
class ArchiveTest < ActionDispatch::IntegrationTest
def setup
Blazer::Audit.delete_all
Blazer::Query.delete_all
end
def test_archive_queries
query = create_query
query2 = create_query
query2.audits.create!
Blazer.archive_queries
query.reload
asser... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/dashboards_test.rb | test/dashboards_test.rb | require_relative "test_helper"
class DashboardsTest < ActionDispatch::IntegrationTest
def setup
Blazer::Query.delete_all
Blazer::Dashboard.delete_all
end
def test_new
get blazer.new_dashboard_path
assert_response :success
end
def test_show
dashboard = create_dashboard
get blazer.das... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/uploads_test.rb | test/uploads_test.rb | require_relative "test_helper"
class UploadsTest < ActionDispatch::IntegrationTest
def setup
skip unless postgresql?
Blazer::Upload.delete_all
Blazer::UploadsConnection.connection.execute("DROP SCHEMA IF EXISTS uploads CASCADE")
Blazer::UploadsConnection.connection.execute("CREATE SCHEMA uploads")
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/anomaly_checks_test.rb | test/anomaly_checks_test.rb | require_relative "test_helper"
class AnomalyChecksTest < ActionDispatch::IntegrationTest
def setup
Blazer::Check.delete_all
Blazer::Query.delete_all
end
def test_prophet
skip unless ENV["TEST_PROPHET"]
assert_anomaly("prophet")
end
def test_trend
skip unless ENV["TEST_TREND"]
asse... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/maps_test.rb | test/maps_test.rb | require_relative "test_helper"
class MapsTest < ActionDispatch::IntegrationTest
def test_latitude_longitude
run_query "SELECT 1.2 AS latitude, 3.4 AS longitude"
assert_match "Map", response.body
end
def test_lat_lon
run_query "SELECT 1.2 AS lat, 3.4 AS lon"
assert_match "Map", response.body
en... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/cache_test.rb | test/cache_test.rb | require_relative "test_helper"
class CacheTest < ActionDispatch::IntegrationTest
def setup
Rails.cache.clear
end
def test_all
with_caching({"mode" => "all"}) do
run_query "SELECT 1"
refute_match "Cached", response.body
run_query "SELECT 1"
assert_match "Cached", response.body
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/permissions_test.rb | test/permissions_test.rb | require_relative "test_helper"
class PermissionsTest < ActionDispatch::IntegrationTest
def setup
Blazer::Query.delete_all
User.delete_all
end
def test_list
with_new_user do |user|
create_query(name: "# Test", creator: user)
get blazer.root_path
assert_response :success
assert... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/support/adapter_test.rb | test/support/adapter_test.rb | module AdapterTest
def setup
settings = YAML.load_file("test/support/adapters.yml")
Blazer.instance_variable_set(:@settings, settings)
end
# some adapter tests override this method
def test_tables
assert_kind_of Array, tables
end
def test_schema
get blazer.schema_queries_path(data_source: ... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/internal/app/controllers/application_controller.rb | test/internal/app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
def current_user
User.last
end
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/internal/app/models/user.rb | test/internal/app/models/user.rb | class User < ActiveRecord::Base
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/internal/db/schema.rb | test/internal/db/schema.rb | ActiveRecord::Schema.define do
create_table :blazer_queries do |t|
t.references :creator
t.string :name
t.text :description
t.text :statement
t.string :data_source
t.string :status
t.timestamps null: false
end
create_table :blazer_audits do |t|
t.references :user
t.references ... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/internal/config/routes.rb | test/internal/config/routes.rb | Rails.application.routes.draw do
mount Blazer::Engine, at: "/"
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/opensearch_test.rb | test/adapters/opensearch_test.rb | require_relative "../test_helper"
class OpensearchTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"opensearch"
end
def test_run
assert_result [{"'world'" => "world"}], "SELECT 'world' AS hello"
end
def test_single_quote
assert_error "Quoting not specified", "SELECT... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/snowflake_test.rb | test/adapters/snowflake_test.rb | require_relative "../test_helper"
class SnowflakeTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"snowflake"
end
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/druid_test.rb | test/adapters/druid_test.rb | require_relative "../test_helper"
class DruidTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"druid"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT ? AS hello\n\n[\"world\"]", "SELECT {var} A... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/postgresql_test.rb | test/adapters/postgresql_test.rb | require_relative "../test_helper"
class PostgresqlTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"postgresql"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT $1 AS hello\n\n[\"world\"]", "SEL... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/spark_test.rb | test/adapters/spark_test.rb | require_relative "../test_helper"
# bin/beeline -u jdbc:hive2://localhost:10000 -e 'CREATE DATABASE blazer_test;'
class SparkTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"spark"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
de... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/elasticsearch_test.rb | test/adapters/elasticsearch_test.rb | require_relative "../test_helper"
class ElasticsearchTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"elasticsearch"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT ? AS hello\n\n[\"world\"]",... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/hive_test.rb | test/adapters/hive_test.rb | require_relative "../test_helper"
# bin/beeline -u jdbc:hive2://localhost:10000 -e 'CREATE DATABASE blazer_test;'
class HiveTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"hive"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def ... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/sqlserver_test.rb | test/adapters/sqlserver_test.rb | require_relative "../test_helper"
# brew install freetds
# docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=YourStrong!Passw0rd' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
# docker exec -it <container-id> /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P YourStrong\!Passw0rd -Q "CREATE DATABASE blazer_tes... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/soda_test.rb | test/adapters/soda_test.rb | require_relative "../test_helper"
class SodaTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"soda"
end
def test_tables
assert_equal ["all"], tables
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello LIMIT 1"
end
def test_single_quo... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/salesforce_test.rb | test/adapters/salesforce_test.rb | require_relative "../test_helper"
# https://stackoverflow.com/questions/12794302/salesforce-authentication-failing/29112224#29112224
# create accounts named world, ', ", and \
# ENV["SALESFORCE_USERNAME"] = "username"
# ENV["SALESFORCE_PASSWORD"] = "password"
# ENV["SALESFORCE_SECURITY_TOKEN"] = "security token"
# EN... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/athena_test.rb | test/adapters/athena_test.rb | require_relative "../test_helper"
class AthenaTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"athena"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
if engine_version > 1
assert_audit "SELECT ? AS hello\n\... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/drill_test.rb | test/adapters/drill_test.rb | require_relative "../test_helper"
class DrillTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"drill"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT 'world' AS hello", "SELECT {var} AS hello",... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/bigquery_test.rb | test/adapters/bigquery_test.rb | require_relative "../test_helper"
class BigqueryTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"bigquery"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT ? AS hello\n\n[\"world\"]", "SELECT {... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/sqlite_test.rb | test/adapters/sqlite_test.rb | require_relative "../test_helper"
class SqliteTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"sqlite"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT $1 AS hello\n\n[\"world\"]", "SELECT {var... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/mysql_test.rb | test/adapters/mysql_test.rb | require_relative "../test_helper"
class MysqlTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
ENV["MYSQL_ADAPTER"] || "mysql2"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
if prepared_statements?
assert_au... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/ignite_test.rb | test/adapters/ignite_test.rb | require_relative "../test_helper"
class IgniteTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"ignite"
end
def test_run
assert_result [{"HELLO" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT ? AS hello\n\n[\"world\"]", "SELECT {var}... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/redshift_test.rb | test/adapters/redshift_test.rb | require_relative "../test_helper"
class RedshiftTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"redshift"
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
assert_audit "SELECT 'world' AS hello", "SELECT {var} AS h... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/cassandra_test.rb | test/adapters/cassandra_test.rb | require_relative "../test_helper"
class CassandraTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"cassandra"
end
def setup
@@once ||= begin
require "cassandra"
cluster = Cassandra.cluster(hosts: ["localhost"])
session = cluster.connect("system")
ses... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/presto_test.rb | test/adapters/presto_test.rb | require_relative "../test_helper"
class PrestoTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"presto"
end
def test_tables
# needs different connector
end
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
def test_audit
asser... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/neo4j_test.rb | test/adapters/neo4j_test.rb | require_relative "../test_helper"
class Neo4jTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"neo4j"
end
def test_run
assert_result [{"hello" => "world"}], "OPTIONAL MATCH () RETURN 'world' AS `hello`"
end
def test_audit
assert_audit "OPTIONAL MATCH () RETURN $var ... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/test/adapters/influxdb_test.rb | test/adapters/influxdb_test.rb | require_relative "../test_helper"
class InfluxdbTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"influxdb"
end
def setup
@@once ||= begin
client = InfluxDB::Client.new(url: "http://localhost:8086/blazer_test")
client.delete_series("items")
client.write_poi... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer.rb | lib/blazer.rb | # dependencies
require "chartkick"
require "safely/core"
# stdlib
require "csv"
require "digest/sha2"
require "json"
require "yaml"
# modules
require_relative "blazer/version"
require_relative "blazer/data_source"
require_relative "blazer/result"
require_relative "blazer/result_cache"
require_relative "blazer/run_sta... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/generators/blazer/install_generator.rb | lib/generators/blazer/install_generator.rb | require "rails/generators/active_record"
module Blazer
module Generators
class InstallGenerator < Rails::Generators::Base
include ActiveRecord::Generators::Migration
source_root File.join(__dir__, "templates")
def copy_migration
migration_template "install.rb", "db/migrate/install_blaz... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/generators/blazer/uploads_generator.rb | lib/generators/blazer/uploads_generator.rb | require "rails/generators/active_record"
module Blazer
module Generators
class UploadsGenerator < Rails::Generators::Base
include ActiveRecord::Generators::Migration
source_root File.join(__dir__, "templates")
def copy_migration
migration_template "uploads.rb", "db/migrate/create_blaze... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/run_statement_job.rb | lib/blazer/run_statement_job.rb | module Blazer
class RunStatementJob < ActiveJob::Base
self.queue_adapter = :async
def perform(data_source_id, statement, options)
statement = Blazer::Statement.new(statement, data_source_id)
statement.values = options.delete(:values)
data_source = statement.data_source
begin
A... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/version.rb | lib/blazer/version.rb | module Blazer
VERSION = "3.3.0"
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/slack_notifier.rb | lib/blazer/slack_notifier.rb | require "net/http"
module Blazer
class SlackNotifier
def self.state_change(check, state, state_was, rows_count, error, check_type)
check.split_slack_channels.each do |channel|
text =
if error
error
elsif rows_count > 0 && check_type == "bad_data"
pluraliz... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/check_mailer.rb | lib/blazer/check_mailer.rb | module Blazer
class CheckMailer < ActionMailer::Base
include ActionView::Helpers::TextHelper
default from: Blazer.from_email if Blazer.from_email
layout false
def state_change(check, state, state_was, rows_count, error, columns, rows, column_types, check_type)
@check = check
@state = sta... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/data_source.rb | lib/blazer/data_source.rb | module Blazer
class DataSource
extend Forwardable
attr_reader :id, :settings
def_delegators :adapter_instance, :schema, :tables, :preview_statement, :reconnect, :cost, :explain, :cancel, :supports_cohort_analysis?, :cohort_analysis_statement
def initialize(id, settings)
@id = id
@settin... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/run_statement.rb | lib/blazer/run_statement.rb | module Blazer
class RunStatement
def perform(statement, options = {})
query = options[:query]
data_source = statement.data_source
statement.bind
# audit
if Blazer.audit
audit_statement = statement.bind_statement
audit_statement += "\n\n#{statement.bind_values.to_jso... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/anomaly_detectors.rb | lib/blazer/anomaly_detectors.rb | Blazer.register_anomaly_detector "anomaly_detection" do |series|
anomalies = AnomalyDetection.detect(series.to_h, period: :auto)
anomalies.include?(series.last[0])
end
Blazer.register_anomaly_detector "prophet" do |series|
df = Rover::DataFrame.new(series[0..-2].map { |v| {"ds" => v[0], "y" => v[1]} })
m = Pro... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/result.rb | lib/blazer/result.rb | module Blazer
class Result
attr_reader :data_source, :columns, :rows, :error, :forecast_error
attr_accessor :cached_at, :just_cached
def initialize(data_source, columns, rows, error, cached_at, just_cached)
@data_source = data_source
@columns = columns.dup
@rows = rows
@error = er... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/statement.rb | lib/blazer/statement.rb | module Blazer
class Statement
attr_reader :statement, :data_source, :bind_statement, :bind_values
attr_accessor :values
def initialize(statement, data_source = nil)
@statement = statement
@data_source = data_source.is_a?(String) ? Blazer.data_sources[data_source] : data_source
@values =... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/forecasters.rb | lib/blazer/forecasters.rb | Blazer.register_forecaster "prophet" do |series, count:|
Prophet.forecast(series, count: count)
end
Blazer.register_forecaster "trend" do |series, count:|
Trend.forecast(series, count: count)
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/engine.rb | lib/blazer/engine.rb | module Blazer
class Engine < ::Rails::Engine
isolate_namespace Blazer
initializer "blazer" do |app|
if app.config.respond_to?(:assets) && defined?(Sprockets)
if Sprockets::VERSION.to_i >= 4
app.config.assets.precompile += [
"blazer/application.js",
"blazer/appl... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/result_cache.rb | lib/blazer/result_cache.rb | module Blazer
class ResultCache
def initialize(data_source)
@data_source = data_source
end
def write_run(run_id, result)
write(run_cache_key(run_id), result, expires_in: 30.seconds)
end
def read_run(run_id)
read(run_cache_key(run_id))
end
def delete_run(run_id)
d... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters.rb | lib/blazer/adapters.rb | Blazer.register_adapter "athena", Blazer::Adapters::AthenaAdapter
Blazer.register_adapter "bigquery", Blazer::Adapters::BigQueryAdapter
Blazer.register_adapter "cassandra", Blazer::Adapters::CassandraAdapter
Blazer.register_adapter "drill", Blazer::Adapters::DrillAdapter
Blazer.register_adapter "druid", Blazer::Adapter... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/elasticsearch_adapter.rb | lib/blazer/adapters/elasticsearch_adapter.rb | module Blazer
module Adapters
class ElasticsearchAdapter < BaseAdapter
def run_statement(statement, comment, bind_params)
columns = []
rows = []
error = nil
begin
response = client.transport.perform_request("POST", endpoint, {}, {query: "#{statement} /*#{comment}*/... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/athena_adapter.rb | lib/blazer/adapters/athena_adapter.rb | module Blazer
module Adapters
class AthenaAdapter < BaseAdapter
def run_statement(statement, comment, bind_params = [])
require "digest/md5"
columns = []
rows = []
error = nil
begin
# use empty? since any? doesn't work for [nil]
if !bind_params.e... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/bigquery_adapter.rb | lib/blazer/adapters/bigquery_adapter.rb | module Blazer
module Adapters
class BigQueryAdapter < BaseAdapter
def run_statement(statement, comment, bind_params)
columns = []
rows = []
error = nil
begin
results = bigquery.query(statement, params: bind_params)
# complete? was removed in google-cloud... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/spark_adapter.rb | lib/blazer/adapters/spark_adapter.rb | module Blazer
module Adapters
class SparkAdapter < HiveAdapter
def tables
client.execute("SHOW TABLES").map { |r| r["tableName"] }
end
# https://spark.apache.org/docs/latest/sql-ref-literals.html
def quoting
:backslash_escape
end
end
end
end
| ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/base_adapter.rb | lib/blazer/adapters/base_adapter.rb | module Blazer
module Adapters
class BaseAdapter
attr_reader :data_source
def initialize(data_source)
@data_source = data_source
end
def run_statement(statement, comment)
# required
end
def quoting
# required, how to quote variables
# :backslas... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/soda_adapter.rb | lib/blazer/adapters/soda_adapter.rb | module Blazer
module Adapters
class SodaAdapter < BaseAdapter
def run_statement(statement, comment)
require "json"
require "net/http"
require "uri"
columns = []
rows = []
error = nil
# remove comments manually
statement = statement.gsub(/--.+... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/drill_adapter.rb | lib/blazer/adapters/drill_adapter.rb | module Blazer
module Adapters
class DrillAdapter < BaseAdapter
def run_statement(statement, comment)
columns = []
rows = []
error = nil
begin
# remove trailing semicolon
response = drill.query(statement.sub(/;\s*\z/, ""))
rows = response.map { |... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/presto_adapter.rb | lib/blazer/adapters/presto_adapter.rb | module Blazer
module Adapters
class PrestoAdapter < BaseAdapter
def run_statement(statement, comment)
columns = []
rows = []
error = nil
begin
columns, rows = client.run("#{statement} /*#{comment}*/")
columns = columns.map(&:name)
rescue => e
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/salesforce_adapter.rb | lib/blazer/adapters/salesforce_adapter.rb | module Blazer
module Adapters
class SalesforceAdapter < BaseAdapter
def run_statement(statement, comment)
columns = []
rows = []
error = nil
# remove comments manually
statement = statement.gsub(/--.+/, "")
# only supports single line /* */ comments
#... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/ignite_adapter.rb | lib/blazer/adapters/ignite_adapter.rb | module Blazer
module Adapters
class IgniteAdapter < BaseAdapter
def run_statement(statement, comment, bind_params)
columns = []
rows = []
error = nil
begin
result = client.query("#{statement} /*#{comment}*/", bind_params, schema: default_schema, statement_type: :se... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/hive_adapter.rb | lib/blazer/adapters/hive_adapter.rb | module Blazer
module Adapters
class HiveAdapter < BaseAdapter
def run_statement(statement, comment)
columns = []
rows = []
error = nil
begin
result = client.execute("#{statement} /*#{comment}*/")
columns = result.any? ? result.first.keys : []
ro... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/neo4j_adapter.rb | lib/blazer/adapters/neo4j_adapter.rb | module Blazer
module Adapters
class Neo4jAdapter < BaseAdapter
def run_statement(statement, comment, bind_params)
columns = []
rows = []
error = nil
begin
if bolt?
result = session.run("#{statement} /*#{comment}*/", bind_params).to_a
columns... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/cassandra_adapter.rb | lib/blazer/adapters/cassandra_adapter.rb | module Blazer
module Adapters
class CassandraAdapter < BaseAdapter
def run_statement(statement, comment, bind_params)
columns = []
rows = []
error = nil
begin
response = session.execute("#{statement} /*#{comment}*/", arguments: bind_params)
rows = respons... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/druid_adapter.rb | lib/blazer/adapters/druid_adapter.rb | module Blazer
module Adapters
class DruidAdapter < BaseAdapter
TIMESTAMP_REGEX = /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\z/
def run_statement(statement, comment, bind_params)
require "json"
require "net/http"
require "uri"
columns = []
rows = []
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/influxdb_adapter.rb | lib/blazer/adapters/influxdb_adapter.rb | module Blazer
module Adapters
class InfluxdbAdapter < BaseAdapter
def run_statement(statement, comment)
columns = []
rows = []
error = nil
begin
result = client.query(statement, denormalize: false).first
if result
columns = result["columns"]
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/opensearch_adapter.rb | lib/blazer/adapters/opensearch_adapter.rb | module Blazer
module Adapters
class OpensearchAdapter < BaseAdapter
def run_statement(statement, comment)
columns = []
rows = []
error = nil
begin
response = client.transport.perform_request("POST", "_plugins/_sql", {}, {query: "#{statement} /*#{comment}*/"}).body
... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/sql_adapter.rb | lib/blazer/adapters/sql_adapter.rb | module Blazer
module Adapters
class SqlAdapter < BaseAdapter
attr_reader :connection_model
def initialize(data_source)
super
@connection_model =
Class.new(Blazer::Connection) do
def self.name
"Blazer::Connection::Adapter#{object_id}"
en... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/lib/blazer/adapters/snowflake_adapter.rb | lib/blazer/adapters/snowflake_adapter.rb | module Blazer
module Adapters
class SnowflakeAdapter < SqlAdapter
def initialize(data_source)
@data_source = data_source
@@registered ||= begin
require "active_record/connection_adapters/odbc_adapter"
require "odbc_adapter/adapters/postgresql_odbc_adapter"
ODB... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
ankane/blazer | https://github.com/ankane/blazer/blob/e5515ecca17ed2f2d3f87347147549353983f24b/config/routes.rb | config/routes.rb | Blazer::Engine.routes.draw do
resources :queries do
post :run, on: :collection # err on the side of caution
post :cancel, on: :collection
post :refresh, on: :member
get :tables, on: :collection
get :schema, on: :collection
get :docs, on: :collection
end
resources :checks, except: [:show] ... | ruby | MIT | e5515ecca17ed2f2d3f87347147549353983f24b | 2026-01-04T15:45:43.211083Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/youplot_test.rb | test/youplot_test.rb | # frozen_string_literal: true
require_relative 'test_helper'
class YouPlotTest < Test::Unit::TestCase
def teardown
YouPlot.run_as_executable = false
end
test :it_has_a_version_number do
assert_kind_of String, ::YouPlot::VERSION
end
test :run_as_executable do
assert_equal false, YouPlot.run_as_... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/test_helper.rb | test/test_helper.rb | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start
require 'youplot'
require 'test/unit'
| ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/unicode_plot_test.rb | test/unicode_plot_test.rb | # frozen_string_literal: true
require_relative 'test_helper'
require 'unicode_plot'
# Check the UnicodePlot constants that YouPlot depends on.
# Prepare for UnicodePlot version upgrades.
class UnicodePlotTest < Test::Unit::TestCase
test 'VERSION' do
assert UnicodePlot::VERSION
end
test 'BORDER_MAP' do
... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/youplot/dsv_test.rb | test/youplot/dsv_test.rb | # frozen_string_literal: true
require_relative '../test_helper'
class YouPlotDSVTest < Test::Unit::TestCase
def setup
@m = YouPlot::DSV
end
test :transpose2 do
n = nil
assert_equal([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]], @m.transpose2([[1, 4, 7],
... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/youplot/simple_test.rb | test/youplot/simple_test.rb | # frozen_string_literal: true
require 'tempfile'
require_relative '../test_helper'
class YouPlotSimpleTest < Test::Unit::TestCase
class << self
def startup
@stdin = $stdin.dup
@stdout = $stdout.dup
@stderr = $stderr.dup
end
def shutdown
$stdin = @stdin
$stdout = @stdout
... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/youplot/iris_test.rb | test/youplot/iris_test.rb | # frozen_string_literal: true
require 'tempfile'
require_relative '../test_helper'
class YouPlotIRISTest < Test::Unit::TestCase
class << self
def startup
@stdin = $stdin.dup
@stdout = $stdout.dup
@stderr = $stderr.dup
end
def shutdown
$stdin = @stdin
$stdout = @stdout
... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/test/youplot/backends/processing_test.rb | test/youplot/backends/processing_test.rb | # frozen_string_literal: true
require_relative '../../test_helper'
class ProcessingTest < Test::Unit::TestCase
test :count_values do
@m = YouPlot::Backends::Processing
assert_equal([%i[a b c], [3, 2, 1]], @m.count_values(%i[a a a b b c]))
assert_equal([%i[c b a], [3, 2, 1]], @m.count_values(%i[a b b c c... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot.rb | lib/youplot.rb | # frozen_string_literal: true
require_relative 'youplot/version'
require_relative 'youplot/dsv'
require_relative 'youplot/parameters'
require_relative 'youplot/command'
module YouPlot
# @run_as_executable = true / false
# YouPlot behaves slightly differently when run as a command line tool
# and when run as a s... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/command.rb | lib/youplot/command.rb | # frozen_string_literal: true
require_relative 'dsv'
require_relative 'parser'
require_relative 'backends/unicode_plot'
module YouPlot
Data = Struct.new(:headers, :series)
class Command
attr_accessor :command, :params, :options
attr_reader :data, :parser
def initialize(argv = ARGV)
@argv =... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/dsv.rb | lib/youplot/dsv.rb | # frozen_string_literal: true
require 'csv'
module YouPlot
# Module to handle DSV (Delimiter-separated values) format.
# Extract header and series.
module DSV
module_function
def parse(input, delimiter, headers, transpose)
# Parse as CSV
arr = CSV.parse(input, col_sep: delimiter)
# R... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/version.rb | lib/youplot/version.rb | # frozen_string_literal: true
module YouPlot
VERSION = '0.4.6'
end
| ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/options.rb | lib/youplot/options.rb | # frozen_string_literal: true
module YouPlot
# Command line options that are not Plot parameters
Options = Struct.new(
:delimiter,
:transpose,
:headers,
:pass,
:output,
:fmt,
:progressive,
:encoding,
:reverse, # count
:color_names, # color
:debug
)
end
| ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/parser.rb | lib/youplot/parser.rb | # frozen_string_literal: true
require 'optparse'
require_relative 'options'
module YouPlot
# Class for parsing command line options
class Parser
class Error < StandardError; end
attr_reader :command, :options, :params,
:main_parser, :sub_parser,
:config_file, :config
... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/parameters.rb | lib/youplot/parameters.rb | # frozen_string_literal: true
module YouPlot
# UnicodePlot parameters.
# Why Struct, not Hash?
# * The keys are static in Struct.
# * Struct does not conflict with keyword arguments. Hash dose.
Parameters = Struct.new(
# Sort me!
:title,
:width,
:height,
:border,
:margin,
:padding... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/backends/processing.rb | lib/youplot/backends/processing.rb | # frozen_string_literal: true
module YouPlot
# plotting functions.
module Backends
module Processing
module_function
def count_values(arr, tally: true, reverse: false)
# tally was added in Ruby 2.7
result = \
if tally && Enumerable.method_defined?(:tally)
arr.... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot/blob/e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397/lib/youplot/backends/unicode_plot.rb | lib/youplot/backends/unicode_plot.rb | # frozen_string_literal: true
# UnicodePlot - Plot your data by Unicode characters
# https://github.com/red-data-tools/unicode_plot.rb
require_relative 'processing'
require 'unicode_plot'
# If the line color is specified as a number, the program will display an error
# message to the user and exit. Remove this patch... | ruby | MIT | e2f82e9c5b18bab477b86d8b7cbdbc3cf4df5397 | 2026-01-04T15:45:57.869385Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/graphql-c_parser/ext/graphql_c_parser_ext/extconf.rb | graphql-c_parser/ext/graphql_c_parser_ext/extconf.rb | # frozen_string_literal: true
require 'mkmf'
create_makefile 'graphql/graphql_c_parser_ext'
| ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/graphql-c_parser/lib/graphql-c_parser.rb | graphql-c_parser/lib/graphql-c_parser.rb | # frozen_string_literal: true
require "graphql/c_parser"
| ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/graphql-c_parser/lib/graphql/c_parser.rb | graphql-c_parser/lib/graphql/c_parser.rb | # frozen_string_literal: true
require "graphql"
require "graphql/c_parser/version"
require "graphql/graphql_c_parser_ext"
module GraphQL
module CParser
def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace, max_tokens: nil)
Parser.parse(query_str, filename: filename, trace: trace, ma... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/graphql-c_parser/lib/graphql/c_parser/version.rb | graphql-c_parser/lib/graphql/c_parser/version.rb | # frozen_string_literal: true
module GraphQL
module CParser
VERSION = "1.1.3"
end
end
| ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/benchmark/run.rb | benchmark/run.rb | # frozen_string_literal: true
require "graphql"
ADD_WARDEN = false
require "jazz"
require "benchmark/ips"
require "stackprof"
require "memory_profiler"
require "graphql/batch"
require "securerandom"
module GraphQLBenchmark
QUERY_STRING = GraphQL::Introspection::INTROSPECTION_QUERY
DOCUMENT = GraphQL.parse(QUERY_ST... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/benchmark/batch_loading.rb | benchmark/batch_loading.rb | # frozen_string_literal: true
module BatchLoading
class GraphQLBatchSchema < GraphQL::Schema
DATA = [
{ id: "1", name: "Bulls", player_ids: ["2", "3"] },
{ id: "2", name: "Michael Jordan", team_id: "1" },
{ id: "3", name: "Scottie Pippin", team_id: "1" },
{ id: "4", name: "Braves", player_... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/spec/graphql_spec.rb | spec/graphql_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "open3"
describe GraphQL do
it "loads without warnings" do
stderr_and_stdout, _status = Open3.capture2e(%|ruby -Ilib -e "require 'bundler/inline'; gemfile(true, quiet: true) { source('https://rubygems.org'); gem('graphql', path: './') }; GraphQL.eager_l... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require 'rubygems'
require 'bundler'
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter
]
SimpleCov.start do
enable_co... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/spec/support/global_id.rb | spec/support/global_id.rb | # frozen_string_literal: true
if defined?(GlobalID)
GlobalID.app = "graphql-ruby-test"
class GlobalIDUser
include GlobalID::Identification
attr_reader :id
def initialize(id, located_many: false)
@id = id
@located_many = located_many
end
def located_many?
@located_many
... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby/blob/fa2ba4e489f8475b194f7c6985e0b25681a442c2/spec/support/connection_assertions.rb | spec/support/connection_assertions.rb | # frozen_string_literal: true
# A shared module for testing ArrayConnection, RelationConnection,
# DatasetConnection and MongoRelationConnection.
#
# The test must implement `schema` to serve the queries below with the expected results.
module ConnectionAssertions
MAX_PAGE_SIZE = 6
DEFAULT_PAGE_SIZE = 4
NAMES = ... | ruby | MIT | fa2ba4e489f8475b194f7c6985e0b25681a442c2 | 2026-01-04T15:43:02.089024Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.