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 | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | bin/generate_3az_vpc.rb | Ruby | mit | 47 | master | 1,646 | #!/usr/bin/env ruby
require 'trollop'
opts = Trollop::options do
opt :ip_to_allow_to_bastion, 'IP address of host to allow SSH access to the bastion', :type => :string, :required => true
opt :nat_keypair_name, 'The name of the key pair to assign to the NAT instance', :type => :string, :default => 'nat_keypair', :... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | bin/generate_private_vpc.rb | Ruby | mit | 47 | master | 594 | #!/usr/bin/env ruby
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'vpc_description'
require 'vpc_cfn_generator'
vpc_description = VpcDescription.new(cidr_block: '192.168.0.0/16',
azs_to_distribute_across: %w{us-east-1b us-east-1c})
vpc_description.add... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | bin/aws-ruby-sdk-migration-assistant.rb | Ruby | mit | 47 | master | 817 | #!/usr/bin/env ruby
#####
## Assists with upgrading from V2 to V3 of the AWS Ruby SDK
## by telling you which includes your missing for various
## service clients or resources your using
#####
# Usage: ./aws-ruby-sdk-migration-assistant.rb path/to/your/files/lol
ignore = %w[assumerolecredentials waiters]
Dir.glob("... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | bin/just_public_vpc.rb | Ruby | mit | 47 | master | 479 | #!/usr/bin/env ruby
require 'trollop'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'vpc_description'
require 'vpc_cfn_generator'
vpc_description = VpcDescription.new(cidr_block: '192.168.0.0/16',
azs_to_distribute_across: %w{us-east-1b us-east-1c})
... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | bin/generate_typical_2az_vpc.rb | Ruby | mit | 47 | master | 1,539 | #!/usr/bin/env ruby
require 'trollop'
opts = Trollop::options do
opt :ip_to_allow_to_bastion, 'IP address of host to allow SSH access to the bastion', :type => :string, :required => true
opt :nat_keypair_name, 'The name of the key pair to assign to the NAT instance', :type => :string, :default => 'nat_keypair', :... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | lib/vpc_description.rb | Ruby | mit | 47 | master | 3,523 | #
# This object contains parameters that can be used to control
# the creation of an AWS VPC.
#
# Perhaps think of this object as a way to bundle up the kind
# of information one might encode in the Parameters and Mappings
# section of a CloudFormation template that would create a given VPC.
#
class VpcDescription
d... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | lib/cfn_executor.rb | Ruby | mit | 47 | master | 3,348 | require 'aws-sdk'
class CloudFormationExecutor
def execute(stack_name, io, parameters = {}, wait=false)
success = true
begin
cfm = AWS::CloudFormation.new
stack = cfm.stacks.create(stack_name,
io.read,
:parameters => parameters,
... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | lib/vpc_cfn_generator.rb | Ruby | mit | 47 | master | 15,595 | require 'JSON'
#
# This object can generate a CloudFormation template for an AWS VPC
# based upon customizing parameters in a VpcDescription object
#
class VpcCfnGenerator
#
# Emit the CloudFormation template based upon the given VpcDescription into
# the specified IO object.
#
# * *Args* :
# - ++ ->... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | serverspec/default/basic_2az_vpc_spec.rb | Ruby | mit | 47 | master | 3,413 | require_relative 'spec_helper'
describe 'the default network', :basic_two_az do
vpc_id = ENV['VPC_ID']
describe vpc(vpc_id), :basics do
it { should be_default_tenancy }
it { should be_available }
its(:cidr_block) { should eq '192.168.0.0/16' }
its(:dhcp_options) {
should include({:domain... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | serverspec/default/private_vpc_spec.rb | Ruby | mit | 47 | master | 1,687 | require_relative 'spec_helper'
describe 'private network with VPN connection through Virtual Private Gateway', :private do
vpc_id = ENV['VPC_ID']
describe vpc(vpc_id), :vpg do
its(:virtual_private_gateway) { should have_name('dummygw') }
end
describe vpc(vpc_id), :basics do
it { should be_default_... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | serverspec/default/three_az_vpc_spec.rb | Ruby | mit | 47 | master | 3,590 | require_relative 'spec_helper'
describe 'the three az network', :three_az do
vpc_id = ENV['VPC_ID']
describe vpc(vpc_id), :basics do
it { should be_default_tenancy }
it { should be_available }
its(:cidr_block) { should eq '192.168.0.0/16' }
its(:dhcp_options) {
should include({:domain_na... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | spec/vpc_cfn_generator_spec.rb | Ruby | mit | 47 | master | 2,595 | require 'json'
require 'vpc_description'
require 'vpc_cfn_generator'
describe 'vpc_cfn_generator' do
before(:all) do
@vpc_description = VpcDescription.new(cidr_block: '192.168.0.0/16',
azs_to_distribute_across: %w{us-east-1b us-east-1c})
end
def emit_json_output(vp... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | spec/vpc_description_spec.rb | Ruby | mit | 47 | master | 917 | describe 'vpc_description' do
it 'should bail on nil parameters' do
vpc_description = VpcDescription.new
expect { vpc_description.add_vpg(nil) }.to_raise ArgumentError
expect { vpc_description.add_bastion(nil, Object.new, Object.new, Object.new)}.to_raise ArgumentError
expect { vpc_description.add_... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | admin/create_iam_user.rb | Ruby | mit | 47 | master | 958 | require 'aws-sdk'
require "securerandom"
client = Aws::IAM::Client.new(region: 'us-east-1')
resource = Aws::IAM::Resource.new(client: client)
puts "Please enter the user's first name"
first_name = gets.chomp
puts "Please enter the user's last name"
last_name = gets.chomp
# Creating a random that complies with Stelli... |
github | stelligent/stelligent_commons | https://github.com/stelligent/stelligent_commons | admin/invite_github_member.rb | Ruby | mit | 47 | master | 484 | require "octokit"
puts "Please enter your OAUTH Token"
access_token = gets.chomp
# This is authenticating to GitHub using the Oauth token
client = Octokit::Client.new(:access_token => access_token)
user = client.user
user.login
puts "Please enter the GitHub username of the person that will be invited to Stelligent"
... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | typeid.gemspec | Ruby | apache-2.0 | 47 | main | 910 | require_relative "./lib/typeid/version.rb"
Gem::Specification.new do |gem|
gem.name = "typeid"
gem.version = TypeID::VERSION
gem.summary = "A type-safe, K-sortable, globally unique identifier inspired by Stripe IDs"
gem.authors = ["Andrew Booth"]
gem.homepage = "https://github.com/broothie/typeid-ruby"
gem... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | Rakefile | Ruby | apache-2.0 | 47 | main | 609 | task default: :list
desc "List tasks"
task :list do
sh "rake -AT"
end
desc "Run specs"
task specs: %i[bundle] do
sh "bin/rspec"
end
desc "Release a new version"
task release: %i[bump bundle]
desc "Bump the version"
task :bump do
# If missing "bump", run: `cargo install --git https://github.com/broothie/bump`
... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | spec/invalid_spec.rb | Ruby | apache-2.0 | 47 | main | 479 | require "yaml"
require_relative "../lib/typeid.rb"
filename = "invalid.yml"
filepath = File.expand_path(filename, __dir__)
examples = YAML.load_file(filepath)
RSpec.context "when testing against #{filename}" do
examples.each do |example|
context "when example '#{example["name"]}'" do
subject(:type_id) { T... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | spec/valid_spec.rb | Ruby | apache-2.0 | 47 | main | 863 | require "yaml"
require_relative "../lib/typeid.rb"
filename = "valid.yml"
filepath = File.expand_path(filename, __dir__)
examples = YAML.load_file(filepath)
RSpec.context "when testing against #{filename}" do
examples.each do |example|
context "when example '#{example["name"]}'" do
describe "decoding" do
... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | spec/spec_helper.rb | Ruby | apache-2.0 | 47 | main | 4,888 | require "simplecov"
SimpleCov.start do
if ENV["CI"]
require "simplecov-cobertura"
formatter SimpleCov::Formatter::CoberturaFormatter
end
end
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The gener... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | spec/lib/typeid_spec.rb | Ruby | apache-2.0 | 47 | main | 958 | require_relative "../../lib/typeid.rb"
RSpec.describe TypeID do
subject(:type_id) { TypeID.new(prefix, suffix: suffix) }
let(:prefix) { "user" }
let(:suffix) { "01h2xcejqtf2nbrexx3vqjhp41" }
let(:string) { "#{prefix}_#{suffix}" }
let(:uuid) { TypeID::UUID.new(bytes) }
let(:bytes) { [1, 136, 186, 199, 74, ... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | spec/lib/typeid/uuid_spec.rb | Ruby | apache-2.0 | 47 | main | 884 | require_relative "../../../lib/typeid.rb"
RSpec.describe TypeID::UUID do
subject(:uuid) { TypeID::UUID.new(bytes) }
let(:bytes) { [1, 136, 186, 199, 74, 250, 120, 170, 188, 59, 189, 30, 239, 40, 216, 129] }
let(:base32) { "01h2xcejqtf2nbrexx3vqjhp41" }
let(:string) { "0188bac7-4afa-78aa-bc3b-bd1eef28d881" }
... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | spec/lib/typeid/uuid/base32_spec.rb | Ruby | apache-2.0 | 47 | main | 495 | require_relative "../../../../lib/typeid.rb"
RSpec.describe TypeID::UUID::Base32 do
let(:decoded) { [1, 136, 186, 199, 74, 250, 120, 170, 188, 59, 189, 30, 239, 40, 216, 129] }
let(:encoded) { "01h2xcejqtf2nbrexx3vqjhp41" }
describe ".encode" do
subject(:encode) { TypeID::UUID::Base32.encode(decoded) }
... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | lib/typeid.rb | Ruby | apache-2.0 | 47 | main | 3,702 | require_relative "./typeid/uuid.rb"
# Represents a TypeID.
# Provides accessors to the underlying prefix, suffix, and UUID.
# Can be treated as a string.
#
# To generate a new +TypeID+:
# TypeID.new("foo") #=> #<TypeID foo_01h4vjdvzefw18zfwz5dxw5y8g>
#
# To parse a +TypeID+ from a string:
# TypeID.from_string("foo... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | lib/typeid/uuid.rb | Ruby | apache-2.0 | 47 | main | 2,073 | require "uuid7"
require_relative "./uuid/base32.rb"
class TypeID < String
# Represents a UUID. Can be treated as a string.
class UUID < String
# @return [Array<Integer>]
attr_reader :bytes
# Utility method to generate a timestamp as milliseconds since the Unix epoch.
#
# @return [Integer]
... |
github | broothie/typeid-ruby | https://github.com/broothie/typeid-ruby | lib/typeid/uuid/base32.rb | Ruby | apache-2.0 | 47 | main | 6,726 | class TypeID < String
class UUID < String
# Provides utilities for encoding and decoding UUIDs to and from base32.
# Based on https://github.com/jetpack-io/typeid-go/blob/341e2b135e0609db272e6400f2f551487725824a/base32/base32.go.
module Base32
DECODED_BYTE_ARRAY_LENGTH = 16
ENCODED_STRING_LEN... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | transloadit-rails.gemspec | Ruby | mit | 47 | main | 1,292 | $:.unshift File.expand_path('../lib', __FILE__)
require 'transloadit/rails/version'
Gem::Specification.new do |gem|
gem.name = 'transloadit-rails'
gem.version = Transloadit::Rails::VERSION
gem.platform = Gem::Platform::RUBY
gem.authors = ['Stephen Touset', 'Robin Mehner']
gem.email = ['stephen@tou... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | Rakefile | Ruby | mit | 47 | main | 582 | require 'rubygems/package_task'
require 'rake/testtask'
GEMSPEC = 'transloadit-rails.gemspec'
spec = eval open(GEMSPEC).read
Gem::PackageTask.new(spec) do |gem|
gem.need_tar = true
end
Rake::TestTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
end
begin
require 'yard'
require 'y... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/Gemfile | Ruby | mit | 47 | main | 1,925 | source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/config/application.rb | Ruby | mit | 47 | main | 489 | require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module RailsExample
class Application < Rails::Application
# Settings in config/environments/* take precedence over those ... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/config/routes.rb | Ruby | mit | 47 | main | 212 | Rails.application.routes.draw do
RailsExample::Application.routes.draw do
resources :uploads
end
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/config/initializers/new_framework_defaults.rb | Ruby | mit | 47 | main | 1,114 | # Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_fo... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/config/environments/production.rb | Ruby | mit | 47 | main | 3,586 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/test/controllers/uploads_controller_test.rb | Ruby | mit | 47 | main | 269 | require 'test_helper'
class UploadsControllerTest < ActionDispatch::IntegrationTest
test "should get new" do
get uploads_new_url
assert_response :success
end
test "should get create" do
get uploads_create_url
assert_response :success
end
end |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | examples/rails_example/db/schema.rb | Ruby | mit | 47 | main | 922 | # 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 source for your
# dat... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | test/generators/transloadit/test_install_generator.rb | Ruby | mit | 47 | main | 607 | require 'action_controller'
require 'test_helper'
class InstallGeneratorTest < Rails::Generators::TestCase
tests Transloadit::Generators::InstallGenerator
destination File.expand_path('../../../tmp', __FILE__)
setup do
prepare_destination
end
test 'the Transloadit config file is installed' do
run_g... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | test/lib/test_signature.rb | Ruby | mit | 47 | main | 2,031 | require "test_helper"
require "ostruct"
class SignatureTest < ActiveSupport::TestCase
test "engine sign returns sha384-prefixed signature" do
params = '{"auth":{"key":"test-key"}}'
secret = "test-secret"
expected = "sha384:#{Transloadit::Request.send(:_hmac, secret, params)}"
with_engine_singleton_... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | lib/generators/transloadit/install_generator.rb | Ruby | mit | 47 | main | 351 | require 'transloadit/rails'
require 'rails/generators'
class Transloadit::Generators::InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../../../templates/transloadit', __FILE__)
desc %{Installs an empty Transloadit config file}
def copy_configuration
template 'transloadit.yml', 'con... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | lib/transloadit/rspec/request_spec_helper.rb | Ruby | mit | 47 | main | 1,159 | class Transloadit
module RSpec
# Provides helper methods to help stub a request to Transloadit in a non-JS request spec.
module RequestSpecHelper
# Stubs the relevant calls to the controller so as that a request spec can
# test Transloadit parameters without needing to actually make a call to the
... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | lib/transloadit/rails/engine.rb | Ruby | mit | 47 | main | 2,956 | require 'transloadit/rails'
require 'transloadit/generators'
require 'rails'
class Transloadit
module Rails
autoload :ParamsDecoder, 'transloadit/rails/params_decoder'
autoload :ViewHelper, 'transloadit/rails/view_helper'
class Engine < ::Rails::Engine
CONFIG_PATH = 'config/transloadit.yml'
... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | lib/transloadit/rails/view_helper.rb | Ruby | mit | 47 | main | 1,849 | require 'transloadit/rails/engine'
module Transloadit::Rails::ViewHelper
#
# Inserts hidden fields specifying and signing the template for Transloadit
# to process.
#
# template - The String or Symbol template name.
# options - The Hash options used to refine the Assembly (default: {}):
# :st... |
github | transloadit/rails-sdk | https://github.com/transloadit/rails-sdk | lib/transloadit/rails/params_decoder.rb | Ruby | mit | 47 | main | 810 | require 'transloadit/rails'
module Transloadit::Rails::ParamsDecoder
extend ActiveSupport::Concern
included do
if respond_to?(:before_action)
before_action :decode_transloadit_json
else
before_filter :decode_transloadit_json
end
end
def decode_transloadit_json
params[:transloadit]... |
github | maccman/syncro | https://github.com/maccman/syncro | syncro.gemspec | Ruby | mit | 47 | master | 2,233 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{syncro}
s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_ru... |
github | maccman/syncro | https://github.com/maccman/syncro | Rakefile | Ruby | mit | 47 | master | 561 | begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "syncro"
gemspec.summary = "Sync Ruby classes between clients."
gemspec.email = "info@eribium.org"
gemspec.homepage = "http://github.com/maccman/syncro"
gemspec.description = "Sync Ruby classes between clients."
gemspec.a... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro.rb | Ruby | mit | 47 | master | 1,043 | gem "supermodel", ">= 0.1.3"
require "supermodel"
gem "activesupport"
require "active_support"
require "active_support/core_ext/class/attribute"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/module/delegation"
require "active_support/core_ext/string/inflections"
require "active_suppor... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/session.rb | Ruby | mit | 47 | master | 2,191 | module Syncro
class Session
class << self
def records
@records ||= []
end
def find(id)
id = Integer(id) # Only integer IDs
records.find {|r| r.id == id }
end
def for_client(client)
records.select {|r| r.client == client }
end
en... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/response.rb | Ruby | mit | 47 | master | 428 | module Syncro
class Response
cattr_accessor :callbacks
self.callbacks = {}
def self.expect(namespace, message_id, prok = nil, &block)
self.callbacks[namespace] ||= {}
self.callbacks[namespace][message_id] = (prok||block)
end
def self.call(namespace, message_id, *args)
ca... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/app.rb | Ruby | mit | 47 | master | 3,348 | module Syncro
class App
attr_reader :session, :message
def initialize(session)
@session = session
end
def client
@client ||= @session.client.reload
end
def call(message)
@client = nil
@message = message
method = "invoke_#{message.type}"
sen... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/client.rb | Ruby | mit | 47 | master | 378 | module Syncro
class Client < SuperModel::Base
include SuperModel::RandomID
class << self
def for(uid)
find_or_create_by_uid(uid.to_s)
end
end
attributes :uid, :last_scribe_id, :synced
def sessions
Session.for_client(self)
end
def scribe... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/marshal.rb | Ruby | mit | 47 | master | 204 | module Syncro
class Client
include SuperModel::Marshal::Model
marshal :except => :connection
end
module Scriber
class Scribe
include SuperModel::Marshal::Model
end
end
end |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/rpc.rb | Ruby | mit | 47 | master | 1,213 | module Syncro
module RPC
def klasses
@klasses ||= []
end
module_function :klasses
def invoke(session, message)
unless klasses.include?(message[:klass])
session.app.error(404)
return
end
klass = message[:klass].constantize
unless klass.re... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/scriber.rb | Ruby | mit | 47 | master | 307 | module Syncro
module Scriber
def klasses
@klasses ||= []
end
module_function :klasses
def disable(&block)
Observer.disable(&block)
end
module_function :disable
def active?
!!Observer.from_scribe
end
module_function :active?
end
end |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/scriber/model.rb | Ruby | mit | 47 | master | 1,469 | module Syncro
module Scriber
module Model
def self.included(base)
base.send :include, Base
base.extend ClassMethods
Observer.instance.add_observer!(base)
end
def scribe_clients
:all
end
def scribe_disabled=(bool)
@scribe_disabled ... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/scriber/base.rb | Ruby | mit | 47 | master | 390 | module Syncro
module Scriber
module Base
def self.included(base)
Scriber.klasses << base
base.extend ClassMethods
end
module ClassMethods
def record(type, options = {})
options.merge!({
:klass => self,
:type => type
})
... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/scriber/observer.rb | Ruby | mit | 47 | master | 4,093 | module Syncro
module Scriber
class Observer
include Singleton
class_attribute :observed_methods
self.observed_methods = []
class << self
# So we can use this Observer on ActiveRecord classes
def method_added(method) #:nodoc:
return unless defined?(ActiveRec... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/scriber/scribe_observer.rb | Ruby | mit | 47 | master | 552 | module Syncro
module Scriber
class ScribeObserver
include Singleton
def after_create(scribe)
sessions = scribe.to_sessions
sessions.each {|c| c.add_scribe(scribe) }
end
def update(observed_method, object) #:nodoc:
send(observed_method, object) if respond_t... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/scriber/scribe.rb | Ruby | mit | 47 | master | 2,689 | module Syncro
module Scriber
class Scribe < SuperModel::Base
include SuperModel::RandomID
# In Rails 3, this defaults to true.
# We don't want it, otherwise the protocols invalid.
self.include_root_in_json = false
class << self
def since(client, scribe_id)
... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/redis/scribe.rb | Ruby | mit | 47 | master | 895 | module Syncro
module Redis
class Syncro::Scriber::Scribe
include SuperModel::Redis::Model
class << self
def since(client, scribe_id)
items = redis.zrangebyscore(redis_key(:clients, client.id), "(#{scribe_id}", "+inf")
items += redis.zrangebyscore(redis_key(:clients,... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/protocol/message_buffer.rb | Ruby | mit | 47 | master | 882 | module Syncro
module Protocol
class MessageBuffer < StringIO
def clear
truncate(0)
end
# How much left to be read
def left
size - pos
end
def back(n)
seek(n * -1, IO::SEEK_CUR)
end
def trim
string.replace(read)
... |
github | maccman/syncro | https://github.com/maccman/syncro | lib/syncro/protocol/message.rb | Ruby | mit | 47 | master | 584 | module Syncro
module Protocol
class Message < HashWithIndifferentAccess
def self.fromJSON(str)
self.new(ActiveSupport::JSON.decode(str))
rescue StandardError
raise "Invalid JSON string: #{str}"
end
def type
self[:type].try(:to_sym)
end
def type=(val)... |
github | maccman/syncro | https://github.com/maccman/syncro | examples/test_server.rb | Ruby | mit | 47 | master | 949 | $: << File.expand_path(File.join(File.dirname(__FILE__), ".."))
require File.join(*%w[lib syncro])
require "eventmachine"
require "supermodel"
class Test < SuperModel::Base
include SuperModel::Marshal::Model
include Syncro::Model
attributes :name
def scribe_clients
[:client_uuid1, :client_uuid2]
e... |
github | maccman/syncro | https://github.com/maccman/syncro | examples/test_client.rb | Ruby | mit | 47 | master | 884 | $: << File.expand_path(File.join(File.dirname(__FILE__), ".."))
require File.join(*%w[lib syncro])
require "eventmachine"
require "supermodel"
class Test < SuperModel::Base
include SuperModel::Marshal::Model
include Syncro::Model
attributes :name
end
class MyConnection < EM::Connection
def connection_comp... |
github | maccman/syncro | https://github.com/maccman/syncro | examples/syncro.ru | Ruby | mit | 47 | master | 750 | #!/usr/bin/env ruby
require File.expand_path('../config/environment', __FILE__)
require 'cramp'
require 'cramp/controller'
Cramp::Controller::Websocket.backend = :thin
class SyncroWebSocket < Cramp::Controller::Websocket
on_start :post_init
on_finish :unbind
on_data :receive_message
alias_method :sen... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | uirusu.gemspec | Ruby | mit | 47 | master | 2,160 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | Rakefile | Ruby | mit | 47 | master | 2,122 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | test/test_helper.rb | Ruby | mit | 47 | master | 1,281 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | test/functional/vtfile_test.rb | Ruby | mit | 47 | master | 3,014 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | test/functional/application_test.rb | Ruby | mit | 47 | master | 2,368 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | test/functional/vturl_test.rb | Ruby | mit | 47 | master | 3,248 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu.rb | Ruby | mit | 47 | master | 3,180 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/vtipaddr.rb | Ruby | mit | 47 | master | 1,583 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/vtcomment.rb | Ruby | mit | 47 | master | 2,647 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/vtresult.rb | Ruby | mit | 47 | master | 4,812 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/vturl.rb | Ruby | mit | 47 | master | 2,421 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/vtdomain.rb | Ruby | mit | 47 | master | 1,598 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/scanner.rb | Ruby | mit | 47 | master | 1,967 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/vtfile.rb | Ruby | mit | 47 | master | 7,848 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/version.rb | Ruby | mit | 47 | master | 1,316 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | hammackj/uirusu | https://github.com/hammackj/uirusu | lib/uirusu/cli/application.rb | Ruby | mit | 47 | master | 11,248 | # Copyright (c) 2010-2017 Jacob Hammack.
#
# 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, merge, publish,... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | Gemfile | Ruby | mit | 47 | master | 400 | source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "minitest", ">= 0"
gem "bundler", "~> 1.0"
gem "jewel... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | Rakefile | Ruby | mit | 47 | master | 1,738 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
BUNDLE_VERSION = File.exist?('VERSION') ? File.read('VERSION').strip : ""
... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | version_bumper.gemspec | Ruby | mit | 47 | master | 1,771 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "version_bumper"
s.version = "0.4.1.pre1"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :re... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | test/test_version_bumper.rb | Ruby | mit | 47 | master | 5,665 | require 'helper'
class TestVersionBumper < MiniTest::Test
def test_version_new
assert_equal Bumper::Version.new.to_s, '0.0.0.0'
assert_equal Bumper::Version.new('0.0.0-alpha.0').to_s, '0.0.0-alpha.0'
assert_equal Bumper::Version.new('0.0.0-alpha').to_s, '0.0.0-alpha'
assert_equal Bumper::Version.new(... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | test/helper.rb | Ruby | mit | 47 | master | 488 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
if ENV["COVERAGE"]
require 'simplecov'
SimpleCov.start
end
$LOAD_PATH.unshift(File.d... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | lib/version_bumper.rb | Ruby | mit | 47 | master | 1,311 | require 'rake'
require 'bumper/version'
@vfile = 'VERSION'
def bumper_file(file)
@vfile = file
end
def bumper_version
@version ||= Bumper::Version.new(File.read(@vfile))
end
namespace :bump do
desc "create a blank version file"
task :init do
@version = Bumper::Version.new('0.0.0.0')
@version.write... |
github | jondot/version_bumper | https://github.com/jondot/version_bumper | lib/bumper/version.rb | Ruby | mit | 47 | master | 3,291 | module Bumper
class Version
[:major, :minor, :patch, :build].each do |part|
define_method part do
@v[part]
end
define_method "#{part}=" do |arg|
@v[part] = arg
end
define_method "bump_#{part}" do
bump(part)
end
end
def initialize(v =... |
github | testdouble/noncommittal | https://github.com/testdouble/noncommittal | noncommittal.gemspec | Ruby | mit | 47 | main | 985 | require_relative "lib/noncommittal/version"
Gem::Specification.new do |spec|
spec.name = "noncommittal"
spec.version = Noncommittal::VERSION
spec.authors = ["Justin Searls"]
spec.email = ["searls@gmail.com"]
spec.summary = "Ensures test isolation by preventing your Rails tests from committing to the databas... |
github | testdouble/noncommittal | https://github.com/testdouble/noncommittal | lib/noncommittal.rb | Ruby | mit | 47 | main | 1,698 | require "noncommittal/version"
module Noncommittal
def self.start!(tables: nil, exclude_tables: [])
raise "noncommittal is only designed to be run in your test environment!" unless Rails.env.test?
tables ||= __gather_default_tables
tables = tables.map(&:to_s) - exclude_tables.map(&:to_s)
ActiveReco... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | adequate_errors.gemspec | Ruby | mit | 47 | master | 1,063 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "adequate_errors/version"
Gem::Specification.new do |spec|
spec.name = "adequate_errors"
spec.version = AdequateErrors::VERSION
spec.license = 'MIT'
spec.authors = ["lulalala"]
... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | Rakefile | Ruby | mit | 47 | master | 519 | require "bundler/gem_tasks"
require "rake/testtask"
dir = File.dirname(__FILE__)
task default: :test
task :package
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb")
t.warning = true
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end
... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/cases/helper.rb | Ruby | mit | 47 | master | 771 | require "active_model"
# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true
# Disable available locale checks to avoid warnings running the test suite.
I18n.enforce_available_locales = false
require "active_support/testing/autorun"
require "active_support/testing/met... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/cases/validations_test.rb | Ruby | mit | 47 | master | 13,759 | require "cases/helper"
require "adequate_errors"
require "models/topic"
require "models/reply"
require "models/custom_reader"
require "active_support/json"
require "active_support/xml_mini"
class ValidationsTest < ActiveModel::TestCase
class CustomStrictValidationException < StandardError; end
def teardown
... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/cases/adequate_errors/interceptor_test.rb | Ruby | mit | 47 | master | 2,773 | require "minitest/autorun"
require "active_model"
require "models/topic"
require 'adequate_errors'
describe AdequateErrors::Interceptor do
let(:model) { Topic.new }
let(:adequate_errors) { model.errors.adequate }
describe '#initialize' do
it 'initialize adequate_errors object' do
assert_equal ActiveMo... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/cases/adequate_errors/nested_error_test.rb | Ruby | mit | 47 | master | 1,243 | require "cases/helper"
require "minitest/autorun"
require 'rspec/mocks/minitest_integration'
require 'adequate_errors'
require "models/topic"
require "models/reply"
describe AdequateErrors::NestedError do
let(:topic) { Topic.new }
let(:inner_error) { AdequateErrors::Error.new(topic, :mineral, :not_enough, count: 2... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/cases/adequate_errors/errors_test.rb | Ruby | mit | 47 | master | 4,779 | require "minitest/autorun"
require "active_model"
require "models/topic"
require 'adequate_errors'
describe AdequateErrors::Errors do
let(:model) { Topic.new }
let(:rails_errors) { ActiveModel::Errors.new(model) }
subject { AdequateErrors::Errors.new(model) }
describe '#add' do
it 'assigns attributes' do
... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/cases/adequate_errors/error_test.rb | Ruby | mit | 47 | master | 3,937 | require "cases/helper"
require "minitest/autorun"
require 'adequate_errors'
require "models/topic"
describe AdequateErrors::Error do
subject { AdequateErrors::Error.new(self, :mineral, :not_enough, count: 2) }
describe '#initialize' do
it 'assigns attributes' do
assert_equal self, subject.base
ass... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/models/reply.rb | Ruby | mit | 47 | master | 819 | require "models/topic"
class Reply < Topic
validate :errors_on_empty_content
validate :title_is_wrong_create, on: :create
validate :check_empty_title
validate :check_content_mismatch, on: :create
validate :check_wrong_update, on: :update
def check_empty_title
errors[:title] << "is Empty" unless ... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/models/custom_reader.rb | Ruby | mit | 47 | master | 225 | class CustomReader
include ActiveModel::Validations
def initialize(data = {})
@data = data
end
def []=(key, value)
@data[key] = value
end
def read_attribute_for_validation(key)
@data[key]
end
end |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | test/models/topic.rb | Ruby | mit | 47 | master | 783 | class Topic
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
def self._validates_default_keys
super | [ :message ]
end
attr_accessor :title, :author_name, :content, :approved, :created_at
attr_accessor :after_validation_performed
after_validation :perform_after_validatio... |
github | lulalala/adequate_errors | https://github.com/lulalala/adequate_errors | lib/adequate_errors/interceptor.rb | Ruby | mit | 47 | master | 1,193 | require "active_model/errors"
require "adequate_errors/errors"
module AdequateErrors
# Wraps around Rails' errors object, intercepting its state changes
# in order to update AdequateErrors' errors object.
module Interceptor
def initialize(base)
rails_errors = super
@adequate_errors = ::AdequateEr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.