source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | spec/sync_runner_spec.rb | Ruby | mit | 180 | master | 2,464 | require 'spec_helper'
include RR
describe SyncRunner do
before(:each) do
end
it "should register itself with CommandRunner" do
CommandRunner.commands['sync'][:command].should == SyncRunner
CommandRunner.commands['sync'][:description].should be_an_instance_of(String)
end
it "prepare_table_pairs sho... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | spec/strange_name_support_spec.rb | Ruby | mit | 180 | master | 5,259 | require 'spec_helper'
include RR
describe "Unusual table and column name support" do
before(:each) do
Initializer.configuration = standard_config
end
it "should be able to insert, update and delete records" do
session = Session.new
session.left.begin_db_transaction
begin
select_row = Proc... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | spec/buffered_committer_spec.rb | Ruby | mit | 180 | master | 10,026 | require 'spec_helper'
include RR
describe Committers::BufferedCommitter do
before(:each) do
Initializer.configuration = standard_config
end
it "should register itself" do
Committers.committers[:buffered_commit].should == Committers::BufferedCommitter
end
# Stubs out the starting of transactions in... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/rep_config.rb | Ruby | mit | 180 | master | 643 | # Simple rubyrep configuration file.
# Intendet to be used for manual tests of the rubyrep commands.
#
# IMPORTANT:
# After completion of manual tests, use the 'db:test:rebuild' command to
# recreate the test databases.
# Otherwise the rspec tests will fail.
database = ENV['RR_TEST_DB'] ? ENV['RR_TEST_DB'] : :postgres... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/test_config.rb | Ruby | mit | 180 | master | 634 | # Simple rubyrep configuration file for use by rspec tests.
# Can be tweaked to either use mysql or postgresql.
#
# IMPORTANT:
# Due to configuration of committer :default will NOT work for manual running
# of rubyrep commands!
database = ENV['RR_TEST_DB'] ? ENV['RR_TEST_DB'] : :postgres
# $start_proxy_as_external_pro... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/postgres_config.rb | Ruby | mit | 180 | master | 569 | # Used as component of a rubyrep config file.
# Defines connection parameters to the postgresql databases.
RR::Initializer::run do |config|
config.left = {
:adapter => 'postgresql',
:database => 'rr_left',
:username => 'postgres',
:password => 'password',
:host => 'localhost',
:... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/hoe.rb | Ruby | mit | 180 | master | 2,462 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/rubyrep'
#require 'rubyrep/version'
AUTHOR = 'Arndt Lehmann' # can also be an array of Authors
EMAIL = "mail@arndtlehman.com"
DESCRIPTION = "Asynchronous master-master replication of relational databases."
GEM_NAME = 'rubyrep' # what ppl will type to install your g... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/mysql_config.rb | Ruby | mit | 180 | master | 633 | # Used as component of a rubyrep config file.
# Defines connection parameters to the mysql databases.
RR::Initializer::run do |config|
mysql_user = RUBY_PLATFORM == 'java' && 'root' || `whoami`.strip
config.left = {
:adapter => 'mysql2',
:database => 'rr_left',
:username => mysql_user,
:passw... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/proxied_test_config.rb | Ruby | mit | 180 | master | 285 | # Rubyrep configuration file.
# "Proxyfies" test_config.rb.
load File.dirname(__FILE__) + '/test_config.rb'
# $start_proxy_as_external_process = true
RR::Initializer::run do |config|
config.left.merge!({
:proxy_host => 'localhost',
:proxy_port => '9876',
})
end |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | config/redmine_config.rb | Ruby | mit | 180 | master | 479 | # Test configuration file for replication between two Redmine issue tracking
# systems
database = ENV['RR_TEST_DB'] ? ENV['RR_TEST_DB'] : :postgres
load File.dirname(__FILE__) + "/#{database}_config.rb"
RR::Initializer::run do |config|
config.left[:database] = 'leftmine'
config.right[:database] = 'rightmine'
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep.rb | Ruby | mit | 180 | master | 2,001 | $LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift File.dirname(__FILE__) + "/rubyrep"
require 'rubygems'
require 'yaml'
gem 'activerecord', '>= 4.2', '< 5'
require 'active_record'
require 'activerecord-jdbc-adapter' if RUBY_PLATFORM == 'java'
require 'ap'
require 'version'
require 'configuration'
require ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_runner.rb | Ruby | mit | 180 | master | 4,878 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'optparse'
require 'thread'
require 'monitor'
class Monitor
alias lock mon_enter
alias unlock mon_exit
end
module RR
# This class implements the functionality of the 'replicate' command.
class ReplicationRunner
CommandRunner.register 'replica... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/trigger_mode_switcher.rb | Ruby | mit | 180 | master | 2,132 | require 'set'
module RR
# Switches rubyrep triggers between "exclude rubyrep activity" modes.
class TriggerModeSwitcher
# Keeps track of all the triggers.
# This is a hash with 2 keys: :+left+ and :+right+.
# Each of these entries is a Set containing table names.
def triggers
@triggers ||= ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/proxy_row_cursor.rb | Ruby | mit | 180 | master | 1,130 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'digest/sha1'
require 'rubyrep'
module RR
# This class is used to scan a given table range
# Can return rows either themselves or only their checksum
class ProxyRowCursor < ProxyCursor
# The column_name => value hash of the current row.
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/generate_runner.rb | Ruby | mit | 180 | master | 2,736 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'optparse'
module RR
# This class implements the functionality of the 'generate' command.
class GenerateRunner
CONFIG_TEMPLATE = <<EOF
RR::Initializer::run do |config|
config.left = {
:adapter => 'postgresql', # or 'mysql2'
:database =>... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/table_sync.rb | Ruby | mit | 180 | master | 2,748 | module RR
# Synchronizes the data of two tables.
class TableSync < TableScan
# Instance of SyncHelper
attr_accessor :helper
# Returns a hash of sync options for this table sync.
def sync_options
@sync_options ||= session.configuration.options_for_table(left_table)
end
# Creat... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_initializer.rb | Ruby | mit | 180 | master | 12,468 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'rubyrep'
module RR
# Ensures all preconditions are met to start with replication
class ReplicationInitializer
# The active Session
attr_accessor :session
# Creates a new RepInititializer for the given Session
def initialize(session)
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/table_spec_resolver.rb | Ruby | mit | 180 | master | 5,629 | module RR
# Resolves table specifications as provided e. g. in the command line of rrscan
class TableSpecResolver
# The +Session+ instance from which the table specifications are resolved.
attr_accessor :session
# Returns the array of tables of the specified database. Caches the table array.
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/session.rb | Ruby | mit | 180 | master | 8,640 | require 'drb'
module RR
# This class represents a rubyrep session.
# Creates and holds expensive objects like e. g. database connections.
class Session
# The Configuration object provided to the initializer
attr_accessor :configuration
# Returns the "left" ActiveRecord / proxy database con... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/command_runner.rb | Ruby | mit | 180 | master | 3,875 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'optparse'
module RR
# This class implements the functionality to dispatch rubyrep commands.
class CommandRunner
# Returns a hash of all commands registered with #register.
def self.commands
@commands ||= {}
end
# Registers... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/proxied_table_scan.rb | Ruby | mit | 180 | master | 6,985 | module RR
# Scans two tables for differences. Goes through a RubyRep Proxy to minimize network load.
# Doesn't have any reporting functionality by itself.
# Instead ProxiedTableScan#run yields all the differences for the caller to do with as it pleases.
# Usage:
# 1. Create a new ProxiedTableScan object... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/sync_helper.rb | Ruby | mit | 180 | master | 4,041 | module RR
# Provides helper functionality for the table syncers.
# The methods exposed by this class are intended to provide a stable interface
# for third party syncers.
class SyncHelper
include LogHelper
# The current +TableSync+ instance
attr_accessor :table_sync
# The active +Session+
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/proxy_block_cursor.rb | Ruby | mit | 180 | master | 4,590 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'digest/sha1'
require 'rubyrep'
module RR
# This class is used to scan a table in blocks.
# Calculates the checksums of the scanned blocks.
class ProxyBlockCursor < ProxyCursor
include TableScanHelper
# The current Digest
attr_a... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/table_scan.rb | Ruby | mit | 180 | master | 2,014 | module RR
# Shared functionality for DirectTableScan and ProxiedTableScan
class TableScan
include TableScanHelper
# The current Session object
attr_accessor :session
# Name of the left table
attr_accessor :left_table
# Name of the right table
attr_accessor :right_table
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/base_runner.rb | Ruby | mit | 180 | master | 6,314 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'optparse'
module RR
# This class implements the base functionality for runners that process table
# specs.
class BaseRunner
# Default options if not overriden in command line
DEFAULT_OPTIONS = {
:table_specs => []
}
# Provide... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/scan_runner.rb | Ruby | mit | 180 | master | 739 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
module RR
# This class implements the functionality of the rrscan.rb command.
class ScanRunner < BaseRunner
CommandRunner.register 'scan' => {
:command => self,
:description => 'Scans for differing records between databases'
}
# Return... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/table_sorter.rb | Ruby | mit | 180 | master | 1,916 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'tsort'
require 'rubyrep'
module RR
# This class sorts a given list of tables so that tables referencing other
# tables via foreign keys are placed behind those referenced tables.
#
# Rationale:
# If tables are sorted in that sequence, the risk of fo... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_helper.rb | Ruby | mit | 180 | master | 5,145 | module RR
# Provides helper functionality for replicators.
# The methods exposed by this class are intended to provide a stable interface
# for third party replicators.
class ReplicationHelper
include LogHelper
# The current +ReplicationRun+ instance
attr_accessor :replication_run
# The acti... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_run.rb | Ruby | mit | 180 | master | 4,669 | require 'timeout'
module RR
# Executes a single replication run
class ReplicationRun
# The current Session object
attr_accessor :session
# The current TaskSweeper
attr_accessor :sweeper
# An array of ReplicationDifference which originally failed replication but should be tried one more ti... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_difference.rb | Ruby | mit | 180 | master | 3,284 | module RR
# Describes a (record specific) difference between both databases as identifed
# via change log.
class ReplicationDifference
# The current Session.
def session
@session ||= loaders.session
end
# The current LoggedChangeLoaders instance
attr_accessor :loaders
# The t... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/proxy_runner.rb | Ruby | mit | 180 | master | 2,432 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'optparse'
require 'drb'
module RR
# This class implements the functionality of the rrproxy.rb command.
class ProxyRunner
CommandRunner.register 'proxy' => {
:command => self,
:description => 'Proxies connections from rubyrep commands ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/database_proxy.rb | Ruby | mit | 180 | master | 1,395 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'drb'
require 'rubyrep'
module RR
# The proxy to a remote database connection
class DatabaseProxy
# Ensure that the proxy object always stays on server side and only remote
# references are returned to the client.
include DRbUndumped
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/task_sweeper.rb | Ruby | mit | 180 | master | 2,131 | module RR
# Monitors and cancels stalled tasks
class TaskSweeper
# Executes the give block in a separate Thread.
# Returns if block is finished or stalled.
# The block must call regular #ping to announce it is not stalled.
# * +timeout_period+:
# Maximum time (in seonds) without ping, after ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/logged_change.rb | Ruby | mit | 180 | master | 4,836 | module RR
# Describes a single logged record change.
#
# Note:
# The change loading functionality depends on the current database session
# being executed in an open database transaction.
# Also at the end of change processing the transaction must be committed.
class LoggedChange
# The current Lo... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/noisy_connection.rb | Ruby | mit | 180 | master | 1,968 | module RR
# Wraps an existing cursor.
# Purpose: send regular updates to the installed TaskSweeper
class NoisyCursor
# The original cusor
attr_accessor :org_cursor
# The installed task sweeper
attr_accessor :sweeper
# Create a new NoisyCursor.
# * cursor: the original cursor
# * swe... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/proxy_cursor.rb | Ruby | mit | 180 | master | 1,212 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'rubyrep'
module RR
# Provides shared functionality for ProxyRowCursor and ProxyBlockCursor
class ProxyCursor
# The current ProxyConnection.
attr_accessor :connection
# The name of the current table.
attr_accessor :table
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/table_scan_helper.rb | Ruby | mit | 180 | master | 1,684 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'rubyrep'
module RR
# Some helper functions that are of use to all TableScan classes
module TableScanHelper
# Compares the primary keys of left_row and right_row to determine their rank.
# Assumes there is a function primary_key_names returning ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/uninstall_runner.rb | Ruby | mit | 180 | master | 2,532 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'optparse'
module RR
# This class implements the functionality of the 'uninstall' command.
class UninstallRunner
CommandRunner.register 'uninstall' => {
:command => self,
:description => 'Removes all rubyrep tables, triggers, etc. from... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/sync_runner.rb | Ruby | mit | 180 | master | 926 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
module RR
# This class implements the functionality of the rrsync.rb command.
class SyncRunner < BaseRunner
CommandRunner.register 'sync' => {
:command => self,
:description => 'Syncs records between databases'
}
# Returns summary desc... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/logged_change_loader.rb | Ruby | mit | 180 | master | 6,095 | module RR
# Makes management of logged change loaders easier
class LoggedChangeLoaders
# The current Session
attr_accessor :session
# A hash of LoggedChangeLoader instances for the :+left+ and :+right+ database
attr_accessor :loaders
# Create new logged change loaders.
# * +session+: C... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/log_helper.rb | Ruby | mit | 180 | master | 1,073 | module RR
# Shared functionality for SyncHelper and LogHelper
module LogHelper
# Takes outcome and details and makes them fit (for available space) in the
# 'descrition' and 'long_description' columns of the event log.
# Parameters:
# * outcome: short description
# * details: long description
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/proxy_connection.rb | Ruby | mit | 180 | master | 15,950 | $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'drb'
require 'rubyrep'
require 'forwardable'
require 'active_record/connection_adapters/abstract_adapter'
module RR
# Enables the fetching of (potential large) result sets in chunks.
class ResultFetcher
# The current database ProxyConnection
a... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/initializer.rb | Ruby | mit | 180 | master | 1,069 | module RR
# The settings of the current deployment are passed to Rubyrep through the
# Initializer::run method.
# This method yields a Configuration object for overwriting of the default
# settings.
# Accordingly a configuration file should look something like this:
#
# Rubyrep::Initializer.run do |con... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/direct_table_scan.rb | Ruby | mit | 180 | master | 2,954 | module RR
# Scans two tables for differences.
# Doesn't have any reporting functionality by itself.
# Instead DirectTableScan#run yields all the differences for the caller to do with as it pleases.
# Usage:
# 1. Create a new DirectTableScan object and hand it all necessary information
# 2. Call Direct... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/configuration.rb | Ruby | mit | 180 | master | 11,921 | module RR
# The Configuration class holds the default configuration options for Rubyrep.
# Configuration values are changed with the Initializer::run method.
class Configuration
# Connection settings for the "left" database.
# See Configuration#right for details.
attr_accessor :left
# Connection... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/type_casting_cursor.rb | Ruby | mit | 180 | master | 1,172 | module RR
# Provides functionality to cast a query result value into the correct ruby type.
# Requires originating table and column to be known.
class TypeCastingCursor
# Delegate the uninteresting methods to the original cursor
def next?; org_cursor.next? end
def clear; org_cursor.clear end
def ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/scan_report_printers/scan_summary_reporter.rb | Ruby | mit | 180 | master | 2,755 | module RR::ScanReportPrinters
# A ScanReportPrinter producing a summary (number of differences) only.
class ScanSummaryReporter
# Register ScanSummaryReporter with the given command line options.
# (Command line format as specified by OptionParser#on.)
RR::ScanReportPrinters.register self, "-s", "-... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/scan_report_printers/scan_report_printers.rb | Ruby | mit | 180 | master | 2,492 | module RR
# Manages scan report printers. Scan report printers implement functionality
# to report the row differences identified during a scan.
# *All* table scans are processed by the *same* printer instance.
#
# Scan report printers need to register themselves and their command line options
# with #regis... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/scan_report_printers/scan_detail_reporter.rb | Ruby | mit | 180 | master | 3,544 | require 'fileutils'
require 'tmpdir'
require 'tempfile'
require 'yaml'
module RR::ScanReportPrinters
# A ScanReportPrinter producing a summary (number of differences) only.
class ScanDetailReporter < ScanSummaryReporter
# Register ScanSummaryReporter with the given command line options.
# (Command lin... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/committers/committers.rb | Ruby | mit | 180 | master | 6,120 | module RR
# Committers are classes that implement transaction policies.
# This module provides functionality to register committers and access the
# list of registered committers.
# Every Committer needs to register itself with Committers#register.
# Each Committer must implement at the following methods:
#... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/committers/buffered_committer.rb | Ruby | mit | 180 | master | 5,424 | module RR
module Committers
# This committer periodically commits transactions. It can be used for
# pre-replication syncs as it
# * updates the activity marker table.
# * switches existing triggers to filter out rubyrep activity
class BufferedCommitter < DefaultCommitter
# Register the co... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replicators/replicators.rb | Ruby | mit | 180 | master | 1,545 | module RR
# Replicators are classes that implement the replication policies.
# This module provides functionality to register replicators and access the
# list of registered replicators.
# Each Replicator must register itself with Replicators#register.
# Each Replicator must implement the following methods:
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replicators/two_way_replicator.rb | Ruby | mit | 180 | master | 17,292 | module RR
module Replicators
# This replicator implements a two way replication.
# Options:
# * :+left_change_handling+, :+right_change_handling+:
# Handling of records that were changed only in the named database.
# Can be any of the following:
# * :+ignore+: No action.
# * :+repl... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/syncers/two_way_syncer.rb | Ruby | mit | 180 | master | 7,692 | module RR
module Syncers
# This syncer implements a two way sync.
# Syncer options relevant for this syncer:
# * :+left_record_handling+, :+right_record_handling+:
# Handling of records only existing only in the named database.
# Can be any of the following:
# * :+ignore+: No action.
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/syncers/syncers.rb | Ruby | mit | 180 | master | 4,118 | module RR
# Syncers are classes that implement the sync policies.
# This module provides functionality to register syncers and access the
# list of registered syncers.
# Each Syncer must register itself with Syncers#register.
# Each Syncer must implement the following methods:
#
# # Creates a new syncer... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_extenders/postgresql_replication.rb | Ruby | mit | 180 | master | 10,253 | module RR
module ReplicationExtenders
# Provides PostgreSQL specific functionality for database replication
module PostgreSQLReplication
RR::ReplicationExtenders.register :postgresql => self
# Returns the key clause that is used in the trigger function.
# * +trigger_var+: should be either ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_extenders/replication_extenders.rb | Ruby | mit | 180 | master | 872 | module RR
# Replication extenders are modules that provide database specific functionality
# required for replication. They are mixed into ActiveRecord database connections.
# This module itself only provides functionality to register and retrieve
# such extenders.
module ReplicationExtenders
# Returns a... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/replication_extenders/mysql_replication.rb | Ruby | mit | 180 | master | 11,829 | module RR
module ReplicationExtenders
# Provides Mysql specific functionality for database replication
module MysqlReplication
RR::ReplicationExtenders.register :mysql2 => self
# Creates or replaces the replication trigger function.
# See #create_replication_trigger for a descriptions of t... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/connection_extenders/postgresql_extender.rb | Ruby | mit | 180 | master | 5,315 | require 'time'
module RR
module ConnectionExtenders
# Provides various PostgreSQL specific functionality required by Rubyrep.
module PostgreSQLExtender
RR::ConnectionExtenders.register :postgresql => self
# Returns an array of schemas in the current search path.
def schemas
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/connection_extenders/mysql_extender.rb | Ruby | mit | 180 | master | 2,907 | module RR
module ConnectionExtenders
# Provides various MySQL specific functionality required by Rubyrep.
module MysqlExtender
RR::ConnectionExtenders.register :mysql2 => self
# Returns an ordered list of primary key column names of the given table
def primary_key_names(table)
row... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/connection_extenders/connection_extenders.rb | Ruby | mit | 180 | master | 5,783 | class ActiveRecord::ConnectionAdapters::AbstractAdapter
# The current log subscriber
attr_accessor :log_subscriber
end
module RR
# Connection extenders provide additional database specific functionality
# not coming in the ActiveRecord library.
# This module itself only provides functionality to register ... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/scan_progress_printers/scan_progress_printers.rb | Ruby | mit | 180 | master | 2,461 | module RR
# Manages scan progress printers. Scan progress printers implement functionality
# to report the progress of a table scan.
# *Each* table scan is handled by a *separate* printer instance.
#
# Scan progress printers need to register themselves and their command line options
# with #register.
#
... |
github | rubyrep/rubyrep | https://github.com/rubyrep/rubyrep | lib/rubyrep/scan_progress_printers/progress_bar.rb | Ruby | mit | 180 | master | 2,532 | module RR
module ScanProgressPrinters
# A helper class to print a text progress bar.
class ProgressBar
MAX_MARKERS = 25 #length of the progress bar (in characters)
# Register ProgressBar with the given command line options.
# (Command line format as specified by OptionParser#on.)
... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | gems.rb | Ruby | mit | 181 | main | 391 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2012-2025, by Samuel Williams.
source "https://rubygems.org"
gemspec
group :maintenance, optional: true do
gem "bake-gem"
gem "bake-modernize"
gem "utopia-project"
end
group :test do
gem "sus"
gem "covered"
gem "decode"
gem "rubo... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | relaxo.gemspec | Ruby | mit | 181 | main | 818 | # frozen_string_literal: true
require_relative "lib/relaxo/version"
Gem::Specification.new do |spec|
spec.name = "relaxo"
spec.version = Relaxo::VERSION
spec.summary = "Relaxo is versioned document database built on top of git."
spec.authors = ["Samuel Williams", "Huba Nagy", "Olle Jonsson"]
spec.license = "MI... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | test/relaxo.rb | Ruby | mit | 181 | main | 614 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2025, by Samuel Williams.
require "relaxo/test_records"
describe Relaxo do
with ".connect" do
include Relaxo::TemporaryDatabase
it "can connect to a new database" do
expect(database).to be_a Relaxo::Database
expect(database.br... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | test/relaxo/database.rb | Ruby | mit | 181 | main | 3,247 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2012-2025, by Samuel Williams.
# Copyright, 2017, by Huba Nagy.
require "relaxo"
require "relaxo/test_records"
describe Relaxo::Database do
include_context Relaxo::TemporaryDatabase
let(:document_path) {"test/document.json"}
let(:sampl... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | test/relaxo/concurrency.rb | Ruby | mit | 181 | main | 839 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2017-2025, by Samuel Williams.
require "relaxo/test_records"
describe Relaxo::Changeset do
include_context Relaxo::TestRecords
it "should detect conflicts" do
events = []
alice = Fiber.new do
database.commit(message: "Alice Da... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | test/relaxo/enumeration.rb | Ruby | mit | 181 | main | 675 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2017-2025, by Samuel Williams.
require "relaxo/test_records"
describe Relaxo::Dataset do
include_context Relaxo::TestRecords
it "should enumerate all documents" do
records = []
database.current do |dataset|
records = dataset.e... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | test/relaxo/changeset.rb | Ruby | mit | 181 | main | 1,407 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2017-2025, by Samuel Williams.
require "relaxo/test_records"
describe Relaxo::Changeset do
include_context Relaxo::TestRecords
it "should enumerate all documents including writes" do
records = []
database.commit(message: "Testing... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | benchmarks/performance.rb | Ruby | mit | 181 | main | 1,899 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2017-2025, by Samuel Williams.
require "benchmark/ips" if ENV["BENCHMARK"]
require "ruby-prof" if ENV["PROFILE"]
require "flamegraph" if ENV["FLAMEGRAPH"]
describe "Relaxo Performance" do
let(:database_path) {File.join(__dir__, "test")}
l... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | lib/relaxo.rb | Ruby | mit | 181 | main | 1,366 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2012-2025, by Samuel Williams.
require "relaxo/database"
require "etc"
require "socket"
module Relaxo
DEFAULT_BRANCH = "main".freeze
def self.connect(path, branch: nil, sync: nil, create: true, **metadata)
if !File.exist?(path) || cr... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | lib/relaxo/database.rb | Ruby | mit | 181 | main | 3,254 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2012-2025, by Samuel Williams.
# Copyright, 2017, by Huba Nagy.
require "rugged"
require_relative "logger"
require_relative "dataset"
require_relative "changeset"
module Relaxo
HEAD = "HEAD".freeze
class Database
def initialize(path,... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | lib/relaxo/changeset.rb | Ruby | mit | 181 | main | 1,308 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2012-2025, by Samuel Williams.
require_relative "dataset"
module Relaxo
class Changeset < Dataset
def initialize(repository, tree)
super
@changes = {}
@directories = {}
end
attr :ref
attr :changes
def changes?
... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | lib/relaxo/dataset.rb | Ruby | mit | 181 | main | 1,018 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2012-2025, by Samuel Williams.
require "rugged"
require_relative "directory"
module Relaxo
class Dataset
def initialize(repository, tree)
@repository = repository
@tree = tree
@directories = {}
end
def read(path)
... |
github | ioquatix/relaxo | https://github.com/ioquatix/relaxo | lib/relaxo/directory.rb | Ruby | mit | 181 | main | 1,847 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2017-2025, by Samuel Williams.
require "rugged"
module Relaxo
class Directory
def initialize(repository, root_tree, path)
@repository = repository
# The root tree, which path is relative to:
@root_tree = root_tree
# T... |
github | auth0/cxn | https://github.com/auth0/cxn | metadata.rb | Ruby | mit | 180 | master | 481 | name 'cxn'
maintainer 'Jose F. Romaniello'
maintainer_email 'jose@auth0.com'
license 'Apache 2.0'
description 'Installs/Configures kibana'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.0.1'
depends 'apt'
depends 'ohai'
depends 'newrelic'
depends 'rsyslog'
depends 'build-essential'... |
github | auth0/cxn | https://github.com/auth0/cxn | Gemfile | Ruby | mit | 180 | master | 408 | source 'https://rubygems.org'
gem 'berkshelf'
# Uncomment these lines if you want to live on the Edge:
#
# group :development do
# gem "berkshelf", github: "berkshelf/berkshelf"
# gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3"
# end
#
# group :plugins do
# gem "vagrant-berkshelf", github: "berkshelf/... |
github | auth0/cxn | https://github.com/auth0/cxn | Vagrantfile | Ruby | mit | 180 | master | 3,741 | # -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
require 'json'
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version '>= 1.5.0'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common... |
github | auth0/cxn | https://github.com/auth0/cxn | attributes/varnish.rb | Ruby | mit | 180 | master | 2,068 | override['varnish']['parameters'] = {
"ban_lurker_sleep" => "0.01",
"ban_lurker_age" => "0.01"
}
override['varnish']['configure']['repo']['major_version'] = 4.1
override['varnish']['configure']['config']['listen_address'] = '0.0.0.0'
override['varnish']['configure']['config']['listen_port'] = 80
override['varnish'... |
github | auth0/cxn | https://github.com/auth0/cxn | attributes/default.rb | Ruby | mit | 180 | master | 583 | default['cxn']['purgers'] = {}
default['cxn']['nodes'] = {}
default['cxn']['domains'] = []
default['cxn']['siblings'] = {}
default['cxn']['varnish']['storage'] = 'malloc'
default['cxn']['varnish']['storage_size'] = '1g'
default['cxn']['newrelic'] = false
default['cxn']['logging'] = false
default['rsyslog']['conf_dir... |
github | auth0/cxn | https://github.com/auth0/cxn | attributes/nginx.rb | Ruby | mit | 180 | master | 922 | override['nginx']['default_site_enabled'] = false
override['nginx']['worker_processes'] = 2
override['nginx']['worker_connections'] = 20000
override['nginx']['gzip'] = 'off'
override['nginx']['server_tokens'] = 'off'
override['nginx']['keepalive_timeout'] = '10s'
override['nginx']['install_method'] = 'package'
overrid... |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/stunnel.rb | Ruby | mit | 180 | master | 314 | package 'stunnel'
service "stunnel" do
service_name "stunnel4"
supports :restart => true
action [:enable, :start]
end
remote_directory '/etc/stunnel' do
source 'stunnel'
end
template "#{node['stunnel']['conf_dir']}/stunnel4" do
source 'stunnel/stunnel4.erb'
notifies :restart, 'service[stunnel]'
end |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/varnish.rb | Ruby | mit | 180 | master | 375 | include_recipe 'varnish::configure'
logrotate_app 'varnish' do
cookbook 'logrotate'
frequency 'hourly'
path '/var/log/varnish/varnishlog.log'
options ['missingok', 'compress', 'notifempty', 'delaycompress']
rotate 10
su 'root'
size '200M'
postrotate ' /bin/kill -HUP `cat /var/run... |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/hostname.rb | Ruby | mit | 180 | master | 353 | file '/etc/hostname' do
content node.name
end
execute "hostname #{node.name}" do
not_if "hostname -eq \"#{node.name}\""
end
hostsfile_entry '127.0.1.1' do
hostname "#{node.name}.cdn.auth0"
aliases [node.name]
end
node['cxn']['nodes'].sort.each do |host, ip|
next if host == node.name
hostsfile_entry ip... |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/rsyslog.rb | Ruby | mit | 180 | master | 419 | service "rsyslog" do
provider Chef::Provider::Service::Upstart
supports :restart => true
action [:enable, :start]
end
template "#{node['rsyslog']['conf_dir']}/10-udp_listener.conf" do
source 'rsyslog/10-udp_listener.conf.erb'
notifies :restart, 'service[rsyslog]'
end
template "#{node['rsyslog']['conf_dir']}... |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/default.rb | Ruby | mit | 180 | master | 279 | include_recipe 'cxn::nginx'
include_recipe 'cxn::varnish'
include_recipe 'cxn::newrelic'
include_recipe 'cxn::hostname'
include_recipe 'cxn::sysctl'
include_recipe 'cxn::ntp'
if node['cxn']['logging'] then
include_recipe 'cxn::stunnel'
include_recipe 'cxn::rsyslog'
end |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/nginx.rb | Ruby | mit | 180 | master | 2,831 | if node['cxn']['logging'] then
node.set['nginx']['access_log'] = [
'/var/log/nginx/access.log acc_log',
"syslog:server=#{node['rsyslog']['host']}:#{node['rsyslog']['port']} acc_log"
]
else
node.set['nginx']['access_log'] = [
'/var/log/nginx/access.log acc_log'
]
end
include_recipe 'ng... |
github | auth0/cxn | https://github.com/auth0/cxn | recipes/sysctl.rb | Ruby | mit | 180 | master | 919 | include_recipe 'sysctl::default'
# Netflix defaults
# http://wiki.mikejung.biz/Sysctl_tweaks#Netflix_2014_EC2_sysctl_tweaks
sysctl_param 'vm.swappiness' do
value 20
end
sysctl_param 'vm.dirty_background_ratio' do
value 10
end
sysctl_param 'vm.dirty_ratio' do
value 40
end
sysctl_param 'net.core.somaxconn' do
... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | acts_as_relation.gemspec | Ruby | mit | 181 | master | 1,332 | # -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'active_record/acts_as_relation/version'
Gem::Specification.new do |s|
# Description Meta...
s.name = 'acts_as_relation'
s.version = ActiveRecord::ActsAsRelation::VERSION
s.platform = Gem::Platform::RUBY
s.a... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | lib/acts_as_relation.rb | Ruby | mit | 181 | master | 314 | require 'active_record/acts_as_relation'
require 'active_record/acts_as_relation/version'
require 'active_record/acts_as_relation/acts_as'
require 'active_record/acts_as_relation/access_methods'
require 'active_record/acts_as_relation/acts_as_modules'
require 'active_record/acts_as_relation/superclass_migration' |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | lib/active_record/acts_as_relation.rb | Ruby | mit | 181 | master | 1,966 | module ActiveRecord
module ActsAsRelation
extend ActiveSupport::Concern
included do
alias_method :acts_as?, :is_a?
end
module ClassMethods
def acts_as(model_name, scope = nil, options = {})
acts_as = ActsAs.new(model_name, scope, options)
include ActiveRecord::ActsAsRela... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | lib/active_record/acts_as_relation/access_methods.rb | Ruby | mit | 181 | master | 1,901 | module ActiveRecord
module ActsAsRelation
module AccessMethods
def define_acts_as_accessors(model_name)
# The weird order of the if-else branches is so that we query ourselves
# before we query our superclass.
class_eval <<-EndCode, __FILE__, __LINE__ + 1
def read_attribute... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | lib/active_record/acts_as_relation/superclass_migration.rb | Ruby | mit | 181 | master | 952 | module ActiveRecord
module ActsAsRelation
module SuperclassMigration
def self.included(base)
base.class_eval do
alias_method_chain :create_table, :as_relation_superclass
end
end
def create_table_with_as_relation_superclass(table_name, options = {})
create_table... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | lib/active_record/acts_as_relation/acts_as.rb | Ruby | mit | 181 | master | 1,216 | module ActiveRecord
module ActsAsRelation
class ActsAs
attr_accessor :module
attr_reader :name, :class_name, :model, :association_name, :module_name, :module_name, :scope, :options
def initialize(model_name, scope = nil, options = {})
@model_name = model_name
@options, @scope = ... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | lib/active_record/acts_as_relation/acts_as_modules.rb | Ruby | mit | 181 | master | 3,699 | module ActiveRecord
module ActsAsRelation
module ActsAsModules
class << self
def [](acts_as)
if const_defined? acts_as.module_name
const_get acts_as.module_name
else
acts_as_module = Module.new
const_set acts_as.module_name, acts_as_module
... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | spec/acts_as_relation_spec.rb | Ruby | mit | 181 | master | 6,104 | require 'spec_helper'
describe 'Submodel' do
it 'respond to supermodel attributes' do
pen = Pen.new
%w(name name= name_changed? name_was price price= price_changed? price_was).each do |at|
expect(pen).to respond_to(at)
end
end
it 'returns supermodel attributes with #attributes' do
pen = Pe... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | spec/spec_helper.rb | Ruby | mit | 181 | master | 398 | require 'coveralls'
Coveralls.wear!
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../dummy/config/environment', __FILE__)
require 'rspec/rails'
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
require 'rake'
Dummy::Application.load_tasks
Rake::Task['db:test:prepare'].invoke
RSpec.configur... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | spec/acts_as_superclass_spec.rb | Ruby | mit | 181 | master | 499 | require 'spec_helper'
describe 'create_table acts_as_superclass' do
it 'creates foreign key and type columns' do
name = Pen.acts_as_association_name
expect(Pen.attribute_names).to include("#{name}_id")
expect(Pen.attribute_names).to include("#{name}_type")
end
it 'when name passed creates foreign ke... |
github | hzamani/acts_as_relation | https://github.com/hzamani/acts_as_relation | spec/dummy/config/application.rb | Ruby | mit | 181 | master | 228 | require File.expand_path('../boot', __FILE__)
require 'active_record/railtie'
Bundler.require
require 'acts_as_relation'
I18n.enforce_available_locales = false
module Dummy
class Application < Rails::Application
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.