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 | ankane/blazer | https://github.com/ankane/blazer | app/controllers/blazer/dashboards_controller.rb | Ruby | mit | 4,779 | master | 2,829 | module Blazer
class DashboardsController < BaseController
before_action :set_dashboard, only: [:show, :edit, :update, :destroy, :refresh]
def new
@dashboard = Blazer::Dashboard.new
end
def create
@dashboard = Blazer::Dashboard.new
# use creator_id instead of creator
# since w... |
github | ankane/blazer | https://github.com/ankane/blazer | app/controllers/blazer/uploads_controller.rb | Ruby | mit | 4,779 | master | 4,836 | module Blazer
class UploadsController < BaseController
before_action :ensure_uploads
before_action :set_upload, only: [:show, :edit, :update, :destroy]
def index
@uploads = Blazer::Upload.order(:table)
end
def new
@upload = Blazer::Upload.new
end
def create
@upload = B... |
github | ankane/blazer | https://github.com/ankane/blazer | app/models/blazer/query.rb | Ruby | mit | 4,779 | master | 1,222 | module Blazer
class Query < Record
belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_class
has_many :checks, dependent: :destroy
has_many :dashboard_queries, dependent: :destroy
has_many :dashboards, through: :dashboard_queries
has_many :audits
validates :... |
github | ankane/blazer | https://github.com/ankane/blazer | app/models/blazer/upload.rb | Ruby | mit | 4,779 | master | 398 | module Blazer
class Upload < Record
belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_class
validates :table, presence: true, uniqueness: true, format: {with: /\A[a-z0-9_]+\z/, message: "can only contain lowercase letters, numbers, and underscores"}, length: {maximum: 63}... |
github | ankane/blazer | https://github.com/ankane/blazer | app/models/blazer/check.rb | Ruby | mit | 4,779 | master | 2,885 | module Blazer
class Check < Record
belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_class
belongs_to :query
validates :query_id, presence: true
validate :validate_emails
validate :validate_variables, if: -> { query_id_changed? }
before_validation :set_st... |
github | ankane/blazer | https://github.com/ankane/blazer | app/models/blazer/dashboard.rb | Ruby | mit | 4,779 | master | 444 | module Blazer
class Dashboard < Record
belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_class
has_many :dashboard_queries, dependent: :destroy
has_many :queries, through: :dashboard_queries
validates :name, presence: true
def variables
queries.flat_map... |
github | ankane/blazer | https://github.com/ankane/blazer | app/helpers/blazer/base_helper.rb | Ruby | mit | 4,779 | master | 1,129 | module Blazer
module BaseHelper
def blazer_title(title = nil)
if title
content_for(:title) { title }
else
content_for?(:title) ? content_for(:title) : nil
end
end
BLAZER_URL_REGEX = /\Ahttps?:\/\/[\S]+\z/
BLAZER_IMAGE_EXT = %w[png jpg jpeg gif]
def blazer_format... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer.rb | Ruby | mit | 4,779 | master | 8,303 | # 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/generators/blazer/install_generator.rb | Ruby | mit | 4,779 | master | 592 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/generators/blazer/uploads_generator.rb | Ruby | mit | 4,779 | master | 515 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/engine.rb | Ruby | mit | 4,779 | master | 2,273 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/slack_notifier.rb | Ruby | mit | 4,779 | master | 2,862 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/check_mailer.rb | Ruby | mit | 4,779 | master | 843 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/result.rb | Ruby | mit | 4,779 | master | 5,318 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/forecasters.rb | Ruby | mit | 4,779 | master | 201 | 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 |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/anomaly_detectors.rb | Ruby | mit | 4,779 | master | 791 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/run_statement.rb | Ruby | mit | 4,779 | master | 1,516 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters.rb | Ruby | mit | 4,779 | master | 1,215 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/run_statement_job.rb | Ruby | mit | 4,779 | master | 675 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/result_cache.rb | Ruby | mit | 4,779 | master | 1,760 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/data_source.rb | Ruby | mit | 4,779 | master | 7,436 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/statement.rb | Ruby | mit | 4,779 | master | 2,491 | 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 =... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/hive_adapter.rb | Ruby | mit | 4,779 | master | 1,381 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/presto_adapter.rb | Ruby | mit | 4,779 | master | 1,364 | 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
... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/opensearch_adapter.rb | Ruby | mit | 4,779 | master | 1,488 | 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
... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/athena_adapter.rb | Ruby | mit | 4,779 | master | 5,971 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/soda_adapter.rb | Ruby | mit | 4,779 | master | 3,089 | 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(/--.+... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/ignite_adapter.rb | Ruby | mit | 4,779 | master | 2,159 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/cassandra_adapter.rb | Ruby | mit | 4,779 | master | 2,141 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/spark_adapter.rb | Ruby | mit | 4,779 | master | 301 | 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 |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/drill_adapter.rb | Ruby | mit | 4,779 | master | 848 | 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 { |... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/influxdb_adapter.rb | Ruby | mit | 4,779 | master | 1,322 | 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"]
... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/elasticsearch_adapter.rb | Ruby | mit | 4,779 | master | 1,919 | 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}*/... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/bigquery_adapter.rb | Ruby | mit | 4,779 | master | 2,201 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/snowflake_adapter.rb | Ruby | mit | 4,779 | master | 2,508 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/sql_adapter.rb | Ruby | mit | 4,779 | master | 12,361 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/base_adapter.rb | Ruby | mit | 4,779 | master | 1,543 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/druid_adapter.rb | Ruby | mit | 4,779 | master | 3,264 | 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 = []
... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/salesforce_adapter.rb | Ruby | mit | 4,779 | master | 1,316 | 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
#... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/blazer/adapters/neo4j_adapter.rb | Ruby | mit | 4,779 | master | 2,575 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | lib/tasks/blazer.rake | Ruby | mit | 4,779 | master | 448 | namespace :blazer do
desc "run checks"
task :run_checks, [:schedule] => :environment do |_, args|
Blazer.run_checks(schedule: args[:schedule] || ENV["SCHEDULE"])
end
desc "send failing checks"
task send_failing_checks: :environment do
Blazer.send_failing_checks
end
desc "archive queries"
task ... |
github | ankane/blazer | https://github.com/ankane/blazer | test/anomaly_checks_test.rb | Ruby | mit | 4,779 | master | 1,127 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/cache_test.rb | Ruby | mit | 4,779 | master | 1,326 | 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
... |
github | ankane/blazer | https://github.com/ankane/blazer | test/queries_test.rb | Ruby | mit | 4,779 | master | 5,786 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/forecasting_test.rb | Ruby | mit | 4,779 | master | 673 | 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
... |
github | ankane/blazer | https://github.com/ankane/blazer | test/cohort_analysis_test.rb | Ruby | mit | 4,779 | master | 868 | 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() ... |
github | ankane/blazer | https://github.com/ankane/blazer | test/test_helper.rb | Ruby | mit | 4,779 | master | 1,881 | 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::... |
github | ankane/blazer | https://github.com/ankane/blazer | test/charts_test.rb | Ruby | mit | 4,779 | master | 986 | 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
... |
github | ankane/blazer | https://github.com/ankane/blazer | test/dashboards_test.rb | Ruby | mit | 4,779 | master | 766 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/maps_test.rb | Ruby | mit | 4,779 | master | 543 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/archive_test.rb | Ruby | mit | 4,779 | master | 542 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/uploads_test.rb | Ruby | mit | 4,779 | master | 2,699 | 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")
... |
github | ankane/blazer | https://github.com/ankane/blazer | test/checks_test.rb | Ruby | mit | 4,779 | master | 2,143 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/permissions_test.rb | Ruby | mit | 4,779 | master | 1,391 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/support/adapter_test.rb | Ruby | mit | 4,779 | master | 1,372 | 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: ... |
github | ankane/blazer | https://github.com/ankane/blazer | test/internal/db/schema.rb | Ruby | mit | 4,779 | master | 1,178 | 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 ... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/elasticsearch_test.rb | Ruby | mit | 4,779 | master | 1,318 | 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\"]",... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/drill_test.rb | Ruby | mit | 4,779 | master | 652 | 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",... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/neo4j_test.rb | Ruby | mit | 4,779 | master | 1,551 | 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 ... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/influxdb_test.rb | Ruby | mit | 4,779 | master | 1,789 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/mysql_test.rb | Ruby | mit | 4,779 | master | 3,055 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/druid_test.rb | Ruby | mit | 4,779 | master | 1,314 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/presto_test.rb | Ruby | mit | 4,779 | master | 711 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/postgresql_test.rb | Ruby | mit | 4,779 | master | 2,422 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/sqlserver_test.rb | Ruby | mit | 4,779 | master | 1,798 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/cassandra_test.rb | Ruby | mit | 4,779 | master | 2,011 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/hive_test.rb | Ruby | mit | 4,779 | master | 1,272 | 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 ... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/opensearch_test.rb | Ruby | mit | 4,779 | master | 569 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/ignite_test.rb | Ruby | mit | 4,779 | master | 1,329 | 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}... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/soda_test.rb | Ruby | mit | 4,779 | master | 634 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/athena_test.rb | Ruby | mit | 4,779 | master | 1,856 | 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\... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/redshift_test.rb | Ruby | mit | 4,779 | master | 1,491 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/bigquery_test.rb | Ruby | mit | 4,779 | master | 1,506 | 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 {... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/spark_test.rb | Ruby | mit | 4,779 | master | 1,274 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/sqlite_test.rb | Ruby | mit | 4,779 | master | 1,382 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | test/adapters/salesforce_test.rb | Ruby | mit | 4,779 | master | 1,059 | 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... |
github | ankane/blazer | https://github.com/ankane/blazer | config/routes.rb | Ruby | mit | 4,779 | master | 531 | 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] ... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | Rakefile | Ruby | mit | 4,737 | main | 226 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end
task default: :test |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | youplot.gemspec | Ruby | mit | 4,737 | main | 791 | # frozen_string_literal: true
require_relative 'lib/youplot/version'
Gem::Specification.new do |spec|
spec.name = 'youplot'
spec.version = YouPlot::VERSION
spec.authors = ['kojix2']
spec.email = ['2xijok@gmail.com']
spec.summary = 'A command line tool for Unicode Plotting... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/unicode_plot_test.rb | Ruby | mit | 4,737 | main | 520 | # 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
... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/youplot_test.rb | Ruby | mit | 4,737 | main | 528 | # 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_... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/youplot/simple_test.rb | Ruby | mit | 4,737 | main | 8,046 | # 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
... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/youplot/parser_test.rb | Ruby | mit | 4,737 | main | 2,417 | # frozen_string_literal: true
require 'tempfile'
require 'tmpdir'
require 'stringio'
require_relative '../test_helper'
class YouPlotParserTest < Test::Unit::TestCase
def setup
# find_config_file sets MYYOUPLOTRC as a side effect; isolate tests.
@original_myyouplotrc = ENV['MYYOUPLOTRC']
ENV.delete('MYYO... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/youplot/dsv_test.rb | Ruby | mit | 4,737 | main | 5,066 | # 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],
... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/youplot/iris_test.rb | Ruby | mit | 4,737 | main | 5,341 | # 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
... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | test/youplot/backends/processing_test.rb | Ruby | mit | 4,737 | main | 3,000 | # 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... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot.rb | Ruby | mit | 4,737 | main | 681 | # 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... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/options.rb | Ruby | mit | 4,737 | main | 851 | # 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
)
# Default v... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/parameters.rb | Ruby | mit | 4,737 | main | 538 | # 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... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/command.rb | Ruby | mit | 4,737 | main | 6,849 | # frozen_string_literal: true
require 'tempfile'
require 'stringio'
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 i... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/dsv.rb | Ruby | mit | 4,737 | main | 2,265 | # 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... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/parser.rb | Ruby | mit | 4,737 | main | 14,073 | # 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
... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/backends/unicode_plot.rb | Ruby | mit | 4,737 | main | 7,515 | # 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... |
github | red-data-tools/YouPlot | https://github.com/red-data-tools/YouPlot | lib/youplot/backends/processing.rb | Ruby | mit | 4,737 | main | 4,382 | # 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.... |
github | SteveLTN/https-portal | https://github.com/SteveLTN/https-portal | fs_overlay/opt/certs_manager/certs_manager.rb | Ruby | mit | 4,705 | master | 3,850 | Dir[File.dirname(__FILE__) + '/lib/*.rb'].each { |file| require file }
require_relative 'models/domain'
require 'fileutils'
class CertsManager
include Commands
attr_accessor :lock
def setup
setup_config(true)
end
def reconfig
setup_config(false)
end
def setup_config(initial)
with_lock do
... |
github | SteveLTN/https-portal | https://github.com/SteveLTN/https-portal | fs_overlay/opt/certs_manager/lib/na_config.rb | Ruby | mit | 4,705 | master | 1,525 | module NAConfig
def self.portal_base_dir
"/var/lib/https-portal"
end
def self.domains
(env_domains + auto_discovered_domains).uniq {|d| [d.name, d.port] }
end
def self.domains_w_unique_names
(env_domains + auto_discovered_domains).uniq(&:name)
end
def self.stage
if ENV['STAGE']
EN... |
github | SteveLTN/https-portal | https://github.com/SteveLTN/https-portal | fs_overlay/opt/certs_manager/lib/erb_binding.rb | Ruby | mit | 4,705 | master | 483 | require 'erb'
class ERBBinding
class CleanBinding
def initialize(hash)
hash.each do |key, value|
singleton_class.send(:define_method, key) { value }
end
end
def get
binding
end
end
def initialize(template_path, binding_hash)
@template = File.read(template_path)
... |
github | SteveLTN/https-portal | https://github.com/SteveLTN/https-portal | fs_overlay/opt/certs_manager/lib/nginx.rb | Ruby | mit | 4,705 | master | 2,412 | require_relative './commands'
module Nginx
class NginxReloadException < RuntimeError; end
def self.setup
compiled_basic_config = ERBBinding.new('/var/lib/nginx-conf/nginx.conf.erb', {}).compile
File.open('/etc/nginx/nginx.conf', 'w') do |f|
f.write compiled_basic_config
end
end
def self.co... |
github | SteveLTN/https-portal | https://github.com/SteveLTN/https-portal | fs_overlay/opt/certs_manager/lib/open_ssl.rb | Ruby | mit | 4,705 | master | 2,915 | require 'date'
module OpenSSL
def self.ensure_account_key
path = "#{NAConfig.portal_base_dir}/account.key"
unless File.exist?(path) && system("openssl rsa --in #{path} --noout --check")
system "openssl genrsa 4096 > #{path}"
end
end
def self.create_ongoing_domain_key(domain)
algo = NAConfi... |
github | SteveLTN/https-portal | https://github.com/SteveLTN/https-portal | fs_overlay/opt/certs_manager/lib/acme.rb | Ruby | mit | 4,705 | master | 1,420 | require 'timeout'
require 'fileutils'
module ACME
class FailedToSignException < RuntimeError; end
def self.sign(domain)
if domain.stage == 'local'
OpenSSL.self_sign(domain)
else
le_sign(domain)
end
rescue FailedToSignException, Timeout::Error => e
false
end
private
def self.l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.