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
timwaters/mapwarper
https://github.com/timwaters/mapwarper
db/migrate/20140814115719_add_reset_password_sent_at_to_users.rb
Ruby
mit
215
master
215
class AddResetPasswordSentAtToUsers < ActiveRecord::Migration def change add_column :users, :reset_password_sent_at, :datetime change_column :users, :reset_password_token, :string, :limit => nil end end
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
db/migrate/20090225160349_acts_as_taggable_migration.rb
Ruby
mit
215
master
659
class ActsAsTaggableMigration < ActiveRecord::Migration def self.up create_table :tags do |t| t.column :name, :string end create_table :taggings do |t| t.column :tag_id, :integer t.column :taggable_id, :integer # You should make sure that the column created is # l...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
db/migrate/20090302214746_create_layer_maps.rb
Ruby
mit
215
master
322
class CreateLayerMaps < ActiveRecord::Migration def self.up create_table :layers_maps, :id => false do |t| t.references :layer, :map t.timestamps end add_index :layers_maps, [:map_id] add_index :layers_maps, [:layer_id] end def self.down drop_table :layers_maps end en...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/routes.rb
Ruby
mit
215
master
8,593
Rails.application.routes.draw do root 'home#index' get '/about' => 'home#about', :as => 'about' get '/help' => 'home#help', :as => 'help' get '/privacy' => 'home#privacy', :as => 'privacy' devise_for :users, :path => 'u',:controllers => { :sessions => "sessions", :omniauth_callbacks => "omniauth_callbacks"...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/application.rb
Ruby
mit
215
master
1,424
require File.expand_path('../boot', __FILE__) 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 Rails4Mapwarper class Application < Rails::Application # Settings in config/environments/* ta...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/deploy.rb
Ruby
mit
215
master
1,599
# config valid only for Capistrano 3.1 lock '3.2.1' set :application, 'mapwarper' set :repo_url, 'git@github.com:timwaters/mapwarper.git' # Default branch is :master # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call set :branch, "master" # Default deploy_to directory is /var/www/my_app # set :depl...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/devise_encryptor.rb
Ruby
mit
215
master
293
require "digest/sha1" module Devise module Encryptable module Encryptors class LegacyRestfulauthentication < Base def self.digest(password, stretches, salt, pepper) '{SHA}'+ Base64.encode64(Digest::SHA1.digest(password)) end end end end end
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/devise.rb
Ruby
mit
215
master
13,331
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmat...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/application_config.rb
Ruby
mit
215
master
1,506
CONFIG_PATH="#{Rails.root}/config/application.yml" APP_CONFIG = YAML.load_file(CONFIG_PATH)[Rails.env] #directories for maps and layer/mosaic tileindex shapefiles DST_MAPS_DIR = APP_CONFIG['dst_maps_dir'].blank? ? File.join(Rails.root, '/public/mapimages/dst/') : APP_CONFIG['dst_maps_dir'] SRC_MAPS_DIR = APP_CONFIG['...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/assets.rb
Ruby
mit
215
master
1,080
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. Rails....
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/mime_types.rb
Ruby
mit
215
master
404
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf Mime::Type.register "application/vnd.google-earth.kml+xml", :kml #Mime::Type.register "image/png", :png Mime::Type.register "application/xml", :aux_xml Mime::Type.r...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/localeapp.rb
Ruby
mit
215
master
434
#if defined?(Rails) && Rails.env.development? # require 'localeapp/rails' # # if defined? APP_CONFIG['localeapp_api_key'] # key = APP_CONFIG['localeapp_api_key'] # else # key = ENV['LOCALEAPP_API_KEY'] # end # # Localeapp.configure do |config| # config.sending_environments = [] # con...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/osm_oauth2.rb
Ruby
mit
215
master
1,567
require 'omniauth-oauth2' module OmniAuth module Strategies class OsmOauth2 < OmniAuth::Strategies::OAuth2 # Give your strategy a name. option :name, "osm_oauth2" # This is where you pass the options you would pass when # initializing your consumer from the OAuth gem. option :clien...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/cors.rb
Ruby
mit
215
master
580
module Rails4Mapwarper class Application < Rails::Application config.middleware.insert_before 0, "Rack::Cors" do allow do origins '*' resource '/api/*', :headers => :any, :expose => ['access-token', 'expiry', 'token-type', 'uid', 'client'], :methods => [:get, :...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/initializers/simple_token_authentication.rb
Ruby
mit
215
master
3,081
SimpleTokenAuthentication.configure do |config| # Configure the session persistence policy after a successful sign in, # in other words, if the authentication token acts as a signin token. # If true, user is stored in the session and the authentication token and # email may be provided only once. # If false,...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/deploy/staging.rb
Ruby
mit
215
master
1,554
# Staging set :deploy_to, '/srv/dev.mapwarper.net/app/' # Simple Role Syntax # ================== # Supports bulk-adding hosts to roles, the primary server in each group # is considered to be the first unless any hosts have the primary # property set. Don't declare `role :all`, it's a meta role. role :app, %w{tim@d...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/deploy/production.rb
Ruby
mit
215
master
1,459
# Simple Role Syntax # ================== # Supports bulk-adding hosts to roles, the primary server in each group # is considered to be the first unless any hosts have the primary # property set. Don't declare `role :all`, it's a meta role. role :app, %w{deploy@example.com} role :web, %w{deploy@example.com} role :db,...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/environments/test.rb
Ruby
mit
215
master
1,805
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 "scratch space" for the test suit...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/environments/development.rb
Ruby
mit
215
master
1,589
Rails.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 serv...
github
timwaters/mapwarper
https://github.com/timwaters/mapwarper
config/environments/production.rb
Ruby
mit
215
master
3,702
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
gemgento/rails_script
https://github.com/gemgento/rails_script
rails_script.gemspec
Ruby
mit
215
master
1,305
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rails_script/version' Gem::Specification.new do |spec| spec.name = 'rails_script' spec.version = RailsScript::VERSION spec.authors = ['Kevin Pheasey'] spec.email ...
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/rails_script.rb
Ruby
mit
215
master
210
require 'rails_script/version' require 'rails_script/engine' require 'rails_script/loader_helper' require 'rails_script/to_javascript' require 'rails_script/railtie' if defined?(Rails) module RailsScript end
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/rails_script/to_javascript.rb
Ruby
mit
215
master
257
module RailsScript module ToJavascript extend ActiveSupport::Concern included do before_action do @to_javascript = {} end end def to_javascript(variables = {}) @to_javascript.merge!(variables) end end end
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/rails_script/loader_helper.rb
Ruby
mit
215
master
305
module RailsScript module LoaderHelper def include_rails_script content_tag :div, nil, id: 'rails-script', data: { controller: controller_path.split(/\/|_/).map(&:capitalize).join(''), action: action_name, vars: @to_javascript.to_json } end end end
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/rails_script/railtie.rb
Ruby
mit
215
master
402
module RailsScript class Railtie < Rails::Railtie config.app_generators do |g| g.templates.unshift File::expand_path('../../templates', __FILE__) end initializer 'rails_Script.loader_helper' do ActionView::Base.send :include, LoaderHelper end initializer 'rails_script.to_javascript' ...
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/generators/rails_script/class/class_generator.rb
Ruby
mit
215
master
349
module RailsScript module Generators class ClassGenerator < ::Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) argument :class_name, type: :string def generate_file template 'javascript.js.coffee', "app/assets/javascripts/#{class_name.underscore}.js.coffee"...
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/generators/rails_script/controller/controller_generator.rb
Ruby
mit
215
master
354
module RailsScript module Generators class ControllerGenerator < ::Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) argument :controller, type: :string def generate_file template 'javascript.js.coffee', "app/assets/javascripts/#{controller.underscore}.js.co...
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/generators/rails_script/install/install_generator.rb
Ruby
mit
215
master
610
module RailsScript module Generators class InstallGenerator < ::Rails::Generators::Base source_root File.expand_path("../../../../../app/assets/javascripts", __FILE__) def copy_files template 'base.coffee', 'app/assets/javascripts/base.coffee' template 'global.coffee', 'app/assets/jav...
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/generators/rails_script/utility/utility_generator.rb
Ruby
mit
215
master
365
module RailsScript module Generators class UtilityGenerator < ::Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) argument :utility_name, type: :string def generate_file template 'javascript.js.coffee', "app/assets/javascripts/utilities/#{utility_name.unders...
github
gemgento/rails_script
https://github.com/gemgento/rails_script
lib/generators/rails_script/element/element_generator.rb
Ruby
mit
215
master
416
module RailsScript module Generators class ElementGenerator < ::Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) argument :element_name, type: :string argument :utility, type: :string, default: '' def generate_file template 'javascript.js.coffee', "ap...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
Rakefile
Ruby
mit
215
main
293
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' RuboCop::RakeTask.new task :version do puts Gem::Specification.load('openapi_first.gemspec').version end RSpec::Core::RakeTask.new(:spec) task default: %i[spec rubocop]
github
ahx/openapi_first
https://github.com/ahx/openapi_first
Gemfile
Ruby
mit
215
main
348
# frozen_string_literal: true source 'https://rubygems.org' gemspec gem 'rack', '>= 3.0.0' gem 'rackup' group :test, :development do gem 'actionpack' gem 'benchmark' gem 'bundler' gem 'minitest' gem 'rack-test' gem 'rails' gem 'rake' gem 'rspec' gem 'rubocop' gem 'rubocop-performance' gem 'sim...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
openapi_first.gemspec
Ruby
mit
215
main
1,264
# frozen_string_literal: true require_relative 'lib/openapi_first/version' Gem::Specification.new do |spec| spec.name = 'openapi_first' spec.version = OpenapiFirst::VERSION spec.authors = ['Andreas Haller'] spec.email = ['andreas.haller@posteo.de'] spec.licenses = ['MIT'] ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first.rb
Ruby
mit
215
main
3,326
# frozen_string_literal: true require_relative 'openapi_first/json' require_relative 'openapi_first/file_loader' require_relative 'openapi_first/errors' require_relative 'openapi_first/registry' require_relative 'openapi_first/configuration' require_relative 'openapi_first/child_configuration' require_relative 'openap...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/json.rb
Ruby
mit
215
main
507
# frozen_string_literal: true # This tries to load MultiJson if available to keep compatibility # with MultiJson until next major version begin require 'multi_json' module OpenapiFirst # Compatibility with MultiJson # @visibility private module JSON ParserError = MultiJson::ParseError def...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/file_loader.rb
Ruby
mit
215
main
793
# frozen_string_literal: true require 'json' require 'yaml' module OpenapiFirst # @!visibility private class FileLoader def self.load(file_path) new.load(file_path) end def initialize @cache = {} @mutex = Mutex.new end def load(file_path) @cache[file_path] || @mutex.s...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/builder.rb
Ruby
mit
215
main
8,415
# frozen_string_literal: true require 'json_schemer' require_relative 'failure' require_relative 'router' require_relative 'header' require_relative 'request' require_relative 'response' require_relative 'schema/hash' require_relative 'ref_resolver' module OpenapiFirst # Builds parts of a Definition # This knows...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/response_body_parsers.rb
Ruby
mit
215
main
749
# frozen_string_literal: true module OpenapiFirst # @visibility private module ResponseBodyParsers DEFAULT = ->(body) { body } @parsers = {} class << self attr_reader :parsers def register(pattern, parser) parsers[pattern] = parser end def [](content_type) ke...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/request_validator.rb
Ruby
mit
215
main
814
# frozen_string_literal: true require_relative 'failure' require_relative 'validators/request_parameters' require_relative 'validators/request_body' module OpenapiFirst # Validates a Request against a request definition. class RequestValidator def initialize( content_schema:, required_request_body...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/router.rb
Ruby
mit
215
main
4,004
# frozen_string_literal: true require_relative 'router/path_template' require_relative 'router/find_content' require_relative 'router/find_response' module OpenapiFirst # Router can map requests / responses to their API definition class Router # Returned by {#match} RequestMatch = Data.define(:request_def...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/response.rb
Ruby
mit
215
main
1,433
# frozen_string_literal: true require_relative 'response_parser' require_relative 'response_validator' require_relative 'validated_response' module OpenapiFirst # Represents a response definition in the OpenAPI document. # This is not a direct reflecton of the OpenAPI 3.X response definition, but a combination of...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/response_validator.rb
Ruby
mit
215
main
699
# frozen_string_literal: true require_relative 'validators/response_headers' require_relative 'validators/response_body' module OpenapiFirst # Entry point for response validators class ResponseValidator VALIDATORS = [ Validators::ResponseHeaders, Validators::ResponseBody ].freeze def init...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/configuration.rb
Ruby
mit
215
main
2,695
# frozen_string_literal: true module OpenapiFirst # Global configuration. Currently only used for the request validation middleware. class Configuration HOOKS = %i[ after_request_validation after_response_validation after_request_parameter_property_validation after_request_body_property...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/ref_resolver.rb
Ruby
mit
215
main
5,448
# frozen_string_literal: true require 'json_schemer' module OpenapiFirst # This is here to give traverse an OAD while keeping $refs intact # @visibility private class RefResolver def initialize(file_loader:) @file_loader = file_loader end private attr_reader :file_loader def load(filepat...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/failure.rb
Ruby
mit
215
main
2,762
# frozen_string_literal: true module OpenapiFirst # A failure object returned when validation or parsing of a request or response has failed. # This returned in ValidatedRequest#error and ValidatedResponse#error. class Failure < Data.define(:type, :message, :errors) # rubocop:disable Style/DataInheritance TY...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/request_body_parsers.rb
Ruby
mit
215
main
1,796
# frozen_string_literal: true module OpenapiFirst # @!visibility private module RequestBodyParsers DEFAULT = ->(request) { Utils.read_body(request) } @parsers = {} class << self attr_reader :parsers def register(pattern, parser) parsers[pattern] = parser end def [](c...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/registry.rb
Ruby
mit
215
main
1,452
# frozen_string_literal: true module OpenapiFirst class NotRegisteredError < Error; end class AlreadyRegisteredError < Error; end # @visibility private module Registry def definitions @definitions ||= {} end # Register an OpenAPI definition for testing # @param path_or_definition [Strin...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/error_response.rb
Ruby
mit
215
main
882
# frozen_string_literal: true module OpenapiFirst # This is the base module for error responses module ErrorResponse ## @param failure [OpenapiFirst::Failure] def initialize(failure: nil) @failure = failure end attr_reader :failure # The response body def body raise "#{self.cl...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/request.rb
Ruby
mit
215
main
3,010
# frozen_string_literal: true require 'openapi_parameters' require_relative 'parsed_request' require_relative 'request_validator' require_relative 'validated_request' require_relative 'request_body_parsers' module OpenapiFirst # Represents one request definition of an OpenAPI description. # Note that this is not ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/child_configuration.rb
Ruby
mit
215
main
729
# frozen_string_literal: true module OpenapiFirst # A subclass to configuration that points to its parent class ChildConfiguration < Configuration def initialize(parent:) super() @parent = parent @request_validation_error_response = parent.request_validation_error_response @request_vali...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/definition.rb
Ruby
mit
215
main
4,348
# frozen_string_literal: true require_relative 'builder' require 'forwardable' module OpenapiFirst # Represents an OpenAPI API Description document # This is returned by OpenapiFirst.load. class Definition extend Forwardable # @return [String,nil] attr_reader :filepath # @return [String,nil] ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/errors.rb
Ruby
mit
215
main
1,166
# frozen_string_literal: true module OpenapiFirst # Base class for all errors class Error < StandardError; end # Raised if YAML/JSON file was not found class FileNotFoundError < Error; end # Raised if response body could not be parsed class ParseError < Error; end # Raised during request validation if...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/validated_request.rb
Ruby
mit
215
main
3,036
# frozen_string_literal: true require 'forwardable' require 'delegate' module OpenapiFirst # A validated request. It can be valid or not. class ValidatedRequest < SimpleDelegator extend Forwardable def initialize(original_request, error:, parsed_request: nil, request_definition: nil, query_parser: nil) ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/validated_response.rb
Ruby
mit
215
main
1,390
# frozen_string_literal: true require 'forwardable' require 'delegate' module OpenapiFirst # A validated response. It can be valid or not. class ValidatedResponse < SimpleDelegator extend Forwardable def initialize(original_response, error:, parsed_values: nil, response_definition: nil) super(origi...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test.rb
Ruby
mit
215
main
5,651
# frozen_string_literal: true require 'logger' require_relative 'test/configuration' require_relative 'registry' module OpenapiFirst # Test integration module Test # rubocop:disable Metrics/ModuleLength autoload :Coverage, 'openapi_first/test/coverage' autoload :Methods, 'openapi_first/test/methods' a...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/response_parser.rb
Ruby
mit
215
main
1,333
# frozen_string_literal: true require_relative 'response_body_parsers' module OpenapiFirst ParsedResponse = Data.define(:body, :headers) # Parse a response class ResponseParser def initialize(headers:, content_type:) @headers_parser = build_headers_parser(headers) @body_parser = ResponseBodyPar...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/error_responses/default.rb
Ruby
mit
215
main
1,766
# frozen_string_literal: true module OpenapiFirst module ErrorResponses # An error reponse that returns application/problem+json with a list of "errors" # See also https://www.rfc-editor.org/rfc/rfc9457.html class Default include OpenapiFirst::ErrorResponse OpenapiFirst.register_error_respon...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/error_responses/jsonapi.rb
Ruby
mit
215
main
1,346
# frozen_string_literal: true module OpenapiFirst module ErrorResponses # A JSON:API conform error response. See https://jsonapi.org/. class Jsonapi include OpenapiFirst::ErrorResponse OpenapiFirst.register_error_response(:jsonapi, self) def body JSON.generate({ errors: serialized...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/schema/hash.rb
Ruby
mit
215
main
1,306
# frozen_string_literal: true require_relative 'validation_error' module OpenapiFirst module Schema # A hash of Schemas class Hash # @param schemas Hash of schemas # @param required Array of required keys def initialize(schemas, required: nil, **options) @schemas = schemas ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/schema/validation_result.rb
Ruby
mit
215
main
758
# frozen_string_literal: true require_relative 'validation_error' module OpenapiFirst module Schema # Result of validating data against a schema. Return value of Schema#validate. class ValidationResult def initialize(validation) @validation = validation end def error? = @validatio...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/schema/validation_error.rb
Ruby
mit
215
main
1,884
# frozen_string_literal: true module OpenapiFirst module Schema # One of multiple validation errors. Returned by Schema::ValidationResult#errors. ValidationError = Data.define(:value, :data_pointer, :schema_pointer, :type, :details, :schema) do # This returns an error message for this specific error. ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/router/find_response.rb
Ruby
mit
215
main
2,016
# frozen_string_literal: true require_relative 'find_content' module OpenapiFirst class Router # @visibility private module FindResponse Match = Data.define(:response, :error) def self.call(responses, status, content_type, request_method:, path:) contents = find_status(responses, status...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/router/find_content.rb
Ruby
mit
215
main
560
# frozen_string_literal: true module OpenapiFirst class Router # @visibility private module FindContent def self.call(contents, content_type) return contents[nil] if content_type.nil? || content_type.empty? contents.fetch(content_type) do semi = content_type.index(';') ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/router/path_template.rb
Ruby
mit
215
main
954
# frozen_string_literal: true module OpenapiFirst class Router # @visibility private class PathTemplate # See also https://spec.openapis.org/oas/v3.1.0#path-templating TEMPLATE_EXPRESSION = /(\{[^{}]+\})/ def self.template?(string) string.include?('{') end def initiali...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/validators/response_body.rb
Ruby
mit
215
main
665
# frozen_string_literal: true require_relative '../schema/validation_result' module OpenapiFirst module Validators class ResponseBody def initialize(schema) @schema = schema end attr_reader :schema def call(response) begin parsed_body = response.body r...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/validators/request_parameters.rb
Ruby
mit
215
main
1,441
# frozen_string_literal: true module OpenapiFirst module Validators module RequestParameters RequestHeaders = Data.define(:schema) do def call(parsed_request) validation = schema.validate(parsed_request.headers) Failure.fail!(:invalid_header, errors: validation.errors) if valida...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/validators/request_body.rb
Ruby
mit
215
main
682
# frozen_string_literal: true module OpenapiFirst module Validators class RequestBody def initialize(content_schema:, required_request_body:) @schema = content_schema @required = required_request_body end def call(parsed_request) body = parsed_request.body if bo...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/validators/response_headers.rb
Ruby
mit
215
main
1,081
# frozen_string_literal: true module OpenapiFirst module Validators class ResponseHeaders def initialize(headers) @headers = headers end attr_reader :headers def call(parsed_response) headers.each do |header| header_value = parsed_response.headers[header.name] ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/app.rb
Ruby
mit
215
main
1,155
# frozen_string_literal: true require_relative 'observe' module OpenapiFirst module Test REQUEST = 'openapi.test.request' RESPONSE = 'openapi.test.response' # A wrapper of the original app # with silent request/response validation to track requests/responses. class App < SimpleDelegator d...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/coverage.rb
Ruby
mit
215
main
3,061
# frozen_string_literal: true require_relative 'coverage/plan' require_relative 'coverage/tracker' require_relative 'coverage/covered_request' require_relative 'coverage/covered_response' require 'drb' module OpenapiFirst module Test # The Coverage module is about tracking request and response validation # ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/logger.rb
Ruby
mit
215
main
324
# frozen_string_literal: true require 'logger' module OpenapiFirst module Test # Logger to output coverage reports and such class Logger < ::Logger def initialize(*) super self.formatter = proc { |_severity, _time, _progname, msg| "#{msg}\n" } end end end ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/observer_middleware.rb
Ruby
mit
215
main
705
# frozen_string_literal: true module OpenapiFirst module Test # Middleware that observes requests and responses. This is used to trigger hooks added by OpenapiFirst::Tests. class ObserverMiddleware def initialize(app, options = {}) @app = app @definition = OpenapiFirst::Test[options.fet...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/methods.rb
Ruby
mit
215
main
2,091
# frozen_string_literal: true require_relative 'minitest_helpers' require_relative 'plain_helpers' module OpenapiFirst module Test # Methods to use in integration tests module Methods def self.included(base) base.include(DefaultApiMethod) base.include(AssertionMethod) end ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/callable.rb
Ruby
mit
215
main
946
# frozen_string_literal: true module OpenapiFirst module Test # Return a Module with a call method that wrapps silent request/response validation to monitor a Rack app # This is used by Openapi::Test.observe module Callable # Returns a Module with a `call(env)` method that wraps super inside silent...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/configuration.rb
Ruby
mit
215
main
3,858
# frozen_string_literal: true require_relative 'logger' module OpenapiFirst module Test # Helper class to setup tests class Configuration def initialize @minimum_coverage = 100 @coverage_formatter = Coverage::TerminalFormatter @coverage_formatter_options = {} @skip_resp...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/minitest_helpers.rb
Ruby
mit
215
main
1,028
# frozen_string_literal: true module OpenapiFirst module Test # Assertion methods for Minitest module MinitestHelpers # :nocov: def assert_api_conform(status: nil, api: openapi_first_default_api) api = OpenapiFirst::Test[api] request = respond_to?(:last_request) ? last_request : @...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/plain_helpers.rb
Ruby
mit
215
main
1,105
# frozen_string_literal: true module OpenapiFirst module Test # Assertion methods to use when no known test framework was found # These methods just raise an exception if an error was found module PlainHelpers def assert_api_conform(status: nil, api: openapi_first_default_api) api = Openapi...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/test/observe.rb
Ruby
mit
215
main
931
# frozen_string_literal: true require_relative 'callable' module OpenapiFirst module Test class ObserveError < Error; end # @visibility private module Observed; end # Inject silent request/response validation to observe rack apps during testing module Observe def self.observe(app, api: :...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/middlewares/response_validation.rb
Ruby
mit
215
main
1,691
# frozen_string_literal: true require 'rack' module OpenapiFirst module Middlewares # A Rack middleware to validate requests against an OpenAPI API description. # You probably want to use +OpenapiFirst::Test+ instead of this middleware. class ResponseValidation # @param spec [String, Symbol, Opena...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
lib/openapi_first/middlewares/request_validation.rb
Ruby
mit
215
main
3,074
# frozen_string_literal: true require 'rack' module OpenapiFirst module Middlewares # A Rack middleware to validate requests against an OpenAPI API description. # All error responses can be customized via the +error_response:+ option. # === Request body validation # # * Returns +415+ if the reque...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/validated_response_spec.rb
Ruby
mit
215
main
1,412
# frozen_string_literal: true RSpec.describe OpenapiFirst::ValidatedResponse do describe '#parsed_body' do it 'returns nil without parsed values' do validated = described_class.new(double(:request), error: double(:error)) expect(validated.parsed_body).to be_nil end end describe '#parsed_head...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/hooks_spec.rb
Ruby
mit
215
main
9,144
# frozen_string_literal: true RSpec.describe 'Hooks' do def build_request(path, method: 'GET', body: nil) Rack::Request.new(Rack::MockRequest.env_for(path, method:, input: body, 'CONTENT_TYPE' => 'application/json')) end describe 'adding a hook' do specify do called = [] myproc = proc do |re...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/validated_request_spec.rb
Ruby
mit
215
main
6,776
# frozen_string_literal: true RSpec.describe OpenapiFirst::ValidatedRequest do let(:path) { nil } let(:query) { nil } let(:headers) { nil } let(:cookies) { nil } let(:body) { nil } let(:parsed_request) { OpenapiFirst::ParsedRequest.new(path:, query:, headers:, cookies:, body:) } let(:valid_request) do ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/request_body_parsers_spec.rb
Ruby
mit
215
main
1,430
# frozen_string_literal: true RSpec.describe OpenapiFirst::RequestBodyParsers do include Rack::Test::Methods def app = ->(_env) { Rack::Response.new.finish } context 'with application/json' do subject(:parser) { described_class['application/json'] } it 'parses JSON' do post '/', JSON.generate({ ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/test_cases_spec.rb
Ruby
mit
215
main
2,234
# frozen_string_literal: true require 'rack/test' require_relative 'spec_helper' RSpec.describe 'request/response validation examples' do include Rack::Test::Methods Dir.glob(File.join(__dir__, '/test_cases/*.yaml')).each do |filepath| describe filepath do YAML.load_file(filepath).each do |example| ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/openapi_first_spec.rb
Ruby
mit
215
main
4,410
# frozen_string_literal: true require_relative 'spec_helper' require 'rack' require 'rack/test' require 'openapi_first' RSpec.describe OpenapiFirst do it 'has a version number' do expect(OpenapiFirst::VERSION).not_to be nil end include Rack::Test::Methods let(:spec_path) { './spec/data/petstore-expanded...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/failure_spec.rb
Ruby
mit
215
main
2,587
# frozen_string_literal: true RSpec.describe OpenapiFirst::Failure do describe '.fail!' do it 'throws a failure' do expect do described_class.fail!(:invalid_body) end.to throw_symbol(OpenapiFirst::FAILURE, instance_of(described_class)) end context 'with an unknown argument' do ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/response_validator_spec.rb
Ruby
mit
215
main
2,654
# frozen_string_literal: true RSpec.describe OpenapiFirst::ResponseValidator do let(:content_schema) do JSONSchemer.schema({ 'type' => 'array', 'items' => { 'type' => 'object', 'required' => %w[id name], ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/ref_resolver_spec.rb
Ruby
mit
215
main
11,151
# frozen_string_literal: true require_relative '../lib/openapi_first/ref_resolver' RSpec.describe OpenapiFirst::RefResolver do let(:contents) do { 'definitions' => { 'Thing' => { 'type' => 'object' }, 'A' => { 'name' => 'A' } }, 'hash' => { '$ref' => '#/definitions/Thin...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/file_loader_spec.rb
Ruby
mit
215
main
1,088
# frozen_string_literal: true RSpec.describe OpenapiFirst::FileLoader do describe '.load' do begin require 'multi_json' # :nocov: before do MultiJson.load_options = { symbolize_keys: true } end after do MultiJson.load_options = { symbolize_keys: false } end ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/configuration_spec.rb
Ruby
mit
215
main
3,244
# frozen_string_literal: true RSpec.describe OpenapiFirst::Configuration do after { Warning[:deprecated] = true } describe '#after_...' do it 'adds a hook' do config = OpenapiFirst::Configuration.new called = [] config.after_request_validation do |request| called << request end...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/example_app_spec.rb
Ruby
mit
215
main
723
# frozen_string_literal: true require 'rack/test' require_relative 'spec_helper' require_relative '../examples/rack_handler' RSpec.describe 'Example App' do include Rack::Test::Methods include OpenapiFirst::Test::Methods before do OpenapiFirst::Test.register(File.join(__dir__, '../examples/openapi.yaml'), ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/spec_helper.rb
Ruby
mit
215
main
856
# frozen_string_literal: true ENV['RACK_ENV'] = 'test' Warning[:deprecated] = true require 'bundler/setup' require 'openapi_first' require 'json' require 'simplecov' require 'rack/test' SimpleCov.start do enable_coverage :branch primary_coverage :branch minimum_coverage line: 100, branch: 100 add_filter 'lib...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/definition_spec.rb
Ruby
mit
215
main
17,446
# frozen_string_literal: true RSpec.describe OpenapiFirst::Definition do def build_request(path, method: 'GET') Rack::Request.new(Rack::MockRequest.env_for(path, method:)) end describe '#config' do it 'returns a frozen configuration' do definition = OpenapiFirst.load('./spec/data/petstore.yaml') ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/response_parser_spec.rb
Ruby
mit
215
main
4,273
# frozen_string_literal: true require 'action_dispatch' RSpec.describe OpenapiFirst::ResponseParser do let(:content_type) { 'application/json' } let(:headers) { nil } subject(:parsed) do described_class.new(content_type:, headers:).parse(rack_response) end describe '#body' do let(:rack_response) d...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/test_spec.rb
Ruby
mit
215
main
27,930
# frozen_string_literal: true require 'minitest' RSpec.describe OpenapiFirst::Test do let(:definition) { OpenapiFirst.load('./examples/openapi.yaml') } let(:app) do Class.new do def call(_env) Rack::Response.new.finish end end end describe '.logger' do after { described_class...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/router_spec.rb
Ruby
mit
215
main
9,225
# frozen_string_literal: true require_relative '../lib/openapi_first/router' RSpec.describe OpenapiFirst::Router do describe '#match' do let(:requests) do [ double(path: '/{id}', request_method: 'get'), double(path: '/{id}', request_method: 'patch'), double(path: '/a', request_meth...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/test/callable_spec.rb
Ruby
mit
215
main
641
# frozen_string_literal: true require 'minitest' RSpec.describe OpenapiFirst::Test do let(:definition) { OpenapiFirst.load('./examples/openapi.yaml') } let(:app) do Class.new do def call(_env) Rack::Response.new.finish end end end describe 'Callable[]' do before do requ...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/test/configuration_spec.rb
Ruby
mit
215
main
2,832
# frozen_string_literal: true RSpec.describe OpenapiFirst::Test::Configuration do subject(:configuration) { described_class.new } it 'raises an error with invalid option value' do expect do configuration.report_coverage = :fatal end.to raise_error(ArgumentError) end describe 'ignored_unknown_st...
github
ahx/openapi_first
https://github.com/ahx/openapi_first
spec/test/observe_spec.rb
Ruby
mit
215
main
2,539
# frozen_string_literal: true RSpec.describe OpenapiFirst::Test::Observe do RSpec.shared_examples 'an observed app' do it 'injects request/response validation' do described_class.observe(app) expect(definition).to receive(:validate_request) expect(definition).to receive(:validate_response) ...