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
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/type_factory.rb
Ruby
mit
91
master
5,553
# frozen_string_literal: true require 'avromatic/model/types/array_type' require 'avromatic/model/types/boolean_type' require 'avromatic/model/types/custom_type' require 'avromatic/model/types/date_type' require 'avromatic/model/types/decimal_type' require 'avromatic/model/types/enum_type' require 'avromatic/model/typ...
github
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/decimal_type.rb
Ruby
mit
91
master
1,156
# frozen_string_literal: true require 'bigdecimal' require 'bigdecimal/util' require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class DecimalType < AbstractType VALUE_CLASSES = [::BigDecimal].freeze INPUT_CLASSES = [::BigDecimal, ::Float, ::Integer].fr...
github
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/integer_type.rb
Ruby
mit
91
master
984
# frozen_string_literal: true require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class IntegerType < AbstractType VALUE_CLASSES = [::Integer].freeze MAX_RANGE = 2**31 def self.in_range?(value) value.is_a?(::Integer) && value.between...
github
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/array_type.rb
Ruby
mit
91
master
1,416
# frozen_string_literal: true require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class ArrayType < AbstractType VALUE_CLASSES = [::Array].freeze attr_reader :value_type def initialize(value_type:) super() @value_type = val...
github
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/union_type.rb
Ruby
mit
91
master
3,327
# frozen_string_literal: true require 'avromatic/io' require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class UnionType < AbstractType attr_reader :member_types, :value_classes, :input_classes def initialize(member_types:) super() ...
github
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/custom_type.rb
Ruby
mit
91
master
2,128
# frozen_string_literal: true require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class CustomType < AbstractType IDENTITY_PROC = Proc.new { |value| value } attr_reader :custom_type_configuration, :value_classes, :default_type def initialize(c...
github
salsify/avromatic
https://github.com/salsify/avromatic
lib/avromatic/model/types/enum_type.rb
Ruby
mit
91
master
1,365
# frozen_string_literal: true require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class EnumType < AbstractType VALUE_CLASSES = [::String].freeze INPUT_CLASSES = [::String, ::Symbol].freeze attr_reader :allowed_values def initialize(al...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
make_flaggable.gemspec
Ruby
mit
91
master
1,121
# -*- encoding: utf-8 -*- require File.expand_path("../lib/make_flaggable/version", __FILE__) Gem::Specification.new do |s| s.name = "make_flaggable" s.version = MakeFlaggable::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Kai Schlamp"] s.email = ["schlamp@gmx.de"] s.homepa...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
Appraisals
Ruby
mit
91
master
793
appraise "rails_3_0" do gem "activerecord", "~> 3.0.0" gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby gem 'sqlite3', :platforms => :ruby gem 'database_cleaner', '1.0.1' end appraise "rails_3_1" do gem "activerecord", "~> 3.1.0" gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby ge...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/make_flaggable.rb
Ruby
mit
91
master
767
require 'make_flaggable/flagging' require 'make_flaggable/flaggable' require 'make_flaggable/flagger' require 'make_flaggable/exceptions' module MakeFlaggable def flaggable? false end def flagger? false end # Specify a model as flaggable. # Optional option :once_per_flagger when only on flag per ...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/make_flaggable/flagger.rb
Ruby
mit
91
master
2,401
module MakeFlaggable module Flagger extend ActiveSupport::Concern included do has_many :flaggings, :class_name => "MakeFlaggable::Flagging", :as => :flagger end module ClassMethods def flagger? true end # Returns flaggers who have flagged any resource # If +fla...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/make_flaggable/flagging.rb
Ruby
mit
91
master
205
module MakeFlaggable class Flagging < ActiveRecord::Base belongs_to :flaggable, :polymorphic => true, counter_cache: true belongs_to :flagger, :polymorphic => true, counter_cache: true end end
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/make_flaggable/flaggable.rb
Ruby
mit
91
master
392
module MakeFlaggable module Flaggable extend ActiveSupport::Concern included do has_many :flaggings, :class_name => "MakeFlaggable::Flagging", :as => :flaggable end module ClassMethods def flaggable? true end end def flagged? flaggings.count > 0 end ...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/make_flaggable/exceptions.rb
Ruby
mit
91
master
470
module MakeFlaggable module Exceptions class AlreadyFlaggedError < StandardError def initialize super "The flaggable was already flagged by this flagger." end end class NotFlaggedError < StandardError def initialize super "The flaggable was not flagged by the flagger." ...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/generators/make_flaggable/make_flaggable_generator.rb
Ruby
mit
91
master
542
require 'rails/generators/migration' require 'rails/generators/active_record' class MakeFlaggableGenerator < Rails::Generators::Base include Rails::Generators::Migration desc "Generates a migration for the Flag model" def self.source_root @source_root ||= File.dirname(__FILE__) + '/templates' end def ...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
lib/generators/make_flaggable/templates/migration.rb
Ruby
mit
91
master
652
class CreateMakeFlaggableTables < ActiveRecord::Migration def self.up create_table :flaggings do |t| t.string :flaggable_type t.integer :flaggable_id t.string :flagger_type t.integer :flagger_id t.text :reason t.timestamps end add_index :flaggings, [:flaggable...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
spec/schema.rb
Ruby
mit
91
master
950
ActiveRecord::Schema.define :version => 0 do create_table :flaggable_models, :force => true do |t| t.string :name t.integer :flaggings_count end create_table :flagger_models, :force => true do |t| t.string :name t.integer :flaggings_count end create_table :flagger_once_models, :force => true...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
spec/models.rb
Ruby
mit
91
master
332
class FlaggableModel < ActiveRecord::Base make_flaggable end class FlaggerModel < ActiveRecord::Base make_flagger end class FlaggerOnceModel < ActiveRecord::Base make_flagger :flag_once => true end class InvalidFlaggableModel < ActiveRecord::Base end class AnotherFlaggableModel < ActiveRecord::Base make_fla...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
spec/spec_helper.rb
Ruby
mit
91
master
969
require 'rubygems' require 'bundler' require 'logger' require 'rspec' require 'active_record' require 'database_cleaner' $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') require 'make_flaggable' ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log') ActiveRecord::Base.configurations = YAM...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
spec/generators/make_flaggable_generator_spec.rb
Ruby
mit
91
master
679
require 'spec_helper' require 'action_controller' require 'generator_spec/test_case' require 'generators/make_flaggable/make_flaggable_generator' describe MakeFlaggableGenerator do include GeneratorSpec::TestCase destination File.expand_path("/tmp", __FILE__) tests MakeFlaggableGenerator before do prepare...
github
medihack/make_flaggable
https://github.com/medihack/make_flaggable
spec/lib/make_flaggable_spec.rb
Ruby
mit
91
master
4,784
require File.expand_path('../../spec_helper', __FILE__) describe "Make Flaggable" do before(:each) do @flaggable = FlaggableModel.create(:name => "Flaggable 1") @flagger = FlaggerModel.create(:name => "Flagger 1") @flagger_once = FlaggerOnceModel.create(:name => "Flagger Once 1") end it "should crea...
github
mahm/zurui-sass-rails
https://github.com/mahm/zurui-sass-rails
zurui-sass-rails.gemspec
Ruby
mit
91
master
1,782
# -*- encoding: utf-8 -*- require File.expand_path('../lib/zurui-sass-rails/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["mah_lab"] gem.email = ["rootmoon@gmail.com"] gem.description = %q{Sass mixins by zurui-design(https://speakerdeck.com/ken_c_lo/zurui-design)} gem.summa...
github
SAML-Toolkits/ruby-saml-example
https://github.com/SAML-Toolkits/ruby-saml-example
Gemfile
Ruby
mit
91
master
1,386
source 'https://rubygems.org' gem 'ruby-saml', '~> 1.7.0' gem 'byebug' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.5' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript...
github
SAML-Toolkits/ruby-saml-example
https://github.com/SAML-Toolkits/ruby-saml-example
app/controllers/saml_controller.rb
Ruby
mit
91
master
4,270
class SamlController < ApplicationController skip_before_action :verify_authenticity_token, :only => [:acs, :logout] def index @attrs = {} end def sso settings = Account.get_saml_settings(get_url_base) if settings.nil? render :action => :no_settings return end request = OneLog...
github
SAML-Toolkits/ruby-saml-example
https://github.com/SAML-Toolkits/ruby-saml-example
app/models/account.rb
Ruby
mit
91
master
1,780
class Account < ActiveRecord::Base def self.get_saml_settings(url_base) # this is just for testing purposes. # should retrieve SAML-settings based on subdomain, IP-address, NameID or similar settings = OneLogin::RubySaml::Settings.new url_base ||= "http://localhost:3000" # Example settings data,...
github
SAML-Toolkits/ruby-saml-example
https://github.com/SAML-Toolkits/ruby-saml-example
config/routes.rb
Ruby
mit
91
master
1,760
Rails.application.routes.draw do resources :saml, only: :index do collection do get :sso post :acs get :metadata get :logout end end root 'saml#index' # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "r...
github
SAML-Toolkits/ruby-saml-example
https://github.com/SAML-Toolkits/ruby-saml-example
config/application.rb
Ruby
mit
91
master
1,217
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
SAML-Toolkits/ruby-saml-example
https://github.com/SAML-Toolkits/ruby-saml-example
db/schema.rb
Ruby
mit
91
master
911
# 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
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
Gemfile
Ruby
mit
91
master
890
# frozen_string_literal: true ruby '3.4.8' source 'https://rubygems.org' gem 'avro', '~> 1.10.0' gem 'avro-resolution_canonical_form', '>= 0.2.0' gem 'bootsnap', require: false gem 'grape', '~> 2.2.0' # newer versions result in content-type issues gem 'pg' gem 'private_attr', require: 'private_attr/everywhere' gem '...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/spec_helper.rb
Ruby
mit
91
master
609
# frozen_string_literal: true # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration require 'simplecov' RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| # ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/schema_registry_spec.rb
Ruby
mit
91
master
9,335
# frozen_string_literal: true describe SchemaRegistry do let(:json_hash) do { type: :record, name: :rec, fields: [ { name: :field1, type: :string, default: '' }, { name: :field2, type: :string } ] } end let(:old_json) { json_hash.to_json } let(:schema) { create(:...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/rails_helper.rb
Ruby
mit
91
master
901
# frozen_string_literal: true ENV['RAILS_ENV'] ||= 'test' require 'simplecov' SimpleCov.start 'rails' require File.expand_path('../config/environment', __dir__) # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production? require...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/schemas/parse_spec.rb
Ruby
mit
91
master
486
# frozen_string_literal: true describe Schemas::Parse do describe ".call" do let(:json) { build(:schema).json } let(:schema) { described_class.call(json) } it "returns an Avro::Schema" do expect(schema).to be_a(Avro::Schema) end context "with an invalid schema" do let(:json) { {}.t...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/factories/configs.rb
Ruby
mit
91
master
396
# frozen_string_literal: true # == Schema Information # # Table name: configs # # id :integer not null, primary key # compatibility :string # created_at :datetime not null # updated_at :datetime not null # subject_id :integer # FactoryBot.define do factory :config d...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/factories/schemas.rb
Ruby
mit
91
master
823
# frozen_string_literal: true # == Schema Information # # Table name: schemas # # id :integer not null, primary key # fingerprint :string not null # json :text not null # created_at :datetime not null # updated_at :datetime not null # fingerpr...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/factories/schema_versions.rb
Ruby
mit
91
master
375
# frozen_string_literal: true # == Schema Information # # Table name: schema_versions # # id :integer not null, primary key # version :integer default(1) # subject_id :integer not null # schema_id :integer not null # FactoryBot.define do factory :schema_version, a...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/factories/subjects.rb
Ruby
mit
91
master
512
# frozen_string_literal: true # == Schema Information # # Table name: subjects # # id :integer not null, primary key # name :text not null # created_at :datetime not null # updated_at :datetime not null # FactoryBot.define do factory :subject, aliases: [:value_...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/support/rails_configuration_custom.rb
Ruby
mit
91
master
291
# frozen_string_literal: true # Monkey-patch Rails::Application::Configuration::Custom to allow configuration # to be stubbed. module Rails class Application::Configuration::Custom # rubocop:disable Style/ClassAndModuleChildren def respond_to_missing?(*) true end end end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/support/helpers/request_helper.rb
Ruby
mit
91
master
1,150
# frozen_string_literal: true # Helper to set Basic authentication for requests. module RequestHelper extend ActiveSupport::Concern GRAPE_ROUTE_METHODS = [:get, :post, :put, :head, :delete, :patch].freeze included do GRAPE_ROUTE_METHODS.each do |method| # Alias the original method so we can explicitl...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/support/contexts/secure_endpoint.rb
Ruby
mit
91
master
418
# frozen_string_literal: true shared_examples_for "a secure endpoint" do context "when HTTP Basic password is disabled" do before do allow(Rails.configuration.x).to receive(:disable_password).and_return(true) end it "allows unauthorized requests" do action expect(status).to eq(200) ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/support/contexts/cached_endpoint.rb
Ruby
mit
91
master
897
# frozen_string_literal: true shared_examples_for "a cached endpoint" do context "when caching is enabled" do before do allow(Rails.configuration.x).to receive(:allow_response_caching).and_return(true) end it "allows the response to be cached" do action expect(response.headers['Cache-C...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/support/contexts/content_type_context.rb
Ruby
mit
91
master
1,485
# frozen_string_literal: true # This shared example expects the following variables to be defined # @param :expected [JSON] JSON response # @param :path [String] Request path # @param :params [Hash, NilClass] Optional params for request shared_examples_for "content type" do |verb| let(:_params) { defined?(params) ? ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/controllers/pages_controller_spec.rb
Ruby
mit
91
master
424
# frozen_string_literal: true describe PagesController do render_views describe "#index" do it "renders the index file" do get(:index) expect(response.body).to eq(IO.read("#{Rails.root}/public/index.html")) end end describe "#success" do it "renders the success file" do get(:suc...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/models/schema_spec.rb
Ruby
mit
91
master
3,846
# frozen_string_literal: true describe Schema do before do allow(Rails.configuration.x).to receive(:fingerprint_version).and_return(fingerprint_version) end describe '#save' do let(:schema) { build(:schema) } before do schema.save! end context "when fingerprint_version is '1'" do ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/requests/subject_api_spec.rb
Ruby
mit
91
master
30,185
# frozen_string_literal: true describe SubjectAPI do let(:invalid_json) do # invalid due to missing record name { type: :record, fields: [{ name: :i, type: :int }] }.to_json end context "content type" do # content type is configured at the API level so only one endpoint is # tested here. inc...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/requests/compatibility_api_spec.rb
Ruby
mit
91
master
5,085
# frozen_string_literal: true describe CompatibilityAPI do describe "POST /compatibility/subjects/:subject/versions/:version" do let(:version) { create(:schema_version) } let(:subject_name) { version.subject.name } let(:schema) do JSON.parse(version.schema.json).tap do |avro| avro['fields'...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/requests/schema_api_spec.rb
Ruby
mit
91
master
1,432
# frozen_string_literal: true require 'rails_helper' describe SchemaAPI do describe "GET /schemas/ids/:id" do let(:schema) { create(:schema) } it_behaves_like "a secure endpoint" do let(:action) { unauthorized_get("/schemas/ids/#{schema.id}") } end context "content type" do include_exa...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
spec/requests/config_api_spec.rb
Ruby
mit
91
master
6,201
# frozen_string_literal: true describe ConfigAPI do let(:expected) do { compatibility: compatibility }.to_json end describe "GET /config" do let(:compatibility) { Compatibility.global } it "returns the global compatibility level" do get('/config') expect(response).to be_ok expect(...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schema_registry.rb
Ruby
mit
91
master
2,468
# frozen_string_literal: true module SchemaRegistry InvalidAvroSchemaError = Class.new(StandardError) IncompatibleAvroSchemaError = Class.new(StandardError) extend self def compatible?(new_json, version:, compatibility: nil) compatibility ||= version.subject.config.try(:compatibility) || Compatibility.gl...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/subject.rb
Ruby
mit
91
master
640
# frozen_string_literal: true # == Schema Information # # Table name: subjects # # id :integer not null, primary key # name :text not null # created_at :datetime not null # updated_at :datetime not null # class Subject < ApplicationRecord include ImmutableModel...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schema.rb
Ruby
mit
91
master
1,955
# frozen_string_literal: true # == Schema Information # # Table name: schemas # # id :integer not null, primary key # fingerprint :string not null # json :text not null # created_at :datetime not null # updated_at :datetime not null # fingerpr...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schema_version.rb
Ruby
mit
91
master
979
# frozen_string_literal: true # == Schema Information # # Table name: schema_versions # # id :integer not null, primary key # version :integer default(1) # subject_id :integer not null # schema_id :integer not null # class SchemaVersion < ApplicationRecord include...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/config.rb
Ruby
mit
91
master
1,125
# frozen_string_literal: true # == Schema Information # # Table name: configs # # id :integer not null, primary key # compatibility :string # created_at :datetime not null # updated_at :datetime not null # subject_id :integer # class Config < ApplicationRecord # Th...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/compatibility.rb
Ruby
mit
91
master
810
# frozen_string_literal: true module Compatibility module Constants BOTH = 'BOTH' # deprecated BACKWARD = 'BACKWARD' BACKWARD_TRANSITIVE = 'BACKWARD_TRANSITIVE' FORWARD = 'FORWARD' FORWARD_TRANSITIVE = 'FORWARD_TRANSITIVE' FULL = 'FULL' FULL_TRANSITIVE = 'FULL_TRANSITIVE' NONE = 'NON...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schema_registry/errors.rb
Ruby
mit
91
master
871
# frozen_string_literal: true module SchemaRegistry # This module contains error codes and messages defined by the Confluent # schema registry. module Errors SUBJECT_NOT_FOUND = { error_code: 40401, message: 'Subject not found' }.freeze VERSION_NOT_FOUND = { error_code: 40402, message: 'Version not foun...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schemas/register_new_version.rb
Ruby
mit
91
master
3,396
# frozen_string_literal: true module Schemas # This class is called to register a new version of a schema. # If the schema already exists, then the existing model object is returned. # Subjects and SchemaVersions are created as necessary. # Race conditions are protected against by relying on unique indexes on ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schemas/fingerprint_generator.rb
Ruby
mit
91
master
1,005
# frozen_string_literal: true module Schemas # This module is used to standardize the fingerprint generation for an # Avro JSON schema module FingerprintGenerator VALID_FINGERPRINT_VERSIONS = ['1', '2', 'all'].to_set.freeze V1_VERSIONS = ['1', 'all'].to_set.freeze V2_VERSIONS = ['2', 'all'].to_set....
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/schemas/parse.rb
Ruby
mit
91
master
321
# frozen_string_literal: true module Schemas # This module is used to wrap Avro schema parsing to raise a standard error # if any exception is raised. module Parse def self.call(json) Avro::Schema.parse(json) rescue StandardError raise SchemaRegistry::InvalidAvroSchemaError end end end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/models/concerns/immutable_model.rb
Ruby
mit
91
master
510
# frozen_string_literal: true # All of the models in this application are insert only. This concern # is used to ensure that they remain immutable. module ImmutableModel extend ActiveSupport::Concern included do delegate :read_only_model!, to: :class alias_method :delete, :read_only_model! end def re...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/config_api.rb
Ruby
mit
91
master
1,650
# frozen_string_literal: true class ConfigAPI < Grape::API include BaseAPI rescue_from Compatibility::InvalidCompatibilityLevelError do invalid_compatibility_level! end rescue_from :all do server_error! end helpers do def find_subject!(name) Subject.eager_load(:config).find_by!(name: n...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/schema_api.rb
Ruby
mit
91
master
480
# frozen_string_literal: true class SchemaAPI < Grape::API include BaseAPI rescue_from ActiveRecord::RecordNotFound do schema_not_found! end rescue_from :all do server_error! end helpers ::Helpers::CacheHelper desc 'Get the schema string identified by the input id' params do requires :i...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/compatibility_api.rb
Ruby
mit
91
master
1,473
# frozen_string_literal: true class CompatibilityAPI < Grape::API include BaseAPI helpers ::Helpers::SchemaVersionHelper rescue_from SchemaRegistry::InvalidAvroSchemaError do invalid_avro_schema! end rescue_from Grape::Exceptions::ValidationErrors do |e| if e.errors.keys == [['with_compatibility']...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/subject_api.rb
Ruby
mit
91
master
4,533
# frozen_string_literal: true class SubjectAPI < Grape::API include BaseAPI INTEGER_FINGERPRINT_REGEXP = /^[0-9]+$/ rescue_from ActiveRecord::RecordNotFound do subject_not_found! end rescue_from SchemaRegistry::InvalidAvroSchemaError do invalid_avro_schema! end rescue_from SchemaRegistry::Inc...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/base_api.rb
Ruby
mit
91
master
1,112
# frozen_string_literal: true require 'grape/middleware/optional_auth' # This module provides shared configuration for the Schema Registry API module BaseAPI extend ActiveSupport::Concern SCHEMA_REGISTRY_V1_CONTENT_TYPE = 'application/vnd.schemaregistry.v1+json' SCHEMA_REGISTRY_CONTENT_TYPE = 'application/vnd....
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/helpers/error_helper.rb
Ruby
mit
91
master
973
# frozen_string_literal: true module Helpers # This module defines helpers for the documented errors that the schema # registry may return. module ErrorHelper def server_error! error!(SchemaRegistry::Errors::SERVER_ERROR, 500) end def subject_not_found! error!(SchemaRegistry::Errors::S...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/helpers/cache_helper.rb
Ruby
mit
91
master
348
# frozen_string_literal: true module Helpers module CacheHelper CACHE_CONTROL_HEADER = 'Cache-Control' CACHE_CONTROL_VALUE = "public, max-age=#{Rails.configuration.x.cache_max_age}".freeze def cache_response! header(CACHE_CONTROL_HEADER, CACHE_CONTROL_VALUE) if Rails.configuration.x.allow_respons...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/api/helpers/schema_version_helper.rb
Ruby
mit
91
master
793
# frozen_string_literal: true module Helpers module SchemaVersionHelper include Helpers::ErrorHelper LATEST_VERSION = 'latest' private def with_schema_version(subject_name, version) schema_version = find_schema_version(subject_name, version) if schema_version yield schema_ver...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
app/controllers/pages_controller.rb
Ruby
mit
91
master
463
# frozen_string_literal: true class PagesController < ApplicationController # This page is primarily for the benefit of the schema registry hosted # at avro-schema-registry.salsify.com def index render(file: "#{Rails.root}/public/index.html", layout: false) end # This page is displayed after successful...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
lib/dual_heroku_rails_deploy.rb
Ruby
mit
91
master
387
# frozen_string_literal: true require 'heroku_rails_deploy/deployer' module DualHerokuRailsDeploy def self.deploy(root_dir, args) config_file = File.join(root_dir, 'config', 'heroku.yml') deploy = HerokuRailsDeploy::Deployer.new(config_file, args) deploy.run HerokuRailsDeploy::Deployer.new(config_...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
lib/grape/middleware/optional_auth.rb
Ruby
mit
91
master
341
# frozen_string_literal: true module Grape module Middleware # This middleware allows HTTP Basic/Digest middleware to be bypassed based # on configuration. class OptionalAuth < Grape::Middleware::Auth::Base def call(env) Rails.configuration.x.disable_password ? app.call(env) : super e...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
lib/tasks/cache.rake
Ruby
mit
91
master
1,121
# frozen_string_literal: true if Rails.env.development? require 'avro_turf' require 'avro_turf/confluent_schema_registry' desc 'Make cacheable requests for all existing schemas in the registry' task cache_all_requests: [:environment] do raise 'registry_url must be specified' unless ENV['registry_url'] ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/schema.rb
Ruby
mit
91
master
2,076
# 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
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/migrate/20160416174131_create_configs.rb
Ruby
mit
91
master
272
class CreateConfigs < ActiveRecord::Migration[5.0] def change create_table(:configs, id: :bigserial) do |t| t.string :compatibility t.timestamps null: false t.bigint :subject_id end add_index(:configs, :subject_id, unique: true) end end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/migrate/20160315151533_create_schema_versions.rb
Ruby
mit
91
master
335
class CreateSchemaVersions < ActiveRecord::Migration[5.0] def change create_table(:schema_versions, id: :bigserial) do |t| t.integer :version, default: 1 t.bigint :subject_id, null: false t.bigint :schema_id, null: false end add_index(:schema_versions, [:subject_id, :version], unique: t...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/migrate/20170310200653_populate_fingerprint2.rb
Ruby
mit
91
master
355
class PopulateFingerprint2 < ActiveRecord::Migration[5.0] class Schema < ApplicationRecord end def up Schema.find_each(batch_size: 100) do |schema| schema.update_attribute( :fingerprint2, Schemas::FingerprintGenerator.generate_v2(schema.json)) end end def down Schema.updat...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/migrate/20170310182013_add_fingerprint2_to_schemas.rb
Ruby
mit
91
master
294
class AddFingerprint2ToSchemas < ActiveRecord::Migration[5.0] def change add_column(:schemas, :fingerprint2, :string, null: true) add_index(:schemas, :fingerprint2, unique: true) remove_index(:schemas, :fingerprint) add_index(:schemas, :fingerprint, unique: false) end end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/migrate/20160314152739_create_schemas.rb
Ruby
mit
91
master
289
class CreateSchemas < ActiveRecord::Migration[5.0] def change create_table(:schemas, id: :bigserial) do |t| t.string :fingerprint, null: false t.text :json, null: false t.timestamps null: false end add_index(:schemas, :fingerprint, unique: true) end end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
db/migrate/20160314152320_create_subjects.rb
Ruby
mit
91
master
244
class CreateSubjects < ActiveRecord::Migration[5.0] def change create_table(:subjects, id: :bigserial) do |t| t.text :name, null: false t.timestamps null: false end add_index(:subjects, :name, unique: true) end end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/puma.rb
Ruby
mit
91
master
395
# frozen_string_literal: true # Simple configuration based on # https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server workers Integer(ENV['WEB_WORKER_PROCESSES'] || 2) threads_count = Integer(ENV['MAX_WEB_THREADS'] || 5) threads threads_count, threads_count preload_app! port ...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/application.rb
Ruby
mit
91
master
1,798
# frozen_string_literal: true require_relative 'boot' require 'rails' require 'active_model/railtie' require 'active_record/railtie' require 'action_controller/railtie' require 'action_view/railtie' require 'active_support/core_ext/integer/time' # Require the gems listed in Gemfile, including any gems # you've limi...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/routes.rb
Ruby
mit
91
master
278
# frozen_string_literal: true Rails.application.routes.draw do mount SchemaAPI => '/schemas' mount SubjectAPI => '/subjects' mount ConfigAPI => '/config' mount CompatibilityAPI => '/compatibility' get '/', to: 'pages#index' get '/success', to: 'pages#success' end
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/initializers/reload_api.rb
Ruby
mit
91
master
550
# frozen_string_literal: true # Grape reloading support # https://github.com/ruby-grape/grape#reloading-api-changes-in-development # Note: adding to explicitly_unloadable_constants caused problems with Spring # so that recommendation from above is not followed. if Rails.env.development? api_files = Dir[Rails.root.j...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/initializers/default_compatibility.rb
Ruby
mit
91
master
346
# frozen_string_literal: true # For Rails to reload this file when it reloads code in development Rails.configuration.to_prepare do if Compatibility::Constants::VALUES.exclude?(Rails.application.config.x.default_compatibility.upcase) raise "Default compatibility '#{Rails.application.config.x.default_compatibilit...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/environments/staging.rb
Ruby
mit
91
master
334
# frozen_string_literal: true require Rails.root.join('config/environments/production') Rails.application.configure do # Settings specified here will take precedence over those in # config/environments/production.rb. config.log_level = :info config.x.default_compatibility = ENV.fetch('DEFAULT_COMPATIBILITY'...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/environments/production.rb
Ruby
mit
91
master
3,571
# frozen_string_literal: true 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, a...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/environments/test.rb
Ruby
mit
91
master
1,616
# frozen_string_literal: true Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "s...
github
salsify/avro-schema-registry
https://github.com/salsify/avro-schema-registry
config/environments/development.rb
Ruby
mit
91
master
1,709
# frozen_string_literal: true Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Do not dump the schema if the environment has DO_NOT_DUMP_SCHEMA set to any value. config.active_record.dump_schema_after_migration = ENV.fetch('DUMP_SCHEMA_AFTER_MI...
github
taganaka/polipus
https://github.com/taganaka/polipus
polipus.gemspec
Ruby
mit
91
master
1,636
# -*- encoding: utf-8 -*- $LOAD_PATH.push File.expand_path('../lib', __FILE__) require 'polipus/version' Gem::Specification.new do |s| s.name = 'polipus' s.version = Polipus::VERSION s.authors = ['Francesco Laurita'] s.email = ['francesco.laurita@gmail.com'] s.homepage = Polipus::HOME...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/spec_helper.rb
Ruby
mit
91
master
1,153
# Require this file using `require "spec_helper"` # to ensure that it is only loaded once. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration require 'digest/md5' require 'coveralls' require 'vcr' require 'webmock/rspec' Coveralls.wear! VCR.configure do |c| c.cassette_library_dir = "#{File.dirname...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/clear.rb
Ruby
mit
91
master
318
# encoding: UTF-8 require 'yaml' Dir.glob('./cassettes/*.yml').each do|f| next unless f =~ /[a-f0-9]{32}/ d = YAML.load_file(f) d['http_interactions'].each do |r| r['request'].delete('headers') r['response'].delete('headers') end File.open(f, 'w') { |fw| fw.write(d.to_yaml) } # puts d.to_yaml end
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus_spec.rb
Ruby
mit
91
master
3,625
# encoding: UTF-8 require 'spec_helper' describe Polipus::PolipusCrawler do after(:each) { Redis.new(db: 10).flushdb } let(:p_options) do { workers: 1, redis_options: { host: 'localhost', db: 10 }, depth_limit: 1, queue_timeout: 1, user_agent: 'polipus-rspec', logger: logger...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/queue_overflow_spec.rb
Ruby
mit
91
master
1,968
# encoding: UTF-8 require 'spec_helper' require 'polipus/queue_overflow' describe Polipus::QueueOverflow do before(:all) do @queue_overflow = Polipus::QueueOverflow.mongo_queue(nil, 'queue_test') @queue_overflow_capped = Polipus::QueueOverflow.mongo_queue_capped(nil, 'queue_test_c', max: 20) @queu...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/robotex_spec.rb
Ruby
mit
91
master
2,492
require 'spec_helper' require 'polipus/robotex' describe Polipus::Robotex do let(:spec_domain) { 'http://www.example.com/' } before(:each) do robots = <<-END User-Agent: msnbot Crawl-Delay: 20 User-Agent: bender Disallow: /my_shiny_metal_ass User-Agent: * Disallow: /login Allow: / Disallow: /locked Allow: /...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/page_spec.rb
Ruby
mit
91
master
1,888
# encoding: UTF-8 require 'spec_helper' require 'polipus/page' describe Polipus::Page do let(:page) do body = <<EOF <html> <body> <a href="/page/1">1</a> <a href="/page/2">2</a> <a href="http://www.google.com/page/3">3</a> <a href="http://google.com/page/3">4</a> ...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/url_tracker_spec.rb
Ruby
mit
91
master
672
# encoding: UTF-8 require 'spec_helper' require 'polipus/url_tracker' describe Polipus::UrlTracker do before(:all) do @bf = Polipus::UrlTracker.bloomfilter @set = Polipus::UrlTracker.redis_set end after(:all) do @bf.clear @set.clear end it 'should work (bf)' do url = 'http://www.asd.co...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/http_spec.rb
Ruby
mit
91
master
6,022
# encoding: UTF-8 require 'spec_helper' require 'mongo' require 'polipus/http' require 'polipus/page' describe Polipus::HTTP do it 'should download a page' do VCR.use_cassette('http_test') do http = Polipus::HTTP.new user_data = { 'mydata' => 'myvalue' } page = http.fetch_page('ht...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/signal_handler_spec.rb
Ruby
mit
91
master
455
require 'spec_helper' describe Polipus::SignalHandler do context 'signal handler' do it 'should be enabled by default' do Polipus::PolipusCrawler.new('polipus-rspec', []) expect(Polipus::SignalHandler.enabled?).to be true end it 'should be disabled if specified' do Polipus::PolipusCraw...
github
taganaka/polipus
https://github.com/taganaka/polipus
spec/polipus/queue_overflow/manager_spec.rb
Ruby
mit
91
master
3,167
# encoding: UTF-8 require 'spec_helper' require 'mongo' require 'polipus/queue_overflow' require 'redis-queue' describe Polipus::QueueOverflow::Manager do before(:all) do @mongo = Mongo::Client.new(['localhost:27_017'], database: '_test_polipus') @mongo['_test_pages'].drop @storage = Polipus::Storage.mon...
github
taganaka/polipus
https://github.com/taganaka/polipus
examples/basic.rb
Ruby
mit
91
master
2,042
# encoding: UTF-8 require 'polipus' require 'mongo' require 'polipus/plugins/cleaner' # Define a Mongo connection mongo = Mongo::Connection.new(pool_size: 15, pool_timeout: 5).db('crawler') # Override some default options options = { # Redis connection redis_options: { host: 'localhost', db: 5, driver:...
github
taganaka/polipus
https://github.com/taganaka/polipus
examples/incremental.rb
Ruby
mit
91
master
1,834
# encoding: UTF-8 require 'polipus' require 'mongo' # Define a Mongo connection mongo = Mongo::Connection.new(pool_size: 15, pool_timeout: 5).db('crawler') # Override some default options options = { # Redis connection redis_options: { host: 'localhost', db: 5, driver: 'hiredis' }, # Page storage: ...