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 |
|---|---|---|---|---|---|---|---|---|
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/app/controllers/sabisu_rails/explorer_controller.rb | app/controllers/sabisu_rails/explorer_controller.rb | module SabisuRails
class ExplorerController < SabisuRails::BaseController
def index
@resources = SabisuRails.resources_names
@explorer = SabisuRails::Explorer.new(params[:explorer] || {})
@response = SabisuRails::Request.new(@explorer, params[@explorer.resource_name], params[:explorer]).respons... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/app/controllers/sabisu_rails/application_controller.rb | app/controllers/sabisu_rails/application_controller.rb | module SabisuRails
class ApplicationController < ActionController::Base
end
end | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails.rb | lib/sabisu_rails.rb | require 'httparty'
module SabisuRails
extend ActiveSupport::Autoload
autoload :Client
autoload :Request
autoload :RouteRecognizer
autoload :Explorer
autoload :Helpers
autoload :Builders
# We ignore some attribues that might cause a collision between models
@@default_ignored_attributes = %w{ created... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/generators/sabisu_rails/install_generator.rb | lib/generators/sabisu_rails/install_generator.rb | module SabisuRails
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
desc "Creates a Sabisu initializer in your application"
def copy_initializer
template "sabisu_rails.rb", "config/initializers/sabisu_rails.rb"
... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/generators/sabisu_rails/templates/sabisu_rails.rb | lib/generators/sabisu_rails/templates/sabisu_rails.rb | # Use this module to configure the sabisu available options
SabisuRails.setup do |config|
# Base uri for posting the
# config.base_api_uri = nil
# Ignored attributes for building the forms
# config.ignored_attributes = %w{ created_at updated_at id }
# HTTP methods
# config.http_methods = %w{ GET POS... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/version.rb | lib/sabisu_rails/version.rb | module SabisuRails
VERSION = "0.0.2.beta"
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/builders.rb | lib/sabisu_rails/builders.rb | module SabisuRails
module Builders
autoload :Base, 'sabisu_rails/builders/base'
autoload :UrlParamsBuilder, 'sabisu_rails/builders/url_params_builder'
autoload :HeadersBuilder, 'sabisu_rails/builders/headers_builder'
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/helpers.rb | lib/sabisu_rails/helpers.rb | module SabisuRails
module Helpers
autoload :Required, 'sabisu_rails/helpers/required'
autoload :Type, 'sabisu_rails/helpers/type'
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/railtie.rb | lib/sabisu_rails/railtie.rb | require 'rails/railtie'
module SabisuRails
class Railtie < ::Rails::Railtie
config.eager_load_namespaces << SabisuRails
config.after_initialize do
SabisuRails.default_resource = SabisuRails.resources_names.first
SabisuRails.app_name = Rails.application.class.parent_name
end
config.after... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/client.rb | lib/sabisu_rails/client.rb | module SabisuRails
module Client
module ClassMethods
def setup_client
base_uri SabisuRails.base_api_uri
headers SabisuRails.api_headers
headers "Content-Type" => "application/#{SabisuRails.api_format}"
basic_auth SabisuRails.basic_auth_username, SabisuRails.basic_auth_passwo... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/request.rb | lib/sabisu_rails/request.rb | module SabisuRails
class Request
include HTTParty
extend SabisuRails::Client::ClassMethods
setup_client
def initialize(explorer, body_params, params)
@explorer = explorer
@body_params = body_params || {}
@params = params || {}
@headers = SabisuRails::Builders::HeadersBuilder.... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/engine.rb | lib/sabisu_rails/engine.rb | module SabisuRails
class Engine < Rails::Engine
isolate_namespace SabisuRails
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/route_recognizer.rb | lib/sabisu_rails/route_recognizer.rb | module SabisuRails
class RouteRecognizer
attr_reader :paths
# Based on @bantic solution - https://gist.github.com/bantic/5688232#file-rails_route_recognizer-rb
# To use this inside your app, call:
# `RouteRecognizer.new.initial_path_segments`
# This returns an array, e.g.: ['assets','blog','team'... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/explorer.rb | lib/sabisu_rails/explorer.rb | module SabisuRails
class Explorer
include SabisuRails::Helpers::Required
include SabisuRails::Helpers::Type
attr_reader :resource, :uri_pattern, :http_method
def initialize(attrs = {})
@resource = attrs[:resource] || SabisuRails.default_resource
@uri_pattern = attrs[:uri_pattern]
... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/helpers/type.rb | lib/sabisu_rails/helpers/type.rb | module SabisuRails
module Helpers
module Type
def column_type(col)
columns.select { |column| column[0] == col }.flatten[1]
end
def columns
@columns ||= resource_class.columns.map{|c| [c.name, c.type] }
end
end
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/helpers/required.rb | lib/sabisu_rails/helpers/required.rb | module SabisuRails
module Helpers
module Required
def required_attribute?(attr)
required_attributes.include? attr.to_sym
end
def required_attributes
@required_attributes ||= resource_class.validators.map(&:attributes).flatten.uniq
end
end
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/builders/url_params_builder.rb | lib/sabisu_rails/builders/url_params_builder.rb | module SabisuRails
module Builders
class UrlParamsBuilder < SabisuRails::Builders::Base
end
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/builders/base.rb | lib/sabisu_rails/builders/base.rb | module SabisuRails
module Builders
class Base
def initialize(params)
@params = params || {}
sanitize_params
end
def build
query_params = {}
@sanitized_params.each do |k,v|
values = v.values #returns the nested hash, and we get the values from that has... | ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/lib/sabisu_rails/builders/headers_builder.rb | lib/sabisu_rails/builders/headers_builder.rb | module SabisuRails
module Builders
class HeadersBuilder < SabisuRails::Builders::Base
end
end
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
kurenn/sabisu-rails | https://github.com/kurenn/sabisu-rails/blob/e55dfbd679ac3ec2401178d5f809773f09373bcf/config/routes.rb | config/routes.rb | SabisuRails::Engine.routes.draw do
get "explorer", to: "explorer#index"
end
| ruby | MIT | e55dfbd679ac3ec2401178d5f809773f09373bcf | 2026-01-04T17:52:02.123775Z | false |
dungbanguyen/adminlte-rails | https://github.com/dungbanguyen/adminlte-rails/blob/586dd13a68cdb557fe811cec95819f6401bd59c3/lib/adminlte-rails.rb | lib/adminlte-rails.rb | require 'adminlte-rails/version'
module AdminLTE
module Rails
require 'adminlte-rails/engine'
end
end
| ruby | MIT | 586dd13a68cdb557fe811cec95819f6401bd59c3 | 2026-01-04T17:51:54.930115Z | false |
dungbanguyen/adminlte-rails | https://github.com/dungbanguyen/adminlte-rails/blob/586dd13a68cdb557fe811cec95819f6401bd59c3/lib/adminlte-rails/version.rb | lib/adminlte-rails/version.rb | module AdminLTE
module Rails
VERSION = '2.3.2'
end
end
| ruby | MIT | 586dd13a68cdb557fe811cec95819f6401bd59c3 | 2026-01-04T17:51:54.930115Z | false |
dungbanguyen/adminlte-rails | https://github.com/dungbanguyen/adminlte-rails/blob/586dd13a68cdb557fe811cec95819f6401bd59c3/lib/adminlte-rails/engine.rb | lib/adminlte-rails/engine.rb | module AdminLTE
module Rails
class Engine < ::Rails::Engine
end
end
end
| ruby | MIT | 586dd13a68cdb557fe811cec95819f6401bd59c3 | 2026-01-04T17:51:54.930115Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/test/stress.rb | test/stress.rb | #!/usr/bin/env ruby
require 'bundler/setup'
require 'traffic_jam'
require 'json'
require 'redis'
require 'optparse'
options = {
forks: 30,
actions: 1000,
keys: 5,
limit: 100,
redis_uri: 'redis://127.0.0.1:6379',
strategy: 'Limit'
}
OptionParser.new do |opts|
opts.banner = "Usage: #{__FILE__} <OPTIONS>"... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam_configuration_spec.rb | spec/traffic_jam_configuration_spec.rb | require_relative 'spec_helper'
describe TrafficJam do
include RedisHelper
let(:config) { TrafficJam::Configuration.new }
before { config.register(:test, 3, 60) }
describe 'constructor' do
it "should take default options" do
config = TrafficJam::Configuration.new(key_prefix: 'hello')
assert_e... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam_spec.rb | spec/traffic_jam_spec.rb | require_relative 'spec_helper'
describe TrafficJam do
include RedisHelper
TrafficJam.configure do |config|
config.redis = RedisHelper.redis
config.register(:test, 3, 60)
config.register(:test4, 4, 60)
end
let(:value) { "user1" }
describe '::limit' do
it "should return limit instance with r... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam_limit_group_spec.rb | spec/traffic_jam_limit_group_spec.rb | require_relative 'spec_helper'
describe TrafficJam do
include RedisHelper
TrafficJam.configure do |config|
config.redis = RedisHelper.redis
end
let(:limit1) do
TrafficJam::Limit.new(:test, "user1", max: 3, period: 60 * 60)
end
let(:limit2) do
TrafficJam::Limit.new(:test, "user2", max: 2, peri... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam_limit_spec.rb | spec/traffic_jam_limit_spec.rb | require_relative 'spec_helper'
describe TrafficJam do
include RedisHelper
TrafficJam.configure do |config|
config.redis = RedisHelper.redis
end
let(:period) { 60 * 60 }
let(:limit) do
TrafficJam::Limit.new(:test, "user1", max: 3, period: 60 * 60)
end
describe :initialize do
it 'should rais... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/spec_helper.rb | spec/spec_helper.rb | require 'redis'
require 'timecop'
require 'simplecov'
require 'minitest/autorun'
require 'spy/integration'
SimpleCov.start :test_frameworks
if ENV['CI']
require 'coveralls'
Coveralls.wear!
end
require 'traffic_jam'
module RedisHelper
@@redis = Redis.new(url: ENV['REDIS_URI'] || 'redis://localhost:6379')
de... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam/lifetime_limit_spec.rb | spec/traffic_jam/lifetime_limit_spec.rb | require_relative '../spec_helper'
describe TrafficJam::RollingLimit do
include RedisHelper
TrafficJam.configure do |config|
config.redis = RedisHelper.redis
end
let(:max) { 3 }
let(:limit) do
TrafficJam::LifetimeLimit.new(:test, 'user1', max: max)
end
after do
Spy.teardown
end
describ... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam/gcra_limit_spec.rb | spec/traffic_jam/gcra_limit_spec.rb | require_relative '../spec_helper'
describe TrafficJam do
include RedisHelper
TrafficJam.configure do |config|
config.redis = RedisHelper.redis
end
let(:period) { 0.1 }
let(:limit) do
TrafficJam::GCRALimit.new(:test, "user1", max: 3, period: period)
end
describe :increment do
after do
... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/spec/traffic_jam/rolling_limit_spec.rb | spec/traffic_jam/rolling_limit_spec.rb | require_relative '../spec_helper'
describe TrafficJam::RollingLimit do
include RedisHelper
TrafficJam.configure do |config|
config.redis = RedisHelper.redis
end
let(:max) { 3 }
let(:limit) do
TrafficJam::RollingLimit.new(:test, 'user1', max: max, period: period)
end
after do
Spy.teardown
... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam.rb | lib/traffic_jam.rb | require 'ostruct'
require 'digest/md5'
require_relative 'traffic_jam/configuration'
require_relative 'traffic_jam/errors'
require_relative 'traffic_jam/gcra_limit'
require_relative 'traffic_jam/lifetime_limit'
require_relative 'traffic_jam/limit'
require_relative 'traffic_jam/limit_group'
require_relative 'traffic_jam/... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/gcra_limit.rb | lib/traffic_jam/gcra_limit.rb | require_relative 'limit'
require_relative 'scripts'
module TrafficJam
# GCRA (Generic Cell Rate Algorithm) is a leaky bucket type rate limiting
# algorithm. GCRA works by storing a key in Redis with a ms-precision expiry
# representing the time that the limit will be completely reset. Each
# increment operatio... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/limit.rb | lib/traffic_jam/limit.rb | require_relative 'scripts'
module TrafficJam
# This class represents a rate limit on an action, value pair. For example, if
# rate limiting the number of requests per IP address, the action could be
# +:requests+ and the value would be the IP address. The class exposes atomic
# increment operations and allows ... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/errors.rb | lib/traffic_jam/errors.rb | module TrafficJam
module Errors
class LimitNotFound < StandardError; end
class LimitExceededError < StandardError
attr_accessor :limit
def initialize(limit)
super("Rate limit exceeded: #{limit.action}")
@limit = limit
end
end
class InvalidKeyError < StandardError; ... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/scripts.rb | lib/traffic_jam/scripts.rb | require 'digest/sha1'
module TrafficJam
module Scripts
def self.load(name)
scripts_dir = File.join(File.dirname(__FILE__), '..', '..', 'scripts')
File.read(File.join(scripts_dir, "#{name}.lua"))
end
private_class_method :load
INCREMENT_SCRIPT = load('increment')
INCREMENT_SCRIPT_HASH... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/rolling_limit.rb | lib/traffic_jam/rolling_limit.rb | require_relative 'scripts'
module TrafficJam
# This class represents a rolling limit on an action, value pair. For example,
# if limiting the amount of money a user can transfer in a week, the action
# could be +:transfers+ and the value would be the user ID. The class exposes
# atomic increment operations and... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/lifetime_limit.rb | lib/traffic_jam/lifetime_limit.rb | module TrafficJam
# This class represents a lifetime limit on an action, value pair. For example, if
# limiting the amount of money a user can transfer, the action could be
# +:transfers+ and the value would be the user ID. The class exposes atomic
# increment operations and allows querying of the current amoun... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/configuration.rb | lib/traffic_jam/configuration.rb | module TrafficJam
# Configuration for TrafficJam library.
#
# @see TrafficJam#configure
class Configuration
OPTIONS = %i( key_prefix hash_length redis )
# @!attribute redis
# @return [Redis] the connected Redis client the library uses
# @!attribute key_prefix
# @return [String] the pref... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
coinbase/traffic_jam | https://github.com/coinbase/traffic_jam/blob/2b90aa596fdb384086a5a39a203effed14a01756/lib/traffic_jam/limit_group.rb | lib/traffic_jam/limit_group.rb | module TrafficJam
# A limit group is a way of enforcing a cap over a set of limits with the
# guarantee that either all limits will be incremented or none. This is useful
# if you must check multiple limits before allowing an action to be taken.
# Limit groups can contain other limit groups.
class LimitGroup
... | ruby | MIT | 2b90aa596fdb384086a5a39a203effed14a01756 | 2026-01-04T17:52:08.574256Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/spec/gastly_spec.rb | spec/gastly_spec.rb | require 'spec_helper'
describe Gastly do
let(:url) { 'http://google.com' }
context '#screenshot' do
it 'returns an instance of Gastly::Screenshot' do
expect(Gastly.screenshot(url, timeout: 1000)).to be_instance_of Gastly::Screenshot
end
end
context '#capture' do
it 'creates a screenshot' do... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/spec/phantomjs_spec.rb | spec/phantomjs_spec.rb | require 'spec_helper'
describe Phantomjs do
it { expect(Phantomjs).to respond_to(:proxy_host) }
it { expect(Phantomjs).to respond_to(:proxy_port) }
end
| ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/spec/spec_helper.rb | spec/spec_helper.rb | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'gastly'
require 'coveralls'
Coveralls.wear!
RSpec.configure do |config|
config.before(:suite) do
Phantomjs.implode!
Phantomjs.path
end
end
| ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/spec/gastly/screenshot_spec.rb | spec/gastly/screenshot_spec.rb | require 'spec_helper'
RSpec.describe Gastly::Screenshot do
let(:url) { 'http://google.com' }
let(:params) do
{
selector: '#hplogo',
browser_width: 1280,
browser_height: 780,
timeout: 1000,
cookies: { user_id: 1, auth_token: 'abcd' },
proxy... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/spec/gastly/image_spec.rb | spec/gastly/image_spec.rb | require 'spec_helper'
RSpec.describe Gastly::Image do
let(:image) { MiniMagick::Image.new('test.png') }
subject { Gastly::Image.new(image) }
context '#resize' do
it 'invokes method #resize with arguments' do
width, height = 100, 100
expect_any_instance_of(MiniMagick::Image).to receive(:resize).w... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly.rb | lib/gastly.rb | require 'phantomjs'
require 'mini_magick'
require_relative 'gastly/utils'
require_relative 'gastly/phantomjs_patch'
require_relative 'gastly/image'
require_relative 'gastly/screenshot'
require_relative 'gastly/exceptions'
require_relative 'gastly/version'
module Gastly
def screenshot(url, **kwargs)
Screenshot.n... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/version.rb | lib/gastly/version.rb | module Gastly
VERSION = '1.1.0'
end
| ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/phantomjs_patch.rb | lib/gastly/phantomjs_patch.rb | module Phantomjs
class << self
attr_accessor :proxy_host, :proxy_port
end
class Platform
RETRY_COUNT = 5
class << self
def install!
STDERR.puts "Phantomjs does not appear to be installed in #{phantomjs_path}, installing!"
FileUtils.mkdir_p Phantomjs.base_dir
# Purge te... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/exceptions.rb | lib/gastly/exceptions.rb | module Gastly
class FetchError < StandardError
def initialize(url)
super("Unable to load #{url}")
end
end
PhantomJSError = Class.new(RuntimeError)
UnknownError = Class.new(RuntimeError)
end
| ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/utils.rb | lib/gastly/utils.rb | require_relative 'utils/hash'
require_relative 'utils/string'
| ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/screenshot.rb | lib/gastly/screenshot.rb | module Gastly
class Screenshot
SCRIPT_PATH = File.expand_path('../script.js', __FILE__)
DEFAULT_TIMEOUT = 0
DEFAULT_BROWSER_WIDTH = 1440
DEFAULT_BROWSER_HEIGHT = 900
DEFAULT_FILE_FORMAT = '.png'.freeze
attr_reader :image
attr_writer :timeout, :browser_width, :browser_height
attr_acces... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/image.rb | lib/gastly/image.rb | module Gastly
class Image
attr_reader :image
# @param image [MiniMagick::Image] Instance of MiniMagick::Image
def initialize(image)
@image = image
end
# @param width [Fixnum] Image width
# @param height [Fixnum] Image height
def resize(width:, height:)
dimensions = "#{width}x... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/utils/string.rb | lib/gastly/utils/string.rb | module Gastly
module Utils
class String
BLANK_RE = /\A[[:space:]]*\z/
attr_reader :string
def initialize(string = '')
@string = string.to_s
end
# A string is blank if it's empty or contains whitespaces only:
#
# ''.blank? # => true
# ' '.blank... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
mgrachev/gastly | https://github.com/mgrachev/gastly/blob/f4d894d7fcb234506cf59a971d92783a28ca2ff1/lib/gastly/utils/hash.rb | lib/gastly/utils/hash.rb | module Gastly
module Utils
class Hash
attr_reader :hash
def initialize(hash = {})
@hash = hash.to_h
end
# Validates all keys in a hash match <tt>*valid_keys</tt>, raising
# +ArgumentError+ on a mismatch.
#
# Note that keys are treated differently than HashWithIn... | ruby | MIT | f4d894d7fcb234506cf59a971d92783a28ca2ff1 | 2026-01-04T17:52:09.186283Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi_spec.rb | spec/nandi_spec.rb | # frozen_string_literal: true
require "nandi/migration"
RSpec.describe Nandi do
let(:renderer) do
Class.new(Object) do
def self.generate(migration); end
end
end
before do
# Test default single-database behavior
allow_any_instance_of(Nandi::Lockfile).to receive(:persist!)
end
describe... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require "bundler/setup"
require "pathname"
require "nandi"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.dis... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/generators/nandi/foreign_key_generator_spec.rb | spec/generators/nandi/foreign_key_generator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "generators/nandi/foreign_key/foreign_key_generator"
RSpec.describe Nandi::ForeignKeyGenerator do
let(:generator) { described_class.new(%w[posts users]) }
before do
# Reset Nandi configuration
Nandi.instance_variable_set(:@config, nil)
# Mo... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/generators/nandi/migration_generator_spec.rb | spec/generators/nandi/migration_generator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "generators/nandi/migration/migration_generator"
RSpec.describe Nandi::MigrationGenerator do
let(:generator) { described_class.new(["add_users_table"]) }
before do
# Reset Nandi configuration
Nandi.instance_variable_set(:@config, nil)
# Moc... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/generators/nandi/index_generator_spec.rb | spec/generators/nandi/index_generator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "generators/nandi/index/index_generator"
RSpec.describe Nandi::IndexGenerator do
let(:generator) { described_class.new(["users", "email,status"]) }
before do
# Reset Nandi configuration
Nandi.instance_variable_set(:@config, nil)
# Mock Rail... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/generators/nandi/compile_generator_spec.rb | spec/generators/nandi/compile_generator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "generators/nandi/compile/compile_generator"
RSpec.describe Nandi::CompileGenerator do
let(:generator) { described_class.new }
let(:temp_dir) { "/tmp/nandi_spec" }
before do
# Reset Nandi configuration before each test
Nandi.instance_variable_... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/migration_spec.rb | spec/nandi/migration_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/migration"
require "nandi/validator"
RSpec.describe Nandi::Migration do
let(:validator) { Nandi::Validator }
describe "name" do
subject(:migration) { MyAmazingClass.new(validator).name }
before do
stub_const("MyAmazingClass", Class... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/safe_migration_enforcer_spec.rb | spec/nandi/safe_migration_enforcer_spec.rb | # frozen_string_literal: true
require "nandi/safe_migration_enforcer"
RSpec.shared_examples "linting" do
let(:db_name) { nil } # Test default single-database behavior
context "when there are no files" do
let(:safe_migrations) { [] }
let(:ar_migrations) { [] }
it "returns true" do
expect(subjec... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/validator_spec.rb | spec/nandi/validator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/validator"
require "nandi/migration"
require "nandi/instructions"
RSpec.describe Nandi::Validator do
subject(:validator) { described_class.call(migration) }
let(:strictest_lock) { Nandi::Migration::LockWeights::SHARE }
let(:statement_timeout) {... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/multi_database_spec.rb | spec/nandi/multi_database_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/multi_database"
RSpec.describe Nandi::MultiDatabase do
subject(:multi_db) { described_class.new }
context "when no databases are registered" do
it "returns empty names array" do
expect(multi_db.names).to eq([])
end
it "raises e... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/formatting_spec.rb | spec/nandi/formatting_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/formatting"
RSpec.describe Nandi::Formatting do
describe "#format_value" do
subject(:result) do
subject_class.new.format_value(value, as_argument: with_as_argument)
end
let(:with_as_argument) { nil }
let(:subject_class) do
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/file_matcher_spec.rb | spec/nandi/file_matcher_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/file_matcher"
RSpec.describe Nandi::FileMatcher do
describe "::call" do
subject(:match) { described_class.call(files: files, spec: spec) }
let(:files) do
[
"20180402010101_do_thing_1.rb",
"20190101010101_do_thing_2.rb"... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/lockfile_spec.rb | spec/nandi/lockfile_spec.rb | # frozen_string_literal: true
require "tempfile"
RSpec.describe Nandi::Lockfile do
before do
described_class.clear_instances!
allow(Nandi.config).to receive(:lockfile_directory).and_return(temp_dir)
end
let(:database) { :primary }
let(:temp_dir) { Dir.mktmpdir }
let(:lockfile_contents) { "--- {}\n... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/compiled_migration_spec.rb | spec/nandi/compiled_migration_spec.rb | # frozen_string_literal: true
require "digest"
require "nandi/migration"
RSpec.describe Nandi::CompiledMigration do
let(:renderer) do
Class.new(Object) do
def self.generate(migration); end
end
end
let(:base_path) do
File.join(
File.dirname(__FILE__),
"/fixtures/example_migrations"... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/config_spec.rb | spec/nandi/config_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/config"
RSpec.describe Nandi::Config do
subject(:config) { described_class.new }
before do
Nandi.instance_variable_set(:@config, nil) # Reset config
config.lockfile_directory = "db"
end
context "multi-database integration" do
bef... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/validation/each_validator_spec.rb | spec/nandi/validation/each_validator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/validation/add_index_validator"
require "nandi/validation/remove_index_validator"
require "nandi/migration"
require "nandi/instructions"
RSpec.describe Nandi::Validation::EachValidator do
subject(:call) { described_class.call(instruction) }
descr... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/validation/add_index_validator_spec.rb | spec/nandi/validation/add_index_validator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/validation/add_index_validator"
require "nandi/migration"
require "nandi/instructions"
RSpec.describe Nandi::Validation::AddIndexValidator do
subject(:validator) { described_class.call(instruction) }
describe "with a hash index in the contained m... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/validation/timeout_validator_spec.rb | spec/nandi/validation/timeout_validator_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/validation/timeout_validator"
require "nandi/migration"
require "nandi/instructions"
RSpec.describe Nandi::Validation::TimeoutValidator do
subject(:validator) { described_class.call(migration) }
let(:statement_timeout) { 1_000 }
let(:lock_timeo... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/timeout_policies/access_exclusive_spec.rb | spec/nandi/timeout_policies/access_exclusive_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/migration"
require "nandi/timeout_policies"
require "nandi/timeout_policies/access_exclusive"
RSpec.describe Nandi::TimeoutPolicies::AccessExclusive do
describe "::validate" do
subject(:validate) { described_class.validate(migration) }
let(... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/instructions/add_index_spec.rb | spec/nandi/instructions/add_index_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/instructions/add_index"
RSpec.describe Nandi::Instructions::AddIndex do
let(:instance) do
described_class.new(
fields: fields,
table: table,
**extra_args,
)
end
let(:fields) { :foo }
let(:extra_args) { {} }
let(:ta... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/instructions/remove_index_spec.rb | spec/nandi/instructions/remove_index_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/instructions/remove_index"
RSpec.describe Nandi::Instructions::RemoveIndex do
let(:instance) { described_class.new(table: table, field: field) }
let(:table) { :widgets }
let(:field) { :foo }
describe "#table" do
let(:table) { :thingumyjig... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/example_migrations/20180104120000_my_invalid_index_migration.rb | spec/nandi/fixtures/example_migrations/20180104120000_my_invalid_index_migration.rb | # frozen_string_literal: true
class MyInvalidIndexMigration < Nandi::Migration
def up
add_index :payments, :foo, using: :gin
end
def down
remove_index :payments, :foo
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/example_migrations/20180104120000_my_invalid_migration.rb | spec/nandi/fixtures/example_migrations/20180104120000_my_invalid_migration.rb | # frozen_string_literal: true
class MyInvalidMigration < Nandi::Migration
def up
add_index :payments, :foo
add_index :payments, :bar
end
def down
remove_index :payments, :foo
remove_index :payments, :bar
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/example_migrations/20180104120001_create_my_table.rb | spec/nandi/fixtures/example_migrations/20180104120001_create_my_table.rb | # frozen_string_literal: true
class MyMigration < Nandi::Migration
def up
create_table :payments do |t|
t.column :payer, :string
t.column :ammount, :float
t.column :payed, :bool, default: false
end
end
def down
drop_table :payments
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/example_migrations/20180104120000_my_migration.rb | spec/nandi/fixtures/example_migrations/20180104120000_my_migration.rb | # frozen_string_literal: true
class MyMigration < Nandi::Migration
def up
add_index :payments, :foo
end
def down
remove_index :payments, :foo
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/irreversible_migration.rb | spec/nandi/fixtures/rendered/active_record/irreversible_migration.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
remove_column(
:payments,
:amount,
**{
}
)
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/validate_constraint.rb | spec/nandi/fixtures/rendered/active_record/validate_constraint.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
disable_lock_timeout!
disable_statement_timeout!
def up
execute <<-SQL
ALTER TABLE payments VALIDATE CONSTRAINT payments_mandates_fk
SQL
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_column.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_column.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
add_column(
:payments,
:foo,
:text,
**{
collate: :de_DE
}
)
end
def down
remove_column(
:payments,
:foo,
**{
cascade: true
}
)
end
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_table_with_extra_args.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_table_with_extra_args.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
create_table :payments, id: false, force: true do |t|
t.column :payer, :string
t.column :ammount, :float
t.column :payed, :bool, default: false
end
en... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_index.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_index.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
disable_lock_timeout!
disable_statement_timeout!
disable_ddl_transaction!
def up
add_index(
:payments,
[:foo, :bar],
**{
name: :idx_payments_on_foo_bar,
using: :btree,
algorithm: :concurrently
}
)
end
def down
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/remove_not_null_constraint.rb | spec/nandi/fixtures/rendered/active_record/remove_not_null_constraint.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
change_column_null :payments, :colours, true
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/custom_instruction_with_mixins.rb | spec/nandi/fixtures/rendered/active_record/custom_instruction_with_mixins.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
include My::Important::Mixin
include My::Other::Mixin
disable_lock_timeout!
disable_statement_timeout!
def up
new_method
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_reference.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_reference.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
add_reference(
:payments,
:mandate,
**{
index: false,
type: :text
}
)
end
def down
remove_reference(
:payments,
:mandate,
**{
}
)
e... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_index_timeouts.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_index_timeouts.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(5000)
disable_ddl_transaction!
def up
add_index(
:payments,
[:foo, :bar],
**{
name: :idx_payments_on_foo_bar,
using: :btree,
algorithm: :concurrently
}
)
end
def dow... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_table_with_timestamps.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_table_with_timestamps.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
create_table :payments do |t|
t.column :payer, :string
t.column :ammount, :float
t.column :payed, :bool, default: false
t.timestamps null: false
end
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_table.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_table.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
create_table :payments do |t|
t.column :payer, :string
t.column :ammount, :float
t.column :payed, :bool, default: false
end
end
def down
d... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/custom_instruction.rb | spec/nandi/fixtures/rendered/active_record/custom_instruction.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
disable_lock_timeout!
disable_statement_timeout!
def up
new_method
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/change_column_default.rb | spec/nandi/fixtures/rendered/active_record/change_column_default.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
change_column_default :payments, :colour, "blue"
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/custom_instruction_with_block.rb | spec/nandi/fixtures/rendered/active_record/custom_instruction_with_block.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
disable_lock_timeout!
disable_statement_timeout!
def up
new_method block rockin' beats
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/add_foreign_key.rb | spec/nandi/fixtures/rendered/active_record/add_foreign_key.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
add_foreign_key(
:payments,
:mandates,
**{
column: :zalgo_comes,
name: :payments_mandates_fk,
validate: false
}
)
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_table_with_timestamps_and_not_args.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_table_with_timestamps_and_not_args.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
create_table :payments do |t|
t.column :payer, :string
t.column :ammount, :float
t.column :payed, :bool, default: false
t.timestamps
end
end
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/create_and_drop_index_with_hash.rb | spec/nandi/fixtures/rendered/active_record/create_and_drop_index_with_hash.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
disable_lock_timeout!
disable_statement_timeout!
disable_ddl_transaction!
def up
add_index(
:payments,
[:foo, :bar],
**{
name: :idx_payments_on_foo_bar,
using: :hash,
algorithm: :concurrently
}
)
end
def down
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/add_check_constraint.rb | spec/nandi/fixtures/rendered/active_record/add_check_constraint.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
execute <<-SQL
ALTER TABLE payments
ADD CONSTRAINT check
CHECK (foo IS NOT NULL)
NOT VALID
SQL
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/fixtures/rendered/active_record/drop_constraint.rb | spec/nandi/fixtures/rendered/active_record/drop_constraint.rb | class MyAwesomeMigration < ActiveRecord::Migration[8.0]
set_lock_timeout(5000)
set_statement_timeout(1500)
def up
execute <<-SQL
ALTER TABLE payments DROP CONSTRAINT payments_mandates_fk
SQL
end
end
| ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
gocardless/nandi | https://github.com/gocardless/nandi/blob/bcacafc9bd79a08d4cb7f43e21a776f42d916de2/spec/nandi/renderers/active_record_spec.rb | spec/nandi/renderers/active_record_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "nandi/renderers/active_record"
require "nandi/migration"
require "nandi/validator"
RSpec.describe Nandi::Renderers::ActiveRecord do
describe "::generate" do
subject(:migration) do
described_class.generate(safe_migration.new(Nandi::Validator))
... | ruby | MIT | bcacafc9bd79a08d4cb7f43e21a776f42d916de2 | 2026-01-04T17:52:04.110442Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.