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
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/extensions/pagination/header_generator.rb
Ruby
mit
302
master
2,921
# frozen_string_literal: true module Praxis module Extensions module Pagination class HeaderGenerator def self.build_cursor_headers(paginator:, last_value:, total_count: nil) %i[next prev first last].each_with_object({}) do |rel_name, info| case rel_name when :next...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/extensions/pagination/ordering_params.rb
Ruby
mit
302
master
9,387
# frozen_string_literal: true require 'forwardable' module Praxis module Extensions module Pagination class OrderingParams include Attributor::Type include Attributor::Dumpable extend Forwardable def_delegators :items, :empty? # DSL for restricting how to order. ...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/extensions/pagination/sequel_pagination_handler.rb
Ruby
mit
302
master
1,064
# frozen_string_literal: true require_relative 'pagination_handler' module Praxis module Extensions module Pagination class SequelPaginationHandler < PaginationHandler def self.where_lt(query, attr, value) query.where("#{attr} < ?", value) end def self.where_gt(query, at...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/extensions/pagination/pagination_handler.rb
Ruby
mit
302
master
2,893
# frozen_string_literal: true module Praxis module Extensions module Pagination class PaginationHandler class PaginationException < RuntimeError; end def self.paginate(query, pagination, root_resource:) return query unless pagination.paginator paginator = pagination.pa...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/extensions/pagination/active_record_pagination_handler.rb
Ruby
mit
302
master
4,530
# frozen_string_literal: true require_relative 'pagination_handler' module Praxis module Extensions module Pagination class ActiveRecordPaginationHandler < PaginationHandler def self.where_lt(query, attr, value) # TODO: common for AR/Sequel? Seems we could use Arel and more-specific Sequ...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/extensions/rails_compat/request_methods.rb
Ruby
mit
302
master
516
# frozen_string_literal: true # Make Praxis' request derive from ActionDispatch if defined? Praxis::Request puts "IT seems that we're trying to redefine Praxis' request parent too late." puts '-> try to include the Rails compat pieces earlier in the bootstrap process (before Praxis::Request is requried)' exit(-1...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/multipart/part.rb
Ruby
mit
302
master
8,449
# frozen_string_literal: true module Praxis class MultipartPart include Attributor::Type attr_reader :name, :filename attr_accessor :body, :headers, :payload_attribute, :headers_attribute, :filename_attribute, :default_handler def self.check_option!(name, definition) case name when :pay...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/multipart/parser.rb
Ruby
mit
302
master
6,220
# frozen_string_literal: true require 'rack/utils' # stolen from Rack::Multipart::Parser module Praxis class MultipartParser EOL = "\r\n" MULTIPART_BOUNDARY = 'AaB03x' MULTIPART = %r{\Amultipart/.*boundary="?([^";,]+)"?}n.freeze TOKEN = %r{[^\s()<>,;:\\"/\[\]?=]+}.freeze CONDISP = /Content-Disp...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/scaffold.rb
Ruby
mit
302
master
6,279
# frozen_string_literal: true module PraxisGen class Scaffold < Thor require 'active_support/inflector' include Thor::Actions attr_reader :actions_hash def self.source_root "#{File.dirname(__FILE__)}/templates/generator/scaffold" end desc 'g', 'Generates an API design and implementat...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/app.rb
Ruby
mit
302
master
846
# frozen_string_literal: true module PraxisGen class App < Thor include Thor::Actions namespace 'praxis:app' def self.source_root "#{File.dirname(__FILE__)}/templates/generator/empty_app" end argument :app_name, required: true desc 'new', 'Generates a blank new app under <app_name> (w...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/model.rb
Ruby
mit
302
master
1,377
# frozen_string_literal: true module PraxisGen class Model < Thor require 'active_support/inflector' include Thor::Actions def self.source_root "#{File.dirname(__FILE__)}/templates/generator/scaffold" end desc 'gmodel', 'Generates a skeleton model file under app/models for ActiveRecord or...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/example.rb
Ruby
mit
302
master
2,249
# frozen_string_literal: true module PraxisGen class Example < Thor include Thor::Actions namespace 'praxis:example' def self.source_root "#{File.dirname(__FILE__)}/templates/generator/example_app" end argument :app_name, required: true desc 'example', 'Generates a new example applic...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/empty_app/Rakefile
Ruby
mit
302
master
359
require 'bundler/setup' ENV['RACK_ENV'] ||= 'development' Bundler.require(:default, ENV['RACK_ENV']) require 'praxis/tasks' desc "Drop into a console with the full application loaded" task console: 'praxis:console' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) Dir["lib/tasks/**/*.rake"].each { |e...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/empty_app/spec/spec_helper.rb
Ruby
mit
302
master
506
Bundler.setup :default, :test Bundler.require :default, :test RSpec.configure do |config| config.include Rack::Test::Methods # config.before(:suite) do # Praxis::Blueprint.caching_enabled = true # end # config.before(:each) do # Praxis::Blueprint.cache = Hash.new do |hash, key| # hash[key] = Ha...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/empty_app/config/environment.rb
Ruby
mit
302
master
979
Praxis::Application.configure do |application| # This is a commented out copy of the default Praxis layout # This example app follows the standard practices, so there is no reason to override it # If we wanted to organize the structure and ordering of files, we can uncomment the layout # and define it at our ow...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/scaffold/implementation/controllers/collection.rb
Ruby
mit
302
master
2,621
# frozen_string_literal: true module <%= version_module %> module Controllers class <%= plural_class %> include Praxis::Controller implements Endpoints::<%= plural_class %> <%- if action_enabled?(:index) -%> # Retrieve all <%= plural_class %> with the right necessary associations ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/scaffold/implementation/resources/item.rb
Ruby
mit
302
master
1,199
# frozen_string_literal: true module <%= version_module %> module Resources class <%= singular_class %> < Base model ::<%= singular_class %> # Change it if it maps to a different DB model class # Define the name mapping from API filter params, to model attribute/associations # when they aren't...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/scaffold/implementation/resources/base.rb
Ruby
mit
302
master
399
# frozen_string_literal: true module <%= version_module %> module Resources class Base < Praxis::Mapper::Resource # Base for all <%= version_module %> resources. # Resources withing a single version should have resource mappings separate from other versions # and the Mapper::Resource will appro...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/scaffold/design/media_types/item.rb
Ruby
mit
302
master
485
# frozen_string_literal: true module <%= version_module %> module MediaTypes class <%= singular_class %> < Praxis::MediaType identifier 'application/json' domain_model '<%= version_module %>::Resources::<%= singular_class %>' description 'Structural definition of a <%= singular_class %>' ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/scaffold/design/endpoints/collection.rb
Ruby
mit
302
master
3,602
# frozen_string_literal: true module <%= version_module %> module Endpoints class <%= plural_class %> include Praxis::EndpointDefinition media_type MediaTypes::<%= singular_class %> version '<%= version %>' description 'Praxis-generated endpoint for managing <%= plural_class %>' ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/config.ru
Ruby
mit
302
master
890
# -p 8888 ENV['RACK_ENV'] ||= 'development' Bundler.setup(:default, ENV['RACK_ENV']) Bundler.require(:default, ENV['RACK_ENV']) # Want to take advantage of some of the Praxis' extensions for: # API field selection (a la GraphQL) - for querying and rendering # API filtering extensions (to add "where clauses") in listi...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/Gemfile
Ruby
mit
302
master
530
# frozen_string_literal: true source 'https://rubygems.org' gem 'activerecord' gem 'link_header' # For pagination extensions gem 'parslet' # For field selection extension gem 'praxis' gem 'puma' # A much better web server than the default webrick gem 'rack' gem 'sqlite3' group :development, :test do gem 'database_...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/Rakefile
Ruby
mit
302
master
1,680
ENV['RACK_ENV'] = 'development' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) require 'praxis' require 'praxis/tasks' # Setup Activerecord migrations require 'active_record' db_dir = File.expand_path('../db', __dir__) ActiveRecord::Tasks::DatabaseTasks.env = ENV['RACK_ENV'] ActiveRecord::Tasks::Data...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/spec/spec_helper.rb
Ruby
mit
302
master
918
Bundler.setup :default, :test Bundler.require :default, :test ENV['RACK_ENV'] = 'test' begin APP=Rack::Builder.parse_file(File.expand_path('../config.ru', __dir__)).first rescue => e puts "Application failed to initialize:" raise e exit 1 end # Migrate and seed the DB (only an empty in-memory DB) ActiveRecor...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
Ruby
mit
302
master
981
# frozen_string_literal: true require 'spec_helper' describe V1::Controllers::Users do before do header 'X-API-Version', '1' end let(:response) { subject; last_response } let(:json_payload) { JSON.dump(payload) } let(:parsed_body) { JSON.parse(response.body, symbolize_names: true) } context 'index' ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/spec/helpers/database_helper.rb
Ruby
mit
302
master
780
require 'active_record' class DatabaseHelper # Simple DB seeding to avoid bringing in other gems like FactoryGirl etc. # This does the job for an example seeder def self.seed! user_data = [ {id: 11, first_name: 'Peter', last_name: 'Praxis', uuid: 'deadbeef', email: 'peter@pan.com'}, {id: 12, firs...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/app/v1/resources/base.rb
Ruby
mit
302
master
439
# frozen_string_literal: true require_relative '../concerns/href' module V1 module Resources class Base < Praxis::Mapper::Resource include Resources::Concerns::Href # Base for all V1 resources. # Resources withing a single version should have resource mappings separate from other versions ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/app/v1/resources/user.rb
Ruby
mit
302
master
1,166
# frozen_string_literal: true module V1 module Resources class User < Base model ::User # Define the name mapping from API filter params, to model attribute/associations # when they aren't 1:1 the same # filters_mapping( # 'label': 'association.label_name' # ) # Add ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/app/v1/concerns/href.rb
Ruby
mit
302
master
1,204
# frozen_string_literal: true module V1 module Resources module Concerns module Href extend ActiveSupport::Concern # Base module where the href concern will grab constants from included do def self.base_module ::V1 end end module Cla...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/app/v1/concerns/controller_base.rb
Ruby
mit
302
master
747
module V1 module Concerns module ControllerBase extend ActiveSupport::Concern # Controller concen that wraps an API with a transaction, and automatically rolls it back # for non-2xx (or 3xx) responses included do around :action do |controller, callee| begin Ac...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/app/v1/controllers/users.rb
Ruby
mit
302
master
297
# frozen_string_literal: true module V1 module Controllers class Users include Praxis::Controller include Concerns::ControllerBase implements V1::Endpoints::Users def index objects = build_query(::User) display(objects) end end end end
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/design/api.rb
Ruby
mit
302
master
817
# Use this file to define your overall api behavior, response templates and traits. Praxis::ApiDefinition.define do info do name 'example' title 'Example API' # Attributes for OpenAPI docs termsOfService 'https://mysitehere.com' contact name: 'API Info', email: 'info@mysitehere.com' server( ...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/design/v1/media_types/user.rb
Ruby
mit
302
master
436
# frozen_string_literal: true module V1 module MediaTypes class User < Praxis::MediaType identifier 'application/json' domain_model 'V1::Resources::User' description 'A user in the system' attributes do attribute :id, Integer attribute :uuid, String attribute :em...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/design/v1/endpoints/users.rb
Ruby
mit
302
master
1,279
# frozen_string_literal: true module V1 module Endpoints class Users include Praxis::EndpointDefinition media_type MediaTypes::User version '1' description 'Endpoints that allow the listing and manipulation of users' action :index do description 'List users' routi...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/config/environment.rb
Ruby
mit
302
master
1,561
Praxis::Application.configure do |application| # Configure the Mapper plugin (if we want to use all the filtering/field_selection extensions) application.bootloader.use Praxis::Plugins::MapperPlugin # Configure the Pagination plugin (if we want to use all the pagination/ordering extensions) application.bootloa...
github
praxis/praxis
https://github.com/praxis/praxis
tasks/thor/templates/generator/example_app/db/migrate/20201010101010_create_users_table.rb
Ruby
mit
302
master
325
# frozen_string_literal: true class CreateUsersTable < ActiveRecord::Migration[5.2] def change create_table :users do |table| table.column :uuid, :string, null: false table.column :first_name, :string, null: false table.column :last_name, :string table.column :email, :string end end...
github
praxis/praxis
https://github.com/praxis/praxis
spec/functional_library_spec.rb
Ruby
mit
302
master
10,295
# frozen_string_literal: true require 'spec_helper' describe 'Functional specs for books with connected DB' do def app Praxis::Application.instance end let(:parsed_response) { JSON.parse(subject.body, symbolize_names: true) } context 'books' do context 'index' do let(:filters_q) { '' } let...
github
praxis/praxis
https://github.com/praxis/praxis
spec/functional_cloud_spec.rb
Ruby
mit
302
master
17,817
# frozen_string_literal: true require 'spec_helper' describe 'Functional specs' do def app Praxis::Application.instance end let(:session) { double('session', valid?: true) } context 'index' do context 'with a valid request' do it 'is successful' do get '/api/clouds/1/instances?api_vers...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_helper.rb
Ruby
mit
302
master
1,420
# frozen_string_literal: true require 'coveralls' Coveralls.wear! $LOAD_PATH.unshift File.expand_path(__dir__) $LOAD_PATH.unshift File.expand_path('../lib', __dir__) $LOAD_PATH.unshift File.expand_path('support', __dir__) require 'bundler' Bundler.setup :default, :test RSpec.configure do |config| config.filter_ru...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_blueprints.rb
Ruby
mit
302
master
2,579
# frozen_string_literal: true class PersonBlueprint < Praxis::Blueprint attributes do attribute :name, String, example: proc { Faker::Name.first_name } attribute :email, String, example: proc { |person| "#{person.name}@example.com" } attribute :age, Integer, min: 0 # Weird, anonymous attribute built...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_simple_authentication_plugin.rb
Ruby
mit
302
master
1,276
# frozen_string_literal: true require 'singleton' module SimpleAuthenticationPlugin include Praxis::PluginConcern class Plugin < Praxis::Plugin include Singleton def initialize @options = { config_file: 'config/authentication.yml' } super end def config_key :authentication ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_authorization_plugin.rb
Ruby
mit
302
master
1,745
# frozen_string_literal: true require 'singleton' module AuthorizationPlugin include Praxis::PluginConcern class Plugin < Praxis::Plugin include Singleton def config_key :authorization end def initialize super @options = { config_file: 'config/authorization.yml' } end ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_complex_authentication_plugin.rb
Ruby
mit
302
master
2,244
# frozen_string_literal: true require 'singleton' class Authenticator include Attributor::Type def self.native_type Class end def self.load(value, _context = Attributor::DEFAULT_ROOT_CONTEXT, **_options) case value when Hash type = value.delete(:type) || value.delete('type') Object.c...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_resources_active_model.rb
Ruby
mit
302
master
5,324
# frozen_string_literal: true require 'active_record' require 'praxis/mapper/active_model_compat' # Creates a new in-memory DB, and the necessary tables (and mini-seeds) for the models in this file def create_tables ActiveRecord::Base.establish_connection( adapter: 'sqlite3', dbfile: ':memory:', datab...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_media_types.rb
Ruby
mit
302
master
5,238
# frozen_string_literal: true require 'praxis/extensions/field_selection' class Person < Praxis::MediaType identifier 'application/vnd.acme.person' attributes do attribute :id, Integer attribute :name, String, example: proc { Faker::Name.full_name } attribute :href, String, example: proc { |person| "/...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_resources.rb
Ruby
mit
302
master
7,590
# frozen_string_literal: true require 'ostruct' require 'praxis/mapper/active_model_compat' class SimpleModel < OpenStruct include Praxis::Mapper::ActiveModelCompat def self._praxis_associations { parent: { model: ParentModel, primary_key: :id, type: :many_to_one, local_k...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_resources_sequel.rb
Ruby
mit
302
master
3,451
# frozen_string_literal: true require 'sequel' require 'praxis/mapper/sequel_compat' # Creates a new in-memory DB, and the necessary tables (and mini-seeds) for the sequel models in this file def create_and_seed_tables sequeldb = Sequel.sqlite # sequeldb.loggers = [Logger.new($stdout)] # Uncomment to see sequel ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/be_deep_equal_matcher.rb
Ruby
mit
302
master
1,168
# frozen_string_literal: true # Copied verbatim from: https://github.com/amogil/rspec-deep-ignore-order-matcher RSpec::Matchers.define :be_deep_equal do |expected| match { |actual| match? actual, expected } failure_message do |actual| "expected that #{actual} would be deep equal with #{expected}" end fa...
github
praxis/praxis
https://github.com/praxis/praxis
spec/support/spec_endpoint_definitions.rb
Ruby
mit
302
master
1,312
# frozen_string_literal: true require_relative 'spec_media_types' Praxis::ApiDefinition.define do trait :test do description 'testing trait' end end class PeopleResource include Praxis::EndpointDefinition description 'People resource' media_type Person version '1.0' canonical_path :show trai...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/config.ru
Ruby
mit
302
master
237
# frozen_string_literal: true require 'json' require 'bundler/setup' require 'pry' $LOAD_PATH.unshift File.expand_path('lib', __dir__) require 'praxis' application = Praxis::Application.instance application.setup run application
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/config/environment.rb
Ruby
mit
302
master
2,654
# frozen_string_literal: true class SetHeader def initialize(app, header, value) @app = app @header = header @value = value end def call(env) status, headers, body = @app.call(env) headers[@header] = @value [status, headers, body] end end class LowBudgetMutex include Singleton at...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/resources/book.rb
Ruby
mit
302
master
1,072
# frozen_string_literal: true require_relative 'base' module Resources class Book < Resources::Base model ::ActiveBook filters_mapping( name: :simple_name ) order_mapping( name: 'simple_name', writer: 'author' ) # Make name go through another nested property, before gett...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/resources/base.rb
Ruby
mit
302
master
576
# frozen_string_literal: true module Resources class Base < Praxis::Mapper::Resource include Praxis::Mapper::Resources::QueryMethods # So we can directly get wrapped models with get, all, first, last... def self.inherited(klass) klass.include Praxis::Mapper::Resources::Callbacks # So we can use callba...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/resources/author.rb
Ruby
mit
302
master
354
# frozen_string_literal: true require_relative 'base' module Resources class Author < Resources::Base model ::ActiveAuthor filters_mapping( 'books.name': 'books.name' ) order_mapping( 'display_name': 'name' ) property :display_name, dependencies: [:name] def display_name ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/concerns/basic_api.rb
Ruby
mit
302
master
324
# frozen_string_literal: true require_relative 'authenticated' require_relative 'log_wrapper' module Concerns module BasicApi extend ActiveSupport::Concern # Basic Api controllers will need the Authenticated and LogWrapper concerns include Concerns::Authenticated include Concerns::LogWrapper end ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/concerns/authenticated.rb
Ruby
mit
302
master
402
# frozen_string_literal: true module Concerns module Authenticated extend ActiveSupport::Concern include Praxis::Callbacks included do before :action do |controller| auth_data = controller.request.headers['Authorization'] Praxis::Responses::Unauthorized.new(body: 'Authentication in...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/concerns/log_wrapper.rb
Ruby
mit
302
master
318
# frozen_string_literal: true module Concerns module LogWrapper extend ActiveSupport::Concern include Praxis::Callbacks included do before :around do |_controller, callee| # Log something at the beginning callee.call # Log something at the end end end end end
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/controllers/base_class.rb
Ruby
mit
302
master
1,089
# frozen_string_literal: true class BaseClass # Do NOT use a controller inherited base class to add concerns! # If you do that, you'd be sharing state (i.e. overriding/adding) from concerns across controllers # which will probably lead to sharing issues you didn't expect. # For example: any controller adding ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/controllers/authors.rb
Ruby
mit
302
master
1,411
# frozen_string_literal: true require_relative 'base_class' class Authors < BaseClass include Praxis::Controller implements ApiResources::Authors include Praxis::Extensions::Rendering def model_class ActiveAuthor end def base_query # Artificially set a base query that has joins, including a joi...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/controllers/books.rb
Ruby
mit
302
master
804
# frozen_string_literal: true class Books < BaseClass include Praxis::Controller implements ApiResources::Books include Praxis::Extensions::Rendering def model_class ActiveBook end def base_query # Make sure we add the distinct clause, that's what we always want for index requests # as we ca...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/controllers/instances.rb
Ruby
mit
302
master
3,695
# frozen_string_literal: true class Instances < BaseClass include Praxis::Controller implements ApiResources::Instances include Concerns::BasicApi before :validate, actions: [:index] do |controller| # p [:before, :validate, :params_and_headers, controller.request.action.name] end before actions: [:s...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/app/controllers/volumes.rb
Ruby
mit
302
master
600
# frozen_string_literal: true class Volumes < BaseClass include Praxis::Controller implements ApiResources::Volumes include Concerns::BasicApi before actions: [:show] do |controller| # puts "before action for volumes" end def index volumes = Volume::Collection.example response.body = volume...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/api.rb
Ruby
mit
302
master
1,090
# frozen_string_literal: true Praxis::ApiDefinition.define do response_template :other_response do |media_type:| status 200 media_type media_type end response_template :multipart do status 200 media_type 'multipart/form-data' end trait :authenticated do headers do key 'Authorizati...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/media_types/book.rb
Ruby
mit
302
master
632
# frozen_string_literal: true class Book < Praxis::MediaType identifier 'application/vnd.acme.book' domain_model 'Resources::Book' attributes do attribute :id, Integer attribute :name, String attribute :simple_name, String attribute :category_uuid, String attribute :author, Author attri...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/media_types/instance.rb
Ruby
mit
302
master
475
# frozen_string_literal: true class Instance < Praxis::MediaType identifier 'application/vnd.acme.instance' attributes do attribute :id, Integer attribute :name, String, example: proc { Faker::Name.first_name }, regexp: /^\w+$/ attribute :href, String attribute :root_...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/media_types/volume.rb
Ruby
mit
302
master
592
# frozen_string_literal: true class Volume < Praxis::MediaType identifier 'application/vnd.acme.volume' attributes do attribute :id, Integer attribute :name, String attribute :source, VolumeSnapshot attribute :snapshots, Praxis::Collection.of(VolumeSnapshot) attribute :snapshots_summary, Vol...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/media_types/author.rb
Ruby
mit
302
master
310
# frozen_string_literal: true class Author < Praxis::MediaType identifier 'application/vnd.acme.author' domain_model 'Resources::Author' attributes do attribute :id, Integer attribute :name, String attribute :display_name, String attribute :books, Praxis::Collection.of(Book) end end
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/media_types/tag.rb
Ruby
mit
302
master
244
# frozen_string_literal: true class Tag < Praxis::MediaType identifier 'application/vnd.acme.tag' domain_model 'Resources::Tag' attributes do attribute :name, String attribute :taggings, Praxis::Collection.of(Tagging) end end
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/media_types/volume_snapshot.rb
Ruby
mit
302
master
742
# frozen_string_literal: true class VolumeSnapshot < Praxis::MediaType identifier 'application/json' attributes do attribute :id, Integer attribute :name, String, regexp: /snapshot-(\w+)/, example: proc { "snapshot-#{Faker::Number.number(digits: 8) }" } end default_fieldset do attribute :id a...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/resources/books.rb
Ruby
mit
302
master
1,208
# frozen_string_literal: true module ApiResources class Books include Praxis::EndpointDefinition media_type Book version '1.0' action :index do routing { get '' } params do attribute :fields, Praxis::Types::FieldSelector.for(Book), description: 'Fields with which to render the r...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/resources/volume_snapshots.rb
Ruby
mit
302
master
607
# frozen_string_literal: true require_relative 'volumes' module ApiResources class VolumeSnapshots include Praxis::EndpointDefinition media_type VolumeSnapshot version '1.0' parent Volumes, id: :volume_id prefix '/snapshots' action :index do routing do get '' end ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/resources/authors.rb
Ruby
mit
302
master
1,051
# frozen_string_literal: true module ApiResources class Authors include Praxis::EndpointDefinition media_type Author version '1.0' action :index do routing { get '' } params do attribute :fields, Praxis::Types::FieldSelector.for(Author), description: 'Fields with which to render...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/resources/volumes.rb
Ruby
mit
302
master
835
# frozen_string_literal: true module ApiResources class Volumes include Praxis::EndpointDefinition media_type Volume version '1.0' prefix '/clouds/:cloud_id/volumes' trait :authenticated action_defaults do params do attribute :cloud_id, Integer, description: 'id of the cloud'...
github
praxis/praxis
https://github.com/praxis/praxis
spec/spec_app/design/resources/instances.rb
Ruby
mit
302
master
6,043
# frozen_string_literal: true module ApiResources class Instances include Praxis::EndpointDefinition media_type Instance version '1.0' # :show action is the canonical path for this resource. # Note that the following is redundant, since :show is the default canonical path if none is defined. ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/file_group_spec.rb
Ruby
mit
302
master
1,133
# frozen_string_literal: true require 'spec_helper' describe Praxis::FileGroup do let(:app) { Praxis::Application.instance } let(:layout) { app.file_layout } context '#initialize' do it 'raises an error if given nil for the base path' do expect { Praxis::FileGroup.new(nil) }.to raise_error(ArgumentEr...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/router_spec.rb
Ruby
mit
302
master
9,399
# frozen_string_literal: true require 'spec_helper' describe Praxis::Router do describe Praxis::Router::VersionMatcher do let(:endpoint_definition) { double('endpoint_definition', version_options: { using: %i[header params] }) } let(:action) { double('action', endpoint_definition: endpoint_definition) } ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/endpoint_definition_spec.rb
Ruby
mit
302
master
9,388
# frozen_string_literal: true require 'spec_helper' describe Praxis::EndpointDefinition do subject(:endpoint_definition) { PeopleResource } its(:description) { should eq('People resource') } its(:media_type) { should eq(Person) } its(:version) { should eq('1.0') } its(:prefix) { should eq('/people') } ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/api_general_info_spec.rb
Ruby
mit
302
master
2,031
# frozen_string_literal: true require 'spec_helper' describe Praxis::ApiGeneralInfo do subject(:info) { Praxis::ApiGeneralInfo.new } before do allow(Praxis::Application.instance).to receive(:versioning_scheme=).with(%i[header params]) end let(:info_block) do proc do name 'Name' title 'Ti...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/collection_spec.rb
Ruby
mit
302
master
3,476
# frozen_string_literal: true require 'spec_helper' describe Praxis::Collection do let(:member_type) { Volume } subject!(:collection) do Praxis::Collection.of(member_type) end let(:identifier_string) { subject.identifier.to_s } context '.of' do let(:member_type) do Class.new(Praxis::MediaTyp...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/response_definition_spec.rb
Ruby
mit
302
master
15,449
# frozen_string_literal: true require 'spec_helper' describe Praxis::ResponseDefinition do subject(:response_definition) { Praxis::ResponseDefinition.new(name, &block) } let(:name) { 'response_name' } let(:block) do proc do status 200 description 'test description' header('X-Header', 'val...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/config_spec.rb
Ruby
mit
302
master
3,624
# frozen_string_literal: true require 'spec_helper' describe Praxis::Config do subject(:config) do Praxis::Config.new end describe '#initialize' do it 'its type is a Struct type' do expect(config.attribute.type < Attributor::Struct).to be(true) end it 'has no value' do expect(config...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/plugin_concern_spec.rb
Ruby
mit
302
master
578
# frozen_string_literal: true require 'spec_helper' describe Praxis::PluginConcern do it 'works' do expect(Praxis::Request.instance_methods).to include(:user_abilities) end context 'ActionDefinition' do subject(:action) { ApiResources::Instances.actions[:terminate] } its(:required_abilities) { shou...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/request_spec.rb
Ruby
mit
302
master
7,479
# frozen_string_literal: true require 'spec_helper' describe Praxis::Request do let(:path) { '/instances/1?junk=foo&api_version=1.0' } let(:rack_input) { StringIO.new('{"something": "given"}') } let(:env_content_type) { 'application/json' } let(:env) do env = Rack::MockRequest.env_for(path) env['rack....
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/application_spec.rb
Ruby
mit
302
master
3,939
# frozen_string_literal: true require 'spec_helper' describe Praxis::Application do context 'configuration' do subject(:app) do app = Class.new(Praxis::Application).instance config = Object.new def config.define(key = nil, type = Attributor::Struct, **opts, &block) [key, type, opts, b...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/controller_spec.rb
Ruby
mit
302
master
835
# frozen_string_literal: true require 'spec_helper' describe Praxis::Controller do subject do Class.new do include Praxis::Controller implements PeopleResource before :validate, actions: [:index] do 'before' end before actions: [:show] do end after :response...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/callbacks_spec.rb
Ruby
mit
302
master
3,593
# frozen_string_literal: true require 'spec_helper' describe Praxis::Callbacks do let(:controller) { double('controller', request: 'request') } subject do Class.new do include Praxis::Callbacks # implements PeopleResource before :validate, actions: [:index] do |_controller| '...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/blueprint_spec.rb
Ruby
mit
302
master
26,306
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") describe Praxis::Blueprint do subject(:blueprint_class) { PersonBlueprint } its(:family) { should eq('hash') } # This context might seem a duplication of tests that should be covered by the underlying attributor...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/middleware_app_spec.rb
Ruby
mit
302
master
2,378
# frozen_string_literal: true require 'spec_helper' describe Praxis::MiddlewareApp do let(:init_args) { { root: 'here' } } let(:middleware) { Praxis::MiddlewareApp.for(**init_args) } let(:instance) { middleware.new(target) } context '.for' do it 'does not initialize the Application instance yet' do ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/renderer_spec.rb
Ruby
mit
302
master
5,661
# frozen_string_literal: true require_relative '../spec_helper' describe Praxis::Renderer do let(:address) { AddressBlueprint.example } let(:prior_addresses) { Array.new(2) { AddressBlueprint.example } } let(:alias_one) { FullName.example } let(:alias_two) { FullName.example } let(:aliases) { [alias_one, al...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/bootloader_spec.rb
Ruby
mit
302
master
3,385
# frozen_string_literal: true require 'spec_helper' describe Praxis::Bootloader do let(:application) do instance_double('Praxis::Application', config: 'config', root: 'root', plugins: {}, file_layout: {}) end subject(:bootloader) { Praxis::Bootloader.new(application) } context 'attributes' do its(:a...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/api_definition_spec.rb
Ruby
mit
302
master
5,674
# frozen_string_literal: true require 'spec_helper' describe Praxis::ApiDefinition do subject(:api) { Praxis::ApiDefinition.instance } # Without getting a fresh new ApiDefinition it is very difficult to test stuff using the Singleton # So for some tests we're gonna create a new instance and work with it to avo...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/notifications_spec.rb
Ruby
mit
302
master
530
# frozen_string_literal: true require 'spec_helper' describe Praxis::Notifications do let(:events) { [] } before do Praxis::Notifications.subscribe('render') do |_name, _start, _finish, _id, payload| events << payload end Praxis::Notifications.instrument('render', extra: :information) do e...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/action_definition_spec.rb
Ruby
mit
302
master
11,807
# frozen_string_literal: true require 'spec_helper' class SpecMediaType < Praxis::MediaType identifier 'application/json' attributes do attribute :one, String attribute :two, Integer end default_fieldset do attribute :one end end describe Praxis::ActionDefinition do let(:endpoint_definition)...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/trait_spec.rb
Ruby
mit
302
master
1,791
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") describe Praxis::Trait do subject(:trait) do Praxis::Trait.new do description 'my awesome trait' routing do prefix '/:app_name' end response :something response :nothing ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/field_expander_spec.rb
Ruby
mit
302
master
8,165
# frozen_string_literal: true require 'spec_helper' describe Praxis::FieldExpander do let(:field_expander) { Praxis::FieldExpander.new } let(:expanded_person_default_fieldset) do # The only ones that are not already leaves is the full name, which can expand to first, last PersonBlueprint.default_fieldset....
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/media_type_identifier_spec.rb
Ruby
mit
302
master
8,639
# frozen_string_literal: true # rubocop:disable Style/StringConcatenation require 'spec_helper' describe Praxis::MediaTypeIdentifier do let(:example) { 'application/ice-cream+sundae; nuts="true"; fudge="true"' } subject { described_class.load(example) } context '.load' do context 'of nil values' do ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/media_type_spec.rb
Ruby
mit
302
master
1,628
# frozen_string_literal: true require 'spec_helper' describe Praxis::MediaType do let(:owner_resource) { instance_double(Person, id: 100, name: Faker::Name.first_name, href: '/') } let(:manager_resource) { instance_double(Person, id: 101, name: Faker::Name.first_name, href: '/') } let(:custodian_resource) { ins...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/config_hash_spec.rb
Ruby
mit
302
master
2,031
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") describe Praxis::ConfigHash do subject(:instance) { Praxis::ConfigHash.new(hash, &block) } let(:hash) { { one: ['existing'], two: 'dos' } } let(:block) do proc { 'abc' } end context 'initialization' do ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/route_spec.rb
Ruby
mit
302
master
928
# frozen_string_literal: true require 'spec_helper' describe Praxis::Route do let(:verb) { 'GET' } let(:path) { '/base/stuff' } let(:prefixed_path) { '/stuff' } let(:version) { '1.0' } let(:options) { {} } subject(:route) { Praxis::Route.new(verb, path, version, prefixed_path: prefixed_path, **options) }...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/stage_spec.rb
Ruby
mit
302
master
3,221
# frozen_string_literal: true require 'spec_helper' describe Praxis::Stage do subject(:stage) { Praxis::Stage.new('name', 'context') } context 'attributes' do its(:name) { should eq('name') } its(:context) { should eq('context') } its(:stages) { should eq([]) } its(:before_callbacks) { should eq(...