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 | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/factories/remote/player.rb | Ruby | mit | 19 | master | 480 | FactoryGirl.define do
factory :remote_player, class: Hash do
player_id { generate :player_id }
team { generate :team_id }
eman_tsrif { generate :first_name }
eman_tsal { generate :last_name }
yadhtrib { generate :date }
pihsnezitic { generate :string }
thgieh { generate :intege... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/factories/remote/team_group_statistic.rb | Ruby | mit | 19 | master | 355 | FactoryGirl.define do
factory :remote_team_group_statistic, class: Hash do
id { generate :team_id }
team_id { id }
games_played { generate :integer }
games_won { generate :integer }
games_lost { generate :integer }
games_draw { generate :integer }
ignored { generate :string }
initia... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/factories/remote/match.rb | Ruby | mit | 19 | master | 505 | FactoryGirl.define do
factory :remote_match, class: Hash do
match_id { generate :match_id }
home_team { generate :team_id }
away_team { generate :team_id }
gninnigeb { generate :timestamp }
rehtaew { %w(worm cold rainy).sample }
ignored_1 { generate :string }
ignored_2 { generate :tim... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/factories/remote/team.rb | Ruby | mit | 19 | master | 538 | FactoryGirl.define do
factory :remote_team, class: Hash do
maet_id { generate :team_id }
eman { generate :name }
yrtnuoc { generate :string }
ytic { generate :string }
ignored_1 { generate :string }
ignored_2 { generate :timestamp }
initialize_with { attributes }
trait :with_... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/factories/remote/stage.rb | Ruby | mit | 19 | master | 633 | FactoryGirl.define do
factory :remote_stage, class: Hash do
stage_id { generate :stage_id }
tour_id { generate :tournament_id }
eman { generate :string }
rebmun { generate :integer }
gninnigeb { generate :timestamp }
gnidge { generate :date }
ignored_1 { generate :date }
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/synchronisable/synchronisable_spec.rb | Ruby | mit | 19 | master | 1,999 | require 'spec_helper'
describe Synchronisable do
describe 'synchronization' do
subject do
-> { Synchronisable.sync }
end
describe 'models specified in configuration' do
context 'only Team and Match' do
before :all do
Synchronisable.config.models = %w(Match Team)
end... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/synchronisable/models/import_spec.rb | Ruby | mit | 19 | master | 291 | require 'spec_helper'
describe Synchronisable::Import do
let!(:team) { create :team }
subject { create(:import, synchronisable: team) }
it 'destroys itself with synchronisable record' do
expect { subject.destroy_with_synchronisable }.to change(Team, :count).by(-1)
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/synchronisable/dsl/macro_spec.rb | Ruby | mit | 19 | master | 1,820 | require 'spec_helper'
describe Synchronisable::DSL::Macro do
describe 'commom attributes' do
subject { HasMacroFoo }
before do
subject.xyz 7
subject.arr 1, 2, 3
end
it { respond_to? :foo }
it { respond_to? :bar }
it { respond_to? :baz }
it { respond_to? :xxx }
it { respo... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/synchronisable/support/has_macro_foo.rb | Ruby | mit | 19 | master | 291 | class HasMacroFoo
include Synchronisable::DSL::Macro
attribute :bar, default: 1
attribute :foo
attribute :baz, default: -> { bar + 1 }
attribute :carefull, default: -> { raise NotImplementedError }
attribute :xyz, converter: ->(x) { x.to_s }
attribute :arr
method :sqr
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/synchronisable/support/shared/contexts.rb | Ruby | mit | 19 | master | 689 | shared_context 'team_0 import' do
let!(:import_0) do
create(:import,
:remote_id => 'team_0',
:synchronisable => create(:team,
:name => 'x',
:country => 'Russia',
:city => 'Moscow',
)
)
end
let!(:team_0) { import_0.synchronisable }
end
shared_context 'team_1 impor... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/models/team_group_statistic_spec.rb | Ruby | mit | 19 | master | 458 | require 'spec_helper'
describe TeamGroupStatistic do
describe 'synchronization' do
context 'sync with no data specified' do
subject { -> { TeamGroupStatistic.sync } }
it { is_expected.to change { TeamGroupStatistic.count }.by(2) }
it { is_expected.to change { Team.count }.by(2) }
it { is... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/models/match_spec.rb | Ruby | mit | 19 | master | 1,076 | require 'spec_helper'
describe Match do
describe 'synchronization' do
context 'when has associations defined in Synchronizer' do
subject do
-> { Match.sync }
end
it { is_expected.to change { Match.count }.by(1) }
it { is_expected.to change { Team.count }.by(2) }
it { is_exp... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/models/tournament_spec.rb | Ruby | mit | 19 | master | 520 | require 'spec_helper'
describe Tournament do
describe 'synchronization' do
let!(:remote_attrs) do
[
build(:remote_tournament, tour_id: '1', eman: 'tour-1'),
build(:remote_tournament, tour_id: '2', eman: 'tour-1'),
build(:remote_tournament, tour_id: '3', eman: 'tour-2')
]
e... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/models/team_spec.rb | Ruby | mit | 19 | master | 4,955 | require 'spec_helper'
describe Team do
describe 'synchronization' do
let!(:remote_attrs) do
[
{
:maet_id => 'team1',
:eman => 'y',
:yrtnuoc => 'USA',
:ytic => 'Washington',
:ignored_1 => 'ignored',
:ignored_2 => 'ignored'
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/models/stage_spec.rb | Ruby | mit | 19 | master | 560 | require 'spec_helper'
describe Stage do
describe 'synchronization' do
let!(:remote_attrs) do
[
build(:remote_stage, tour_id: '1', eman: 'ignored'),
build(:remote_stage, tour_id: '2'),
build(:remote_stage, tour_id: '3')
]
end
describe 'skipping with before_sync hook' d... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/schema.rb | Ruby | mit | 19 | master | 3,916 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140422135244_create_imports.rb | Ruby | mit | 19 | master | 820 | class CreateImports < ActiveRecord::Migration
def self.up
create_table :imports do |t|
t.string :synchronisable_type, null: false
t.integer :synchronisable_id, null: false
t.text :attrs
t.string :remote_id, null: false
t.string :unique_id
t.timestamps
end
add_in... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140422133122_create_match_players.rb | Ruby | mit | 19 | master | 278 | class CreateMatchPlayers < ActiveRecord::Migration
def change
create_table :match_players do |t|
t.references :match, index: true
t.references :player, index: true
t.string :ref_type
t.integer :formation_index
t.timestamps
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140507135800_create_tournaments.rb | Ruby | mit | 19 | master | 288 | class CreateTournaments < ActiveRecord::Migration
def change
create_table :tournaments do |t|
t.string :name
t.string :short_name
t.date :beginning
t.date :ending
t.boolean :is_current, default: false, null: false
t.timestamps
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140507135837_create_stages.rb | Ruby | mit | 19 | master | 262 | class CreateStages < ActiveRecord::Migration
def change
create_table :stages do |t|
t.date :beginning
t.date :ending
t.references :tournament, index: true
t.string :name
t.integer :number
t.timestamps
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140422132544_create_matches.rb | Ruby | mit | 19 | master | 241 | class CreateMatches < ActiveRecord::Migration
def change
create_table :matches do |t|
t.integer :beginning
t.integer :home_team_id
t.integer :away_team_id
t.string :weather
t.timestamps
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140422132708_create_players.rb | Ruby | mit | 19 | master | 316 | class CreatePlayers < ActiveRecord::Migration
def change
create_table :players do |t|
t.string :first_name
t.string :last_name
t.date :birthday
t.string :citizenship
t.float :height
t.float :weight
t.references :team, index: true
t.timestamps
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/db/migrate/20140609133855_create_team_group_statistic.rb | Ruby | mit | 19 | master | 306 | class CreateTeamGroupStatistic < ActiveRecord::Migration
def change
create_table :team_group_statistics do |t|
t.references :team, index: true
t.integer :games_played
t.integer :games_won
t.integer :games_lost
t.integer :games_draw
t.timestamps
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/models/stadium.rb | Ruby | mit | 19 | master | 211 | class Stadium < ActiveRecord::Base
# There is no synchronizer defined for this model,
# so synchronization controller is gonna try
# to use remote attributes as is to create a record
synchronisable
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/models/match.rb | Ruby | mit | 19 | master | 212 | class Match < ActiveRecord::Base
belongs_to :home_team, class_name: 'Team'
belongs_to :away_team, class_name: 'Team'
belongs_to :stage
has_many :match_players, dependent: :destroy
synchronisable
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/models/match_player.rb | Ruby | mit | 19 | master | 367 | class MatchPlayer < ActiveRecord::Base
REF_TYPES = [
REF_TYPE_LINE_UP_HOME = 'line_up_home',
REF_TYPE_LINE_UP_AWAY = 'line_up_away',
REF_TYPE_SUBSTITUTES_HOME = 'substitutes_home',
REF_TYPE_SUBSTITUTES_AWAY = 'substitutes_away'
]
belongs_to :match
belongs_to :player
validates :match,... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/synchronizers/player_synchronizer.rb | Ruby | mit | 19 | master | 390 | class PlayerSynchronizer < Synchronisable::Synchronizer
remote_id :player_id
mappings(
:eman_tsrif => :first_name,
:eman_tsal => :last_name,
:yadhtrib => :birthday,
:pihsnezitic => :citizenship,
:thgieh => :height,
:thgiew => :weight,
:team => :team_id
)
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/synchronizers/match_synchronizer.rb | Ruby | mit | 19 | master | 1,837 | class MatchSynchronizer < Synchronisable::Synchronizer
gateway MatchGateway
has_one :team, key: 'home_team_id'
has_one :team, key: 'away_team_id'
remote_id :match_id
mappings(
:gninnigeb => :beginning,
:home_team => :home_team_id,
:away_team => :away_team_id,
:rehtaew => :weather,
:ln... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/synchronizers/tournament_synchronizer.rb | Ruby | mit | 19 | master | 371 | class TournamentSynchronizer < Synchronisable::Synchronizer
has_many :stages
remote_id :tour_id
unique_id { |attrs| attrs[:name] }
mappings(
:eman => :name,
:eman_trohs => :short_name,
:gninnigeb => :beginning,
:gnidge => :ending,
:tnerruc_si => :is_current
)
only :name, :b... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/synchronizers/stage_synchronizer.rb | Ruby | mit | 19 | master | 394 | class StageSynchronizer < Synchronisable::Synchronizer
has_many :matches
remote_id :stage_id
mappings(
:tour_id => :tournament_id,
:gninnigeb => :beginning,
:gnidge => :ending,
:eman => :name,
:rebmun => :number
)
except :ignored_1, :ignored_2
gateway StageGateway
bef... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/synchronizers/break_convention_team_synchronizer.rb | Ruby | mit | 19 | master | 257 | class BreakConventionTeamSynchronizer < Synchronisable::Synchronizer
has_many :players
remote_id :maet_id
mappings(
:eman => :name,
:yrtnuoc => :country,
:ytic => :city
)
except :ignored_1, :ignored_2
gateway TeamGateway
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/team_gateway.rb | Ruby | mit | 19 | master | 363 | class TeamGateway < GatewayBase
def id_key
:maet_id
end
def source
@source ||= [
FactoryGirl.build(:remote_team,
:maet_id => 'team_0',
:player_ids => %w(player_0 player_2)
),
FactoryGirl.build(:remote_team,
:maet_id => 'team_1',
:player_ids => %w(... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/gateway_base.rb | Ruby | mit | 19 | master | 279 | require 'synchronisable/gateway'
class GatewayBase < Synchronisable::Gateway
def id_key
not_implemented! :id_key
end
def source
not_implemented! :source
end
def fetch(params)
source
end
def find(id)
source.find { |h| h[id_key] == id }
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/stage_gateway.rb | Ruby | mit | 19 | master | 829 | class StageGateway < GatewayBase
def source
@source ||= [
FactoryGirl.build(:remote_stage,
:stage_id => 'stage_0',
:match_ids => %w(match_0)
),
FactoryGirl.build( :remote_stage,
:stage_id => 'stage_1',
:match_ids => %w(match_0)
)
]
end
def fet... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/player_gateway.rb | Ruby | mit | 19 | master | 571 | class PlayerGateway < GatewayBase
def id_key
:player_id
end
def source
@source ||= [
FactoryGirl.build(:remote_player,
:team => 'team_0',
:player_id => 'player_0'
),
FactoryGirl.build(:remote_player,
:team => 'team_0',
:player_id => 'player_2'
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/match_gateway.rb | Ruby | mit | 19 | master | 257 | class MatchGateway < GatewayBase
def id_key
:match_id
end
def source
@source ||= [
FactoryGirl.build(:remote_match,
:match_id => 'match_0',
:home_team => 'team_0',
:away_team => 'team_1'
)
]
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/tournament_gateway.rb | Ruby | mit | 19 | master | 456 | class TournamentGateway < GatewayBase
def id_key
:tour_id
end
def source
@source ||= [
FactoryGirl.build(:remote_tournament,
:tour_id => 'tournament_0',
:is_current => true,
:stage_ids => [
{
id: 'stage_0',
tournament_id: 'tournament_0'
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/app/gateways/team_group_statistic_gateway.rb | Ruby | mit | 19 | master | 440 | class TeamGroupStatisticGateway < GatewayBase
def id_key
:id
end
def find(id)
raise NotImplementedError, 'Life is a bitch'
end
def source
@source ||= [
FactoryGirl.build(:remote_team_group_statistic,
:id => 'team_0',
:team_id => 'team_0'
),
FactoryGirl.bu... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/config/routes.rb | Ruby | mit | 19 | master | 1,602 | Dummy::Application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'c... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/config/boot.rb | Ruby | mit | 19 | master | 206 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/config/application.rb | Ruby | mit | 19 | master | 994 | require File.expand_path('../boot', __FILE__)
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
require 'synchronisable'
module Dummy
class Application < Rails::Application
# Settings in config/environme... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 19 | master | 659 | # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to diction... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/config/initializers/inflections.rb | Ruby | mit | 19 | master | 744 | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | spec/dummy/config/environments/development.rb | Ruby | mit | 19 | master | 1,063 | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web ser... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable.rb | Ruby | mit | 19 | master | 2,598 | require 'active_record'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/string/inflections'
require 'active_support/configurable'
require 'active_support/concern'
# HACK: monkeypatches / fallbacks for activesupport ~> 3.0
if Gem.loaded_specs['a... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/generators/synchronisable/install_generator.rb | Ruby | mit | 19 | master | 729 | require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'
module Synchronisable
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
desc 'Generates (but does not run) a... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/generators/synchronisable/templates/initializer.rb | Ruby | mit | 19 | master | 818 | Synchronisable.configure do |config|
# Logging configuration
#
# Default logger fallbacks to `Rails.logger` if available, otherwise
# `STDOUT` will be used for output.
#
# config.logging = {
# :logger => defined?(Rails) ? Rails.logger : Logger.new(STDOUT),
# :verbose => true,
# :colorize => t... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/generators/synchronisable/templates/create_imports_migration.rb | Ruby | mit | 19 | master | 807 | class CreateImports < ActiveRecord::Migration
def self.up
create_table :imports do |t|
t.string :synchronisable_type, null: false
t.integer :synchronisable_id, null: false
t.text :attrs
t.string :remote_id, null: false
t.string :unique_id
t.timestamps null: false
end... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/controller.rb | Ruby | mit | 19 | master | 3,671 | require 'colorize'
require 'synchronisable/error_handler'
require 'synchronisable/context'
require 'synchronisable/input/parser'
require 'synchronisable/source'
require 'synchronisable/models/import'
require 'synchronisable/helper/logging'
require 'synchronisable/worker/record'
require 'synchronisable/worker/associati... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/model.rb | Ruby | mit | 19 | master | 2,013 | require 'synchronisable/model/methods'
require 'synchronisable/model/scopes'
require 'synchronisable/synchronizers/synchronizer_default'
module Synchronisable
module Model
extend ActiveSupport::Concern
module ClassMethods
SYNCHRONIZER_SUFFIX = 'Synchronizer'
# Declare this on your model class t... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/configuration.rb | Ruby | mit | 19 | master | 1,006 | module Synchronisable
class Configuration
include ActiveSupport::Configurable
class << self
# HACK: This is required to smooth a future transition to activesupport 4.x
# Since 3-2's config_accessor doesn't take a block or provide an option to set the default value of a config.
alias_method ... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/exceptions.rb | Ruby | mit | 19 | master | 305 | module Synchronisable
# Error is thrown when remote id isn't supplied
# with remote attibutes hash.
class MissedRemoteIdError < StandardError; end
# Error is thrown when required associations isn't supplied
# with remote attributes hash.
class MissedAssociationsError < StandardError; end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/version.rb | Ruby | mit | 19 | master | 227 | module Synchronisable
# Gem version builder module
module VERSION
MAJOR = 1
MINOR = 3
PATCH = 1
SUFFIX = ''
NUMBER = [MAJOR, MINOR, PATCH].compact.join('.')
STRING = "#{NUMBER}#{SUFFIX}"
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/synchronizer.rb | Ruby | mit | 19 | master | 6,144 | require 'synchronisable/dsl/macro'
require 'synchronisable/attribute_mapper'
require 'synchronisable/dsl/associations'
require 'synchronisable/exceptions'
module Synchronisable
# @abstract Subclass to create your model specific synchronizer class to
# setup synchronization attributes and behavior.
#
# @see S... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/attribute_mapper.rb | Ruby | mit | 19 | master | 897 | module Synchronisable
class AttributeMapper
class << self
def map(source, mappings, options = {})
new(mappings, options).map(source)
end
end
def initialize(mappings, options = {})
@mappings = mappings
@keep = options[:keep] || []
@only, @except = options[:only], opti... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/source.rb | Ruby | mit | 19 | master | 2,535 | module Synchronisable
# TODO: Massive refactoring needed
# Synchronization source.
class Source
CHILD_ASSOCIATION_KEYS = %i(has_one has_many)
PARENT_ASSOCIATION_KEYS = %i(belongs_to)
attr_accessor :import_record
attr_reader :parent_associations, :child_associations
attr_reader :model, :remot... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/error_handler.rb | Ruby | mit | 19 | master | 1,753 | module Synchronisable
# Helper class for synchronization errors handling.
#
# @see Synchronisable::Context
#
# @api private
class ErrorHandler
# @param logger [Logger] logger to used to log errors
# @param context [Synchronisable::Context] synchronization context
def initialize(logger, context)
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/context.rb | Ruby | mit | 19 | master | 761 | module Synchronisable
# Synchronization context.
class Context
attr_accessor :model, :errors,
:before, :after, :deleted
def initialize(model, parent)
@model, @parent = model, parent
@errors = []
@before, @after, @deleted = 0, 0, 0
end
def success?
errors.e... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/gateway.rb | Ruby | mit | 19 | master | 326 | module Synchronisable
class Gateway
def fetch(params = {})
not_implemented! :fetch
end
def find(params)
not_implemented! :find
end
protected
def not_implemented!(method)
raise NotImplementedError,
I18n.t('errors.gateway_method_missing', method: method)
end
en... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/worker/record.rb | Ruby | mit | 19 | master | 1,461 | require 'synchronisable/worker/base'
module Synchronisable
module Worker
# Responsible for record synchronization.
#
# @api private
class Record < Base
# Synchronizes record.
def sync_record
@synchronizer.with_record_sync_callbacks(@source) do
log_info(@source.dump_messa... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/worker/base.rb | Ruby | mit | 19 | master | 510 | require 'synchronisable/helper/logging'
module Synchronisable
module Worker
# Base class for synchronization workers.
#
# @see Synchronisable::Worker::Record
# @see Synchronisable::Worker::Associations
#
# @api private
class Base
include Helper::Logging
def initialize(synchro... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/worker/associations.rb | Ruby | mit | 19 | master | 2,663 | require 'synchronisable/worker/base'
module Synchronisable
module Worker
# Responsible for associations synchronization.
#
# @api private
class Associations < Base
# Synchronizes associations.
#
# @see Synchronisable::Source
# @see Synchronisable::DSL::Associations
# @se... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/model/methods.rb | Ruby | mit | 19 | master | 2,203 | require 'synchronisable/controller'
require 'synchronisable/models/import'
module Synchronisable
module Model
# Methods that will be attached to synchronisable model class.
module Methods
def synchronisable?
true
end
# Creates a new controller, that initiates synchronization
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/model/scopes.rb | Ruby | mit | 19 | master | 498 | require 'synchronisable/models/import'
module Synchronisable
module Model
module Scopes
def not_imported
includes(:import)
.where(imports: { synchronisable_id: nil })
.references(:imports)
end
def imported
includes(:import)
.where.not(imports: { sy... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/dsl/association.rb | Ruby | mit | 19 | master | 1,702 | require 'synchronisable/dsl/macro'
module Synchronisable
module DSL
# Association builder.
# Subclasses must implement #macro method.
class Association
include Synchronisable::DSL::Macro
KIND_KEY_SUFFIX_MAP = {
:belongs_to => :id,
:has_one => :id,
:has_many => :ids
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/dsl/macro.rb | Ruby | mit | 19 | master | 2,889 | require 'synchronisable/dsl/macro/method'
require 'synchronisable/dsl/macro/attribute'
module Synchronisable
module DSL
# Allows to define DSL-like attributes and methods.
# to be used in target class/module.
#
# @example Common use cases
# class Foo
# include Synchronisable::DSL::Macro... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/dsl/associations.rb | Ruby | mit | 19 | master | 1,632 | require 'synchronisable/dsl/association'
module Synchronisable
module DSL
module Associations
extend ActiveSupport::Concern
included do
class_attribute :associations
self.associations = {}
end
module ClassMethods
def inherited(subclass)
super
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/dsl/macro/expression.rb | Ruby | mit | 19 | master | 1,123 | module Synchronisable
module DSL
module Macro
# Serves as storage and provides lazy evaluation for expression.
# You can override attributes in subclasses,
# for example you can change the default value.
#
# @api private
#
# @see Synchronisable::DSL::Macro
# @see Sy... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/dsl/macro/method.rb | Ruby | mit | 19 | master | 320 | require 'synchronisable/dsl/macro/expression'
module Synchronisable
module DSL
module Macro
# Expression for a method definition.
#
# @api private
#
# @see Synchronisable::DSL::Macro
# @see Synchronisable::DSL::Expression
class Method < Expression; end
end
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/dsl/macro/attribute.rb | Ruby | mit | 19 | master | 743 | require 'synchronisable/dsl/macro/expression'
module Synchronisable
module DSL
module Macro
# Expression for an attribute definition.
#
# @api private
#
# @see Synchronisable::DSL::Macro
# @see Synchronisable::DSL::Expression
class Attribute < Expression
def init... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/helper/logging.rb | Ruby | mit | 19 | master | 579 | module Synchronisable
module Helper
# Provides logging helper methods.
# Class or module that includes this one
# should implement `logger` method.
#
# @api private
module Logging
protected
%i(verbose colorize).each do |name|
define_method("#{name}_logging?".to_sym) do
... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/input/descriptor.rb | Ruby | mit | 19 | master | 889 | module Synchronisable
module Input
# Provides a set of helper methods
# to describe user input.
#
# @api private
#
# @see Synchronisable::Input::Descriptor
class Descriptor
attr_reader :data
def initialize(data)
@data = data
end
def empty?
@data.bl... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/input/parser.rb | Ruby | mit | 19 | master | 1,979 | require 'synchronisable/input/descriptor'
module Synchronisable
module Input
# Responsible for guessing the user input format.
#
# @api private
#
# @see Synchronisable::Input::Parser
class Parser
def initialize(model, synchronizer)
@model = model
@synchronizer = synchron... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/synchronizers/synchronizer_default.rb | Ruby | mit | 19 | master | 266 | require 'synchronisable/synchronizer'
module Synchronisable
# Default synchronizer to be used when
# model specific synchronizer is not defined.
#
# @api private
#
# @see Synchronisable::Synchronizer
class SynchronizerDefault < Synchronizer
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/models/import.rb | Ruby | mit | 19 | master | 775 | module Synchronisable
class Import < ActiveRecord::Base
belongs_to :synchronisable, polymorphic: true
if Gem.loaded_specs['activerecord'].version < Gem::Version.create(4)
attr_accessible :synchronisable_id, :synchronisable_type, :remote_id, :unique_id, :attrs
end
serialize :attrs, Hash
sc... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/synchronisable/bootstrap/i18n.rb | Ruby | mit | 19 | master | 335 | require 'i18n'
locale_paths = File.join(File.dirname(__FILE__),
'..', 'locale', '*.yml')
Dir[locale_paths].each { |path| I18n.load_path << path }
I18n.backend.load_translations unless defined?(Rails)
I18n.config.enforce_available_locales = true
I18n.default_locale = :en
I18n.available_locale... |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/core_ext/object/try.rb | Ruby | mit | 19 | master | 284 | class Object
def try!(*a, &b)
if a.empty? && block_given?
if b.arity.zero?
instance_eval(&b)
else
yield self
end
else
public_send(*a, &b)
end
end
def try(*a, &b)
try!(*a, &b) if a.empty? || respond_to?(a.first)
end
end |
github | vyorkin-personal/synchronisable | https://github.com/vyorkin-personal/synchronisable | lib/core_ext/hash/keys.rb | Ruby | mit | 19 | master | 369 | class Hash
def transform_keys
return enum_for(:transform_keys) unless block_given?
result = self.class.new
each_key do |key|
result[yield(key)] = self[key]
end
result
end
def transform_keys!
return enum_for(:transform_keys!) unless block_given?
keys.each do |key|
self[yiel... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | scheman-rails.gemspec | Ruby | mit | 19 | master | 1,091 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "scheman/rails/version"
Gem::Specification.new do |spec|
spec.name = "scheman-rails"
spec.version = Scheman::Rails::VERSION
spec.authors = ["Ryo Nakamura"]
spec.email = ["r7ka... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | spec/spec_helper.rb | Ruby | mit | 19 | master | 392 | ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../dummy/config/environment", __FILE__)
require "rspec/rails"
RSpec.configure do |config|
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.treat_symbols_as_metadata_keys_with_true_values = true
config... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | spec/dummy/config/application.rb | Ruby | mit | 19 | master | 1,213 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the g... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | lib/scheman/rails.rb | Ruby | mit | 19 | master | 249 | require "open3"
require "scheman"
require "scheman/rails/commands/base"
require "scheman/rails/commands/applier"
require "scheman/rails/commands/dumper"
require "scheman/rails/errors"
require "scheman/rails/railtie"
require "scheman/rails/version" |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | lib/scheman/rails/tasks.rake | Ruby | mit | 19 | master | 370 | namespace :db do
namespace :schema do
desc "Show diff between the current DB schema and db/schema.sql"
task diff: [:environment, :load_config] do
Scheman::Rails::Dumper.call
end
desc "Apply diff between the current DB schema and db/schema.sql"
task apply: [:environment, :load_config] do
... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | lib/scheman/rails/commands/applier.rb | Ruby | mit | 19 | master | 1,934 | module Scheman
module Rails
class Applier < Base
DEFAULT_SCHEMA_MESSAGE = "# Write your database schema here"
def self.call
new.call
end
def call
execute_sql
create_schema_file
end
private
def execute_sql
if has_error?
abort(e... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | lib/scheman/rails/commands/base.rb | Ruby | mit | 19 | master | 1,107 | module Scheman
module Rails
class Base
SCHEMA_PATH = "db/schema.sql"
def self.call
new.call
end
private
def database
configuration["database"]
end
def encoding
configuration["encoding"]
end
def socket
configuration["socket"... |
github | r7kamura/scheman-rails | https://github.com/r7kamura/scheman-rails | lib/scheman/rails/commands/dumper.rb | Ruby | mit | 19 | master | 2,143 | module Scheman
module Rails
class Dumper < Base
def call
case
when has_unexpected_dump_error?
abort(dump_error_message)
when str = result.presence
puts str
end
end
def has_unknown_database_error?
has_dump_error? && /Unknown database/ =... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | merb-extlib.gemspec | Ruby | mit | 19 | master | 1,452 | Gem::Specification.new do |s|
s.files = ["LICENSE",
"Rakefile",
"spec/hash_spec.rb",
"spec/object_spec.rb",
"spec/set_spec.rb",
"spec/spec_helper.rb",
"spec/string_spec.rb",
"spec/time_spec.rb",
"lib/merb-extlib",
"lib/merb-extlib/class.rb",
"lib/merb-extlib/hash.rb",
"lib/merb-extlib/logger.rb",
"lib/mer... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | Rakefile | Ruby | mit | 19 | master | 5,851 | require "rake"
require "rake/clean"
require "rake/gempackagetask"
require "rake/rdoctask"
require "rake/testtask"
require "spec/rake/spectask"
require "fileutils"
def __DIR__
File.dirname(__FILE__)
end
include FileUtils
NAME = "merb-extlib"
require "lib/#{NAME}/version"
def sudo
ENV['MERB_SUDO'] ||= "sudo"
s... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib.rb | Ruby | mit | 19 | master | 469 | require "pathname"
# for Pathname#/
require File.expand_path(File.join(File.dirname(__FILE__), 'merb-extlib', 'pathname'))
dir = Pathname(__FILE__).dirname.expand_path / 'merb-extlib'
require dir / "version"
require dir / "string"
require dir / "time"
require dir / "class"
require dir / "hash"
require dir / "mash"
... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/set.rb | Ruby | mit | 19 | master | 939 | module Merb
# Simple set implementation
# on top of Hash with merging support.
#
# In particular this is used to store
# a set of callable actions of controller.
class SimpleSet < Hash
# @param arr<Array> Initial set values.
#
# @return <Array> The array the Set was initialized with
def ini... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/rubygems.rb | Ruby | mit | 19 | master | 1,402 | # this is a temporary workaround until rubygems Does the Right thing here
require 'rubygems'
module Gem
class SourceIndex
# This is resolved in 1.1
if Version.new(RubyGemsVersion) < Version.new("1.1")
# Overwrite this so that a gem of the same name and version won't push one
# from the... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/time.rb | Ruby | mit | 19 | master | 235 | class Time
# @return <String>
# ISO 8601 compatible rendering of the Time object's properties.
#
# @example
# Time.now.to_json # => "\"2008-03-28T17:54:20-05:00\""
def to_json
self.xmlschema.to_json
end
end |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/object_space.rb | Ruby | mit | 19 | master | 230 | module ObjectSpace
class << self
# @return <Array[Class]> All the classes in the object space.
def classes
klasses = []
ObjectSpace.each_object(Class) {|o| klasses << o}
klasses
end
end
end |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/mash.rb | Ruby | mit | 19 | master | 3,817 | # This class has dubious semantics and we only have it so that people can write
# params[:key] instead of params['key'].
class Mash < Hash
# @param constructor<Object>
# The default value for the mash. Defaults to an empty hash.
#
# @details [Alternatives]
# If constructor is a Hash, a new mash will be c... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/virtual_file.rb | Ruby | mit | 19 | master | 204 | require "stringio"
# To use as a parameter to Merb::Template.inline_template
class VirtualFile < StringIO
attr_accessor :path
def initialize(string, path)
super(string)
@path = path
end
end |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/object.rb | Ruby | mit | 19 | master | 5,167 | class Object
# Extracts the singleton class, so that metaprogramming can be done on it.
#
# @return <Class> The meta class.
#
# @example [Setup]
# class MyString < String; end
#
# MyString.instance_eval do
# define_method :foo do
# puts self
# end
# end
#
# MyString.met... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/class.rb | Ruby | mit | 19 | master | 6,737 | # Copyright (c) 2004-2008 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merg... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/hash.rb | Ruby | mit | 19 | master | 12,015 | require 'base64'
class Hash
class << self
# Converts valid XML into a Ruby Hash structure.
#
# @param xml<String> A string representation of valid XML.
#
# @note Mixed content is treated as text and any tags in it are left unparsed
# @note Any attributes other than type on a node containing a... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/logger.rb | Ruby | mit | 19 | master | 5,806 | require "time" # httpdate
# ==== Public Merb Logger API
#
# To replace an existing logger with a new one:
# Merb::Logger.set_log(log{String, IO},level{Symbol, String})
#
# Available logging levels are
# Merb::Logger::{ Fatal, Error, Warn, Info, Debug }
#
# Logging via:
# Merb.logger.fatal(message<String>,&block)
#... |
github | wycats/merb-extlib | https://github.com/wycats/merb-extlib | lib/merb-extlib/string.rb | Ruby | mit | 19 | master | 2,217 | require "pathname"
class String
##
# @return <String> The string with all regexp special characters escaped.
#
# @example
# "*?{}.".escape_regexp #=> "\\*\\?\\{\\}\\."
def escape_regexp
Regexp.escape self
end
##
# @return String The string with all regexp special characters unescaped.
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.