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 |
|---|---|---|---|---|---|---|---|---|
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/helpers.rb | slack-gamebot/api/helpers.rb | require 'slack-gamebot/api/helpers/cursor_helpers'
require 'slack-gamebot/api/helpers/pagination_parameters'
require 'slack-gamebot/api/helpers/sort_helpers'
require 'slack-gamebot/api/helpers/error_helpers'
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/status_presenter.rb | slack-gamebot/api/presenters/status_presenter.rb | module Api
module Presenters
module StatusPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
link :self do |opts|
"#{base_url(opts)}/status"
end
property :games_count
property :games
def games_count
Game.co... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/challenge_presenter.rb | slack-gamebot/api/presenters/challenge_presenter.rb | module Api
module Presenters
module ChallengePresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :id, type: String, desc: 'Challenge ID.'
property :state, type: String, desc: 'Current state of the challenge.'
property :channel, ... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/matches_presenter.rb | slack-gamebot/api/presenters/matches_presenter.rb | module Api
module Presenters
module MatchesPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: MatchPresenter, as: :matches, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/users_presenter.rb | slack-gamebot/api/presenters/users_presenter.rb | module Api
module Presenters
module UsersPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: UserPresenter, as: :users, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/team_presenter.rb | slack-gamebot/api/presenters/team_presenter.rb | module Api
module Presenters
module TeamPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :id, type: String, desc: 'Team ID.'
property :team_id, type: String, desc: 'Slack team ID.'
property :name, type: String, desc: 'Team na... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/teams_presenter.rb | slack-gamebot/api/presenters/teams_presenter.rb | module Api
module Presenters
module TeamsPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: TeamPresenter, as: :teams, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/paginated_presenter.rb | slack-gamebot/api/presenters/paginated_presenter.rb | module Api
module Presenters
module PaginatedPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :total_count
link :self do |opts|
"#{request_url(opts)}#{query_string_for_cursor(nil, opts)}"
end
link :next do |op... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/games_presenter.rb | slack-gamebot/api/presenters/games_presenter.rb | module Api
module Presenters
module GamesPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: GamePresenter, as: :games, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/seasons_presenter.rb | slack-gamebot/api/presenters/seasons_presenter.rb | module Api
module Presenters
module SeasonsPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: SeasonPresenter, as: :seasons, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/user_presenter.rb | slack-gamebot/api/presenters/user_presenter.rb | module Api
module Presenters
module UserPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :id, type: String, desc: 'User ID.'
property :user_name, type: String, desc: 'User name.'
property :nickname, type: String, desc: 'Optio... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/challenges_presenter.rb | slack-gamebot/api/presenters/challenges_presenter.rb | module Api
module Presenters
module ChallengesPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: ChallengePresenter, as: :challenges, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/season_presenter.rb | slack-gamebot/api/presenters/season_presenter.rb | module Api
module Presenters
module SeasonPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :current_id, as: :id, type: String, desc: 'Season ID.'
property :created_at, type: DateTime, desc: 'Date/time when the season was created.'
... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/root_presenter.rb | slack-gamebot/api/presenters/root_presenter.rb | module Api
module Presenters
module RootPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
link :self do |opts|
"#{base_url(opts)}/api/"
end
link :status do |opts|
"#{base_url(opts)}/api/status"
end
link :u... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/user_ranks_presenter.rb | slack-gamebot/api/presenters/user_ranks_presenter.rb | module Api
module Presenters
module UserRanksPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
include Api::Presenters::PaginatedPresenter
collection :results, extend: UserRankPresenter, as: :user_ranks, embedded: true
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/game_presenter.rb | slack-gamebot/api/presenters/game_presenter.rb | module Api
module Presenters
module GamePresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :id, type: String, desc: 'Game ID.'
property :name, type: String, desc: 'Name of the game.'
property :bot_name, type: String, desc: 'Bot... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/match_presenter.rb | slack-gamebot/api/presenters/match_presenter.rb | module Api
module Presenters
module MatchPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :id, type: String, desc: 'Match ID.'
property :tied, type: ::Grape::API::Boolean, desc: 'Match is a tie.'
property :resigned, type: ::G... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/presenters/user_rank_presenter.rb | slack-gamebot/api/presenters/user_rank_presenter.rb | module Api
module Presenters
module UserRankPresenter
include Roar::JSON::HAL
include Roar::Hypermedia
include Grape::Roar::Representer
property :id, type: String, desc: 'UserRank ID.'
property :user_name, type: String, desc: 'UserRank name.'
property :wins, type: Integer, des... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/helpers/cursor_helpers.rb | slack-gamebot/api/helpers/cursor_helpers.rb | module Api
module Helpers
module CursorHelpers
extend ActiveSupport::Concern
# apply cursor-based pagination to a collection
# returns a hash:
# results: (paginated collection subset)
# next: (cursor to the next page)
def paginate_by_cursor(coll, &)
raise 'Both cur... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/helpers/sort_helpers.rb | slack-gamebot/api/helpers/sort_helpers.rb | module Api
module Helpers
module SortHelpers
extend ActiveSupport::Concern
def sort_order(options = {})
params[:sort] = options[:default_sort_order] unless params[:sort]
return [] unless params[:sort]
sort_order = params[:sort].to_s
unless options[:default_sort_order]... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/helpers/error_helpers.rb | slack-gamebot/api/helpers/error_helpers.rb | module Api
module Helpers
module ErrorHelpers
extend ActiveSupport::Concern
included do
rescue_from :all, backtrace: true do |e|
backtrace = e.backtrace[0..5].join("\n ")
Api::Middleware.logger.error "#{e.class.name}: #{e.message}\n #{backtrace}"
error = { type... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/helpers/pagination_parameters.rb | slack-gamebot/api/helpers/pagination_parameters.rb | module Api
module Helpers
module PaginationParameters
extend Grape::API::Helpers
params :pagination do
optional :offset, type: Integer, desc: 'Offset from which to retrieve.'
optional :size, type: Integer, desc: 'Number of items to retrieve for this page or from the current offset.'
... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/challenges_endpoint.rb | slack-gamebot/api/endpoints/challenges_endpoint.rb | module Api
module Endpoints
class ChallengesEndpoint < Grape::API
format :json
helpers Api::Helpers::CursorHelpers
helpers Api::Helpers::SortHelpers
helpers Api::Helpers::PaginationParameters
namespace :challenges do
desc 'Get a challenge.'
params do
requir... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/subscriptions_endpoint.rb | slack-gamebot/api/endpoints/subscriptions_endpoint.rb | module Api
module Endpoints
class SubscriptionsEndpoint < Grape::API
format :json
namespace :subscriptions do
desc 'Subscribe to slack-playplay.'
params do
requires :stripe_token, type: String
requires :stripe_token_type, type: String
requires :stripe_ema... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/seasons_endpoint.rb | slack-gamebot/api/endpoints/seasons_endpoint.rb | module Api
module Endpoints
class SeasonsEndpoint < Grape::API
format :json
helpers Api::Helpers::CursorHelpers
helpers Api::Helpers::SortHelpers
helpers Api::Helpers::PaginationParameters
namespace :seasons do
desc 'Get current season.'
params do
requires ... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/teams_endpoint.rb | slack-gamebot/api/endpoints/teams_endpoint.rb | module Api
module Endpoints
class TeamsEndpoint < Grape::API
format :json
helpers Api::Helpers::CursorHelpers
helpers Api::Helpers::SortHelpers
helpers Api::Helpers::PaginationParameters
namespace :teams do
desc 'Get a team.'
params do
requires :id, type: S... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/matches_endpoint.rb | slack-gamebot/api/endpoints/matches_endpoint.rb | module Api
module Endpoints
class MatchesEndpoint < Grape::API
format :json
helpers Api::Helpers::CursorHelpers
helpers Api::Helpers::SortHelpers
helpers Api::Helpers::PaginationParameters
namespace :matches do
desc 'Get a match.'
params do
requires :id, ty... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/credit_cards_endpoint.rb | slack-gamebot/api/endpoints/credit_cards_endpoint.rb | module Api
module Endpoints
class CreditCardsEndpoint < Grape::API
format :json
namespace :credit_cards do
desc 'Updates a credit card.'
params do
requires :stripe_token, type: String
optional :stripe_token_type, type: String
optional :stripe_email, type:... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/users_endpoint.rb | slack-gamebot/api/endpoints/users_endpoint.rb | module Api
module Endpoints
class UsersEndpoint < Grape::API
format :json
helpers Api::Helpers::CursorHelpers
helpers Api::Helpers::SortHelpers
helpers Api::Helpers::PaginationParameters
namespace :users do
desc 'Get a user.'
params do
requires :id, type: S... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/root_endpoint.rb | slack-gamebot/api/endpoints/root_endpoint.rb | module Api
module Endpoints
class RootEndpoint < Grape::API
include Api::Helpers::ErrorHelpers
prefix :api
format :json
formatter :json, Grape::Formatter::Roar
get do
present self, with: Api::Presenters::RootPresenter
end
mount Api::Endpoints::StatusEndpoint
... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/games_endpoint.rb | slack-gamebot/api/endpoints/games_endpoint.rb | module Api
module Endpoints
class GamesEndpoint < Grape::API
format :json
helpers Api::Helpers::CursorHelpers
helpers Api::Helpers::SortHelpers
helpers Api::Helpers::PaginationParameters
namespace :games do
desc 'Get a game.'
params do
requires :id, type: S... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/slack-gamebot/api/endpoints/status_endpoint.rb | slack-gamebot/api/endpoints/status_endpoint.rb | module Api
module Endpoints
class StatusEndpoint < Grape::API
format :json
namespace :status do
desc 'Get system status.'
get do
present self, with: Api::Presenters::StatusPresenter
end
end
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/slack_ruby_bot_client.rb | config/initializers/slack_ruby_bot_client.rb | # frozen_string_literal: true
module SlackRubyBot
class Client < Slack::RealTime::Client
attr_accessor :send_gifs, :aliases
def initialize(attrs = {})
super
@send_gifs = attrs[:send_gifs]
@aliases = attrs[:aliases]
end
def send_gifs?
send_gifs.nil? || send_gifs
end
... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/giphy.rb | config/initializers/giphy.rb | module Giphy
def self.random(keywords)
return unless ENV.key?('GIPHY_API_KEY')
url = "http://api.giphy.com/v1/gifs/random?q=#{keywords}&api_key=#{ENV.fetch('GIPHY_API_KEY', nil)}&rating=G"
result = JSON.parse(Net::HTTP.get_response(URI.parse(url)).body)
result['data']['images']['fixed_height']['url']... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/array.rb | config/initializers/array.rb | class Array
def and
join_with 'and'
end
def or
join_with 'or'
end
def same?
uniq.length == 1
end
private
def join_with(separator)
if count > 1
"#{self[0..-2].join(', ')} #{separator} #{self[-1]}"
else
first
end
end
end
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/slack_ruby_bot_commands_base.rb | config/initializers/slack_ruby_bot_commands_base.rb | module SlackRubyBot
module Commands
class Base
class << self
def invoke(client, data)
_invoke client, data
rescue Mongoid::Errors::Validations => e
logger.info "#{name.demodulize.upcase}: #{client.owner}, error - #{e.document.class}, #{e.document.errors.to_hash}"
... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/active_support.rb | config/initializers/active_support.rb | ActiveSupport.to_time_preserves_timezone = :zone
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/slack_ruby_bot_server_mailchimp.rb | config/initializers/slack_ruby_bot_server_mailchimp.rb | SlackRubyBotServer::Mailchimp.configure do |config|
config.mailchimp_api_key = ENV.fetch('MAILCHIMP_API_KEY', nil)
config.mailchimp_list_id = ENV.fetch('MAILCHIMP_LIST_ID', nil)
config.additional_member_tags = ['gamebot']
config.additional_merge_fields = ->(team, _options) { { 'BOT' => team.game.name.capitalize... | ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
dblock/slack-gamebot | https://github.com/dblock/slack-gamebot/blob/0af9dc9bf8c61523ed46c1007a96a3c9daa488c8/config/initializers/stripe.rb | config/initializers/stripe.rb | Stripe.api_key = ENV['STRIPE_API_KEY'] if ENV.key?('STRIPE_API_KEY')
| ruby | MIT | 0af9dc9bf8c61523ed46c1007a96a3c9daa488c8 | 2026-01-04T17:48:57.592423Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/ownership_test.rb | test/ownership_test.rb | require_relative "test_helper"
class OwnershipTest < Minitest::Test
def test_around
owner :logistics do
$around_calls << "middle"
end
assert_equal ["start", "middle", "finish"], $around_calls
end
def test_exception
error = assert_raises do
owner :logistics do
raise "boom"
... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/rollbar_test.rb | test/rollbar_test.rb | require_relative "test_helper"
require "rollbar"
Rollbar.configure do |config|
config.logger = Logger.new(nil)
config.access_token = "footoken"
config.transmit = false
config.disable_monkey_patch = true
config.use_payload_access_token = true
end
Ownership::Rollbar.access_token = {
logistics: "logistics-t... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/active_record_test.rb | test/active_record_test.rb | require_relative "test_helper"
$io = StringIO.new
ActiveRecord::Base.logger = ActiveSupport::Logger.new($io)
class ActiveRecordTest < Minitest::Test
def setup
ActiveRecord::QueryLogs.tags = [:owner]
super
$io.truncate(0)
end
def teardown
ActiveRecord::QueryLogs.tags = []
end
def test_owner... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/controller_test.rb | test/controller_test.rb | require_relative "test_helper"
class ControllerTest < ActionDispatch::IntegrationTest
def test_controller
get root_url
assert_equal :logistics, $current_owner
end
def test_only
get users_url
assert_equal :logistics, $current_owner
end
def test_except
get user_url(1)
assert_equal :cu... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/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"] ? STDOUT : nil)
Combustion.path = "test/internal"
Combustion.initialize! :active_record, :action_controller, :active_job do
config.load_defaults Rails::VERSION::STRING.... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/honeybadger_test.rb | test/honeybadger_test.rb | require_relative "test_helper"
require "honeybadger/ruby"
Honeybadger.init!(framework: :ruby, env: "test", "logging.path": Tempfile.new.path)
Honeybadger.configure do |config|
config.api_key = "default-key"
config.backend = "test"
config.logger = Logger.new(IO::NULL)
end
Ownership::Honeybadger.api_keys = {
l... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/job_test.rb | test/job_test.rb | require_relative "test_helper"
class JobTest < Minitest::Test
def test_job
TestJob.perform_now
assert_equal :logistics, $current_owner
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/internal/app/jobs/test_job.rb | test/internal/app/jobs/test_job.rb | class TestJob < ActiveJob::Base
owner :logistics
def perform
$current_owner = Ownership.owner
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/internal/app/controllers/home_controller.rb | test/internal/app/controllers/home_controller.rb | class HomeController < ActionController::Base
owner :logistics
def index
$current_owner = Ownership.owner
head :ok
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/internal/app/controllers/users_controller.rb | test/internal/app/controllers/users_controller.rb | class UsersController < ActionController::Base
owner :logistics, only: [:index]
owner :customers, except: [:index]
def index
$current_owner = Ownership.owner
head :ok
end
def show
$current_owner = Ownership.owner
head :ok
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/internal/app/models/user.rb | test/internal/app/models/user.rb | class User < ActiveRecord::Base
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/internal/db/schema.rb | test/internal/db/schema.rb | ActiveRecord::Schema.define do
create_table :users do |t|
t.string :name
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/test/internal/config/routes.rb | test/internal/config/routes.rb | Rails.application.routes.draw do
root "home#index"
resources :users, only: [:index, :show]
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership.rb | lib/ownership.rb | # modules
require_relative "ownership/global_methods"
require_relative "ownership/version"
# integrations
require_relative "ownership/honeybadger"
require_relative "ownership/rollbar"
module Ownership
class << self
attr_accessor :around_change, :default_owner
def owner
Thread.current[:ownership_owner... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership/version.rb | lib/ownership/version.rb | module Ownership
VERSION = "0.5.0"
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership/controller_methods.rb | lib/ownership/controller_methods.rb | require "active_support/concern"
module Ownership
module ControllerMethods
extend ActiveSupport::Concern
class_methods do
def owner(owner, **options)
around_action(**options) do |_, block|
owner(owner) { block.call }
end
end
end
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership/rollbar.rb | lib/ownership/rollbar.rb | module Ownership
module Rollbar
class << self
attr_reader :access_token
def access_token=(access_token)
@access_token = access_token
@configure ||= configure # just once
access_token
end
private
def owner_access_token(owner)
access_token.respond_to?... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership/job_methods.rb | lib/ownership/job_methods.rb | require "active_support/concern"
module Ownership
module JobMethods
extend ActiveSupport::Concern
class_methods do
def owner(owner)
around_perform do |_, block|
owner(owner) { block.call }
end
end
end
end
end
| ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership/global_methods.rb | lib/ownership/global_methods.rb | module Ownership
module GlobalMethods
private
def owner(owner, &block)
raise ArgumentError, "Missing block" unless block_given?
previous_value = Thread.current[:ownership_owner]
begin
Thread.current[:ownership_owner] = owner
# callbacks
if Ownership.around_change
... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
ankane/ownership | https://github.com/ankane/ownership/blob/c72a57652e35d746a6fcdabaed26b1dab30d6d94/lib/ownership/honeybadger.rb | lib/ownership/honeybadger.rb | module Ownership
module Honeybadger
class << self
attr_reader :api_keys
def api_keys=(api_keys)
@api_keys = api_keys
@configuration ||= configure
api_keys
end
private
def add_owner_as_tag(notice, current_owner)
return unless current_owner
n... | ruby | MIT | c72a57652e35d746a6fcdabaed26b1dab30d6d94 | 2026-01-04T17:51:02.493959Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/test/test_memstat.rb | test/test_memstat.rb | require 'memstat'
require 'minitest/autorun'
require 'benchmark'
class TestCli < Minitest::Test
SMAPS_PATH = File.expand_path('../../test/files/smaps.txt', __FILE__)
STATUS_PATH = File.expand_path('../../test/files/status.txt', __FILE__)
def test_print
smaps = Memstat::Proc::Smaps.new(:path => SMAPS_PATH)
... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat.rb | lib/memstat.rb | require 'thor'
module Memstat
autoload :Cli, 'memstat/cli'
autoload :Version, 'memstat/version'
module OobGC
autoload :Unicorn, 'memstat/oob_gc/unicorn'
end
module Proc
autoload :Base, 'memstat/proc/base'
autoload :Smaps, 'memstat/proc/smaps'
autoload :Status, 'memstat/proc/status... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat/version.rb | lib/memstat/version.rb | module Memstat
VERSION = '0.1.3'
end
| ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat/cli.rb | lib/memstat/cli.rb | module Memstat
class Cli < Thor
# Aggregate information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
desc 'smaps', 'Print useful information from /proc/[pid]/smaps'
def smap... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat/oob_gc/unicorn.rb | lib/memstat/oob_gc/unicorn.rb | module Memstat
module OobGC
module Unicorn
def self.new(app, threshold = (1024**3))
self.const_set :OOBGC_THRESHOLD, threshold
app # pretend to be Rack middleware since it was in the past
end
def process_client(client)
super(client) # Unicorn::HttpServer#process_client
... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat/proc/smaps.rb | lib/memstat/proc/smaps.rb | module Memstat
module Proc
class Smaps < Base
FIELDS = %w[size rss pss shared_clean shared_dirty private_clean private_dirty swap]
attr_accessor *FIELDS
attr_accessor :lines, :items
def initialize(options = {})
super
@path ||= "/proc/#{@pid}/smaps"
FIELDS.each do ... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat/proc/base.rb | lib/memstat/proc/base.rb | module Memstat
module Proc
class Base
attr_accessor :pid, :path
def initialize(options = {})
raise Error.new('path or pid must be given') unless options[:path] || options[:pid]
@pid = options[:pid]
@path = options[:path]
end
def pid?
!!@pid
end
... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
kenn/memstat | https://github.com/kenn/memstat/blob/f6922c277b05e028cc05ad6aba60358d5cb27829/lib/memstat/proc/status.rb | lib/memstat/proc/status.rb | module Memstat
module Proc
class Status < Base
FIELDS = %w[peak size lck pin hwm rss data stk exe lib pte swap]
attr_accessor *FIELDS
def initialize(options = {})
super
@path ||= "/proc/#{@pid}/status"
run
end
def run
@lines = File.readlines(@path).... | ruby | MIT | f6922c277b05e028cc05ad6aba60358d5cb27829 | 2026-01-04T17:51:02.738031Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb_spec.rb | spec/timescaledb_spec.rb | RSpec.describe Timescaledb do
it "has a version number" do
expect(Timescaledb::VERSION).not_to be nil
end
describe ".extension" do
describe ".installed?" do
it { expect(Timescaledb.extension.installed?).to be_truthy }
end
describe ".version" do
it { expect(Timescaledb.extension.versi... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/spec_helper.rb | spec/spec_helper.rb | require "bundler/setup"
require "pry"
require "rspec/its"
require "timescaledb"
require 'timescaledb/toolkit'
require "dotenv"
require "database_cleaner/active_record"
require "active_support/testing/time_helpers"
Dotenv.load! if File.exist?(".env")
ActiveSupport.on_load(:active_record_postgresqladapter) do
self.da... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/support/active_record/models.rb | spec/support/active_record/models.rb | ActiveSupport.on_load(:active_record) { extend Timescaledb::ActsAsHypertable }
class Event < ActiveRecord::Base
acts_as_hypertable
end
class HypertableWithNoOptions < ActiveRecord::Base
acts_as_hypertable
end
class HypertableWithOptions < ActiveRecord::Base
acts_as_hypertable time_column: :timestamp
end
clas... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/support/active_record/schema.rb | spec/support/active_record/schema.rb |
def setup_tables
ActiveRecord::Schema.define(version: 1) do
hypertable_options = { chunk_time_interval: '1 min', compress_segmentby: 'identifier', compress_after: '7 days' }
create_table(:events, id: false, hypertable: hypertable_options) do |t|
t.string :identifier, null: false
t.jsonb :payload... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/schema_dumper_spec.rb | spec/timescaledb/schema_dumper_spec.rb | RSpec.describe Timescaledb::SchemaDumper, database_cleaner_strategy: :truncation do
let(:con) { ActiveRecord::Base.connection }
let(:query) do
Event.select("time_bucket('1m', created_at) as time,
identifier as label,
count(*) as value").group("1,2")
end
let(:query_daily)... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/stats_spec.rb | spec/timescaledb/stats_spec.rb | RSpec.describe Timescaledb::Stats do
let(:hypertables) { Timescaledb::Hypertable.all }
subject(:stats) { described_class.new(hypertables) }
describe '.to_h' do
it 'returns expected structure' do
approximate_row_count = hypertables.each_with_object(Hash.new) do |hypertable, count|
name = [hyper... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/migration_helper_spec.rb | spec/timescaledb/migration_helper_spec.rb | RSpec.describe Timescaledb::MigrationHelpers, database_cleaner_strategy: :truncation do
describe ".create_table" do
let(:con) { ActiveRecord::Base.connection }
before(:each) do
con.drop_table :migration_tests, if_exists: true, force: :cascade
end
subject(:create_table) do
con.create_tabl... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/connection_spec.rb | spec/timescaledb/connection_spec.rb | require 'ostruct'
RSpec.describe Timescaledb do
describe '.establish_connection' do
it 'returns a PG::Connection object' do
expect do
Timescaledb.establish_connection(ENV['PG_URI_TEST'])
end.to_not raise_error
end
end
describe ::Timescaledb::Connection do
subject(:connection) { ... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/acts_as_hypertable_spec.rb | spec/timescaledb/acts_as_hypertable_spec.rb | RSpec.describe Timescaledb::ActsAsHypertable do
describe ".acts_as_hypertable?" do
context "when the model has not been declared as a hypertable" do
it "returns false" do
expect(NonHypertable.acts_as_hypertable?).to eq(false)
end
end
context "when the model has been declared as a hy... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/toolkit_helper_spec.rb | spec/timescaledb/toolkit_helper_spec.rb | RSpec.describe Timescaledb::Toolkit::Helpers, database_cleaner_strategy: :truncation do
let(:con) { ActiveRecord::Base.connection }
let(:hypertable_options) do
{
time_column: 'ts',
chunk_time_interval: '1 day',
compress_segmentby: 'device_id',
compress_orderby: 'ts',
compress_aft... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/continuous_aggregates_helper_spec.rb | spec/timescaledb/continuous_aggregates_helper_spec.rb | require 'spec_helper'
RSpec.describe Timescaledb::ContinuousAggregatesHelper do
let(:test_class) do
HypertableWithContinuousAggregates
end
before(:all) do
ActiveRecord::Base.connection.instance_exec do
hypertable_options = {
time_column: 'ts',
chunk_time_interval: '1 day',
... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/stats/job_stats_spec.rb | spec/timescaledb/stats/job_stats_spec.rb | RSpec.describe Timescaledb::Stats::JobStats do
subject(:stats) { described_class.new }
describe '.to_h' do
it 'returns expected structure' do
expect(stats.to_h).to match(
a_hash_including(failures: a_kind_of(Integer), runs: a_kind_of(Integer), success: a_kind_of(Integer))
)
end
end
en... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/stats/hypertables_spec.rb | spec/timescaledb/stats/hypertables_spec.rb | RSpec.describe Timescaledb::Stats::Hypertables do
let(:hypertables) { Timescaledb.connection.query('SELECT * FROM timescaledb_information.hypertables') }
subject(:stats) { described_class.new(hypertables) }
describe '.to_h' do
it 'returns expected structure' do
approximate_row_count = hypertables.each... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/stats/continuous_aggregates_spec.rb | spec/timescaledb/stats/continuous_aggregates_spec.rb | RSpec.describe Timescaledb::Stats::ContinuousAggregates do
subject(:stats) { described_class.new }
describe '.to_h' do
it 'returns expected structure' do
expect(stats.to_h).to match(a_hash_including(total: a_kind_of(Integer)))
end
end
end | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/stats/chunks_spec.rb | spec/timescaledb/stats/chunks_spec.rb | RSpec.describe Timescaledb::Stats::Chunks do
let(:hypertables) { Timescaledb.connection.query('SELECT * FROM timescaledb_information.hypertables') }
subject(:stats) { described_class.new(hypertables) }
describe '.to_h' do
it 'returns expected structure' do
expect(stats.to_h).to match(
a_hash_i... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/database/quoting_spec.rb | spec/timescaledb/database/quoting_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'timescaledb/database'
RSpec.describe Timescaledb::Database do
describe '.quote' do
it 'wraps given text between single quotes' do
expect(described_class.quote('events')).to eq("'events'")
end
context 'when including single quotes' do
... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/database/types_spec.rb | spec/timescaledb/database/types_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'timescaledb/database'
RSpec.describe Timescaledb::Database do
describe '.interval_to_sql' do
context 'when passing nil' do
it 'returns NULL' do
expect(described_class.interval_to_sql(nil)).to eq('NULL')
end
end
context 'w... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/database/chunk_statements_spec.rb | spec/timescaledb/database/chunk_statements_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'timescaledb/database'
RSpec.describe Timescaledb::Database do
describe '.compress_chunk_sql' do
it 'returns expected SQL' do
expect(
described_class.compress_chunk_sql('_timescaledb_internal._hyper_1_2_chunk')
).to eq("SELECT comp... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/database/schema_statements_spec.rb | spec/timescaledb/database/schema_statements_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'timescaledb/database'
RSpec.describe Timescaledb::Database do
describe '.create_hypertable_sql' do
context 'when passing only required params' do
it 'returns expected SQL' do
expect(
described_class.create_hypertable_sql('even... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/spec/timescaledb/database/hypertable_statements_spec.rb | spec/timescaledb/database/hypertable_statements_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'timescaledb/database'
RSpec.describe Timescaledb::Database do
describe '.hypertable_size_sql' do
it 'returns expected SQL' do
expect(
described_class.hypertable_size_sql('events')
).to eq("SELECT hypertable_size('events');")
e... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/ohlc.rb | examples/toolkit-demo/ohlc.rb | # ruby ohlc.rb postgres://user:pass@host:port/db_name
# @see https://timescale.github.io/timescaledb-ruby/toolkit_ohlc/
require 'bundler/inline' #require only what you need
gemfile(true) do
gem 'timescaledb', path: '../..'
gem 'pry'
end
ActiveRecord::Base.establish_connection ARGV.last
# Compare ohlc processin... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/compare_volatility.rb | examples/toolkit-demo/compare_volatility.rb | # ruby compare_volatility.rb postgres://user:pass@host:port/db_name
require 'bundler/inline' #require only what you need
gemfile(true) do
gem 'timescaledb', path: '../..'
gem 'pry'
end
# TODO: get the volatility using the window function with plain postgresql
ActiveRecord::Base.establish_connection ARGV.last
#... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/candlestick.rb | examples/toolkit-demo/candlestick.rb | # ruby candlestick.rb postgres://user:pass@host:port/db_name
# @see https://timescale.github.io/timescaledb-ruby/toolkit_candlestick/
require 'bundler/inline' #require only what you need
gemfile(true) do
gem 'timescaledb', path: '../..'
gem 'pry'
gem 'puma'
gem 'sinatra'
gem 'sinatra-contrib'
gem 'sinatr... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/lttb-zoom/lttb_zoomable.rb | examples/toolkit-demo/lttb-zoom/lttb_zoomable.rb | # ruby lttb_zoomable.rb postgres://user:pass@host:port/db_name
require 'bundler/inline' #require only what you need
gemfile(true) do
gem 'timescaledb', path: '../../..'
gem 'pry'
gem 'sinatra', require: false
gem 'sinatra-reloader'
gem 'sinatra-cross_origin'
gem 'puma'
end
require 'timescaledb/toolkit'
r... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/lttb/lttb_sinatra.rb | examples/toolkit-demo/lttb/lttb_sinatra.rb | # ruby lttb.rb postgres://user:pass@host:port/db_name
require 'bundler/inline' #require only what you need
gemfile(true) do
gem 'timescaledb', path: '../../..'
gem 'pry'
gem 'sinatra', require: false
gem 'sinatra-reloader', require: false
gem 'sinatra-cross_origin', require: false
gem 'chartkick'
gem 'p... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/lttb/lttb.rb | examples/toolkit-demo/lttb/lttb.rb | module Triangle
module_function
def area(a, b, c)
(ax, ay),(bx,by),(cx,cy) = a,b,c
(
(ax - cx).to_f * (by - ay) -
(ax - bx).to_f * (cy - ay)
).abs * 0.5
end
end
class Lttb
class << self
def avg(array)
array.sum.to_f / array.size
end
def downsample(data, threshold)
... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/toolkit-demo/lttb/lttb_test.rb | examples/toolkit-demo/lttb/lttb_test.rb | require_relative 'lttb'
require 'pp'
require 'date'
data = [
['2020-1-1', 10],
['2020-1-2', 21],
['2020-1-3', 19],
['2020-1-4', 32],
['2020-1-5', 12],
['2020-1-6', 14],
['2020-1-7', 18],
['2020-1-8', 29],
['2020-1-9', 23],
['2020-1-10', 27],
['2020-1-11', 14]]
data.each do |e|
e[0] = Time.mktim... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/ranking/app/jobs/application_job.rb | examples/ranking/app/jobs/application_job.rb | class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
| ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/ranking/app/controllers/application_controller.rb | examples/ranking/app/controllers/application_controller.rb | class ApplicationController < ActionController::API
end
| ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/ranking/app/models/game.rb | examples/ranking/app/models/game.rb | class Game < ApplicationRecord
end
| ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/ranking/app/models/play.rb | examples/ranking/app/models/play.rb | class Play < ApplicationRecord
belongs_to :game
self.primary_key = "created_at"
acts_as_hypertable
end
| ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/ranking/app/models/application_record.rb | examples/ranking/app/models/application_record.rb | class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
| ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
timescale/timescaledb-ruby | https://github.com/timescale/timescaledb-ruby/blob/e15cabd97d1b0901abedea39c4443386b305f184/examples/ranking/db/seeds.rb | examples/ranking/db/seeds.rb | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# ... | ruby | MIT | e15cabd97d1b0901abedea39c4443386b305f184 | 2026-01-04T17:50:22.541182Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.