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
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
config/deploy.rb
Ruby
apache-2.0
97
master
2,336
lock '3.9.1' set :application, 'cve_server' set :repo_url, 'https://github.com/SpiderLabs/cve_server.git' set :branch, 'master' # Default branch is :master set :deploy_to, '/home/deployer/cve_server' set :stage, :production set :pty, false set :linked_dirs, fetch(:linked_dirs, []).push('nvd_data', 'log', 'tmp') set :p...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
config/puma.rb
Ruby
apache-2.0
97
master
759
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'cve_server' @config = CVEServer::Boot.config directory @config.root rackup File.join(@config.root, 'config.ru') environment @config.env daemonize @config.env == 'production' pid_dir = File.join(@config.root, 'tmp', 'pids') Dir.mkdir pid_di...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
examples/client.rb
Ruby
apache-2.0
97
master
925
=begin Ruby Implementation Examples: client = Client.new("127.0.0.1") or client = Client.new("127.0.0.1", 8080) or client = Client.new("127.0.0.1", 443, "https") # Get all CPEs defined cpes = client.get_all_cpes() # Get all CVEs per CPE cves = client.get_cves_per_cpe("apache:http_serve...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/spec_helper.rb
Ruby
apache-2.0
97
master
471
require 'rspec' require 'rack/test' require 'json' require 'simplecov' ENV['RACK_ENV'] = 'test' $LOAD_PATH.unshift File.expand_path('../lib', __FILE__) SimpleCov.start module CVEServer module TestHelper def response_content_type last_response.headers['Content-Type'] end def json_response J...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/cve_spec.rb
Ruby
apache-2.0
97
master
2,735
require 'spec_helper' require 'cve_server/cve' describe CVEServer::Cve do describe '#all_cpes_affected' do context 'when no CPEs are provided' do it 'should return the expected affected CPEs' do expected_results = [ "apache:camel", "cisco:adaptive_security_appliance_software", ...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/app_spec.rb
Ruby
apache-2.0
97
master
29,420
require 'spec_helper' require 'cve_server/app' shared_examples "good response results" do |url, expected_results| describe "verifying the response for #{url}" do before :all do get url end it 'response should be ok' do expect(last_response).to be_ok end it 'response is not empty' do...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/helper_spec.rb
Ruby
apache-2.0
97
master
3,711
require 'spec_helper' require 'cve_server/helper' module HelperSpec module_function def cves [ 'CVE-2011-1529', 'CVE-2011-1530', 'CVE-2011-1624', 'CVE-2011-1625', 'CVE-2011-1640', 'CVE-2011-1737', 'CVE-2011-1738', 'CVE-2012-0814', 'cve-2013-2125', 'c...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/config_spec.rb
Ruby
apache-2.0
97
master
550
require 'spec_helper' require 'cve_server/config' describe CVEServer::Config do before :all do @conf = CVEServer::Config.new end it 'should be a test environment' do expect(@conf.env).to eq 'test' end it 'should have the mongo database adapter' do expect(@conf.db_adapter).to eq 'mongo' end ...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/boot_spec.rb
Ruby
apache-2.0
97
master
688
require 'spec_helper' require 'cve_server/boot' describe CVEServer::Boot do describe 'CVEServer::Boot included in a class' do before :all do class BootTestClass include CVEServer::Boot end @class = BootTestClass.new end it 'should have a CveService::Config instance in the confi...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/nvd/cvss_spec.rb
Ruby
apache-2.0
97
master
4,771
require 'spec_helper' require 'cve_server/nvd/cvss' module CvssSpec module_function def cvss [ { cvss: { score: '7.5', access_vector: 'NETWORK', access_complexity: 'LOW', authentication: 'NONE', confidentiality_impact: 'PARTIAL', integr...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/nvd/json/reader_spec.rb
Ruby
apache-2.0
97
master
1,506
require 'spec_helper' require 'zlib' require 'cve_server/nvd/json/reader' describe CVEServer::NVD::JSON::Reader do context 'when it receives a valid JSON input from NVD' do let(:infile) { json_file = '../../../../fixtures/nvd_data/partial-nvdcve-1.0_seed.json.gz' File.expand_path(json_file, __FILE__)...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/nvd/json/entry_spec.rb
Ruby
apache-2.0
97
master
10,007
require 'spec_helper' require 'zlib' require 'cve_server/nvd/json/entry' describe CVEServer::NVD::JSON::Entry do context 'when it receives a valid entry from the NVD dataset' do let(:infile) { json_file = '../../../../fixtures/nvd_data/partial-nvdcve-1.0_seed.json.gz' File.expand_path(json_file, __FI...
github
SpiderLabs/cve_server
https://github.com/SpiderLabs/cve_server
spec/cve_server/db/document_spec.rb
Ruby
apache-2.0
97
master
411
require 'spec_helper' require 'cve_server/db/document' describe CVEServer::DB::Document do describe 'CVEServer::DB::Document included in a class' do before :all do # Dummy class class Cve include CVEServer::DB::Document collection_name :cves end end it 'should find one ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
Rakefile
Ruby
mit
97
main
392
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'Filterameter' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.md') ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
Guardfile
Ruby
mit
97
main
805
# frozen_string_literal: true guard :rspec, cmd: 'bundle exec rspec' do require 'guard/rspec/dsl' dsl = Guard::RSpec::Dsl.new(self) # RSpec files rspec = dsl.rspec watch(rspec.spec_helper) { rspec.spec_dir } watch(rspec.spec_support) { rspec.spec_dir } watch(rspec.spec_files) # Ruby files ruby = ds...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
filterameter.gemspec
Ruby
mit
97
main
1,321
$:.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "filterameter/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |spec| spec.name = "filterameter" spec.version = Filterameter::VERSION spec.authors = ["Todd Kummer"] spec.email ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
Gemfile
Ruby
mit
97
main
761
# frozen_string_literal: true source 'https://gem.coop' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Declare your gem's dependencies in filterameter.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :developme...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter.rb
Ruby
mit
97
main
391
# frozen_string_literal: true require 'zeitwerk' loader = Zeitwerk::Loader.for_gem loader.setup # ready! # # Filterameter module Filterameter class << self attr_writer :configuration end def self.configuration @configuration ||= Configuration.new end def self.reset @configuration = Configurat...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filter_factory.rb
Ruby
mit
97
main
2,198
# frozen_string_literal: true module Filterameter # # Filter Factory # # Class FilterFactory builds a filter from a FilterDeclaration. class FilterFactory def initialize(model_class) @model_class = model_class end def build(declaration) context = Helpers::DeclarationWithModel.new(@mode...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/query_builder.rb
Ruby
mit
97
main
4,678
# frozen_string_literal: true module Filterameter # # Query Builder # # Class Query Builder turns filter parameters into a query. # # The query builder is instantiated by the filter coordinator. The default query currently is simple `all`. The # default sort comes for the controller declaration of the same...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declarations_validator.rb
Ruby
mit
97
main
2,726
# frozen_string_literal: true module Filterameter # # Declarations Validator # # Class DeclarationsValidtor fetches each filter and sort from the registry to validate the declaration. This class # can be accessed from the controller as `declarations_validator` (via the FilterCoordinator) and be used in tests. ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filter_coordinator.rb
Ruby
mit
97
main
2,308
# frozen_string_literal: true require 'active_support/inflector' require 'active_support/rails' require 'action_dispatch' require 'action_controller/metal/live' require 'action_controller/metal/strong_parameters' module Filterameter # # Filter Coordinator # # Class FilterCoordinator stores the configuration de...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/sort_declaration.rb
Ruby
mit
97
main
997
# frozen_string_literal: true module Filterameter # # Sort Declaration # # Class SortDeclaration captures the sort declaration within the controller. A sort declaration is also generated # from a FilterDeclaration when it is `sortable?`. class SortDeclaration attr_reader :name, :parameter_name, :associat...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors.rb
Ruby
mit
97
main
267
# frozen_string_literal: true module Filterameter module DeclarationErrors # # Declaration Error # # Error DeclarationError provides a base class for errors from filter or sort declarations. class DeclarationError < StandardError end end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/sort_factory.rb
Ruby
mit
97
main
1,274
# frozen_string_literal: true module Filterameter # # Sort Factory # # Class SortFactory builds a sort from a model and a declaration. class SortFactory def initialize(model_class) @model_class = model_class end def build(declaration) context = Helpers::DeclarationWithModel.new(@model_...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/errors.rb
Ruby
mit
97
main
543
# frozen_string_literal: true module Filterameter # # Errors # # Module Errors provides `valid?` and `errors` to implementing classes. If the `valid?` method is not overridden, # then it returns true. # # To provide validations rules, override `validate`. If any fail, populate the errors attribute with the...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/configuration.rb
Ruby
mit
97
main
1,609
# frozen_string_literal: true module Filterameter # # Configuration # # Class Configuration stores the following settings: # * action_on_undeclared_parameters # * action_on_validation_failure # * filter_key # # ## Action on Undeclared Parameters # # Occurs when the filter parameter contains a...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filter_declaration.rb
Ruby
mit
97
main
2,693
# frozen_string_literal: true require 'active_support/core_ext/array/wrap' module Filterameter # # Filter Declaration # # Class FilterDeclaration captures the filter declaration within the controller. # # When the min_only or max_only range option is specified, in addition to the attribute filter which carr...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/parameters_base.rb
Ruby
mit
97
main
1,164
# frozen_string_literal: true require 'active_model/attribute_assignment' require 'active_model/validations' module Filterameter # # Parameters # # Class Parameters is sub-classed to provide controller-specific validations. class ParametersBase include ActiveModel::Validations include Filterameter::Va...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/log_subscriber.rb
Ruby
mit
97
main
616
# frozen_string_literal: true module Filterameter # # Log Subscriber # # Class LogSubscriber provides instrumentation for events. class LogSubscriber < ActiveSupport::LogSubscriber def validation_failure(event) debug do errors = event.payload[:errors] ([' The following filter validat...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declarative_filters.rb
Ruby
mit
97
main
8,001
# frozen_string_literal: true module Filterameter # # Declarative Controller Filters # # Mixin DeclarativeFilters should be included in controllers to enable the filter DSL. module DeclarativeFilters extend ActiveSupport::Concern class_methods do delegate :declarations_validator, to: :filter_coo...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/maximum_filter.rb
Ruby
mit
97
main
332
# frozen_string_literal: true module Filterameter module Filters # # Maximum Filter # # Class MaximumFilter adds criteria for all values greater than or equal to a maximum. class MaximumFilter < ArelFilter def apply(query, value) query.where(@arel_attribute.lteq(value)) end en...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/matches_filter.rb
Ruby
mit
97
main
769
# frozen_string_literal: true module Filterameter module Filters # # Matches Filter # # Class MatchesFilter uses arel's `matches` to generate a LIKE query. class MatchesFilter include Filterameter::Errors include Filterameter::Filters::AttributeValidator def initialize(attribute_na...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/conditional_scope_filter.rb
Ruby
mit
97
main
949
# frozen_string_literal: true module Filterameter module Filters # # Conditional Scope Filter # # Class ConditionalScopeFilter applies the scope if the parameter is not false. class ConditionalScopeFilter include Filterameter::Errors def initialize(scope_name) @scope_name = scope...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/nested_collection_filter.rb
Ruby
mit
97
main
372
# frozen_string_literal: true module Filterameter module Filters # # Nested Collection Filter # # Class NestedCollectionFilter joins the nested table(s), merges the filter to the association's model, then makes # the results distinct. class NestedCollectionFilter < NestedFilter def apply(*)...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/attribute_validator.rb
Ruby
mit
97
main
443
# frozen_string_literal: true module Filterameter module Filters # # Attribute Validator # # Module AttributeValidator validates that the attribute exists on the model. module AttributeValidator private def validate(model) return if model.attribute_method? @attribute_name ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/arel_filter.rb
Ruby
mit
97
main
473
# frozen_string_literal: true module Filterameter module Filters # # Arel Filter # # Class ArelFilter is a base class for arel queries. It does not implement # `apply`. class ArelFilter include Filterameter::Errors include Filterameter::Filters::AttributeValidator def initializ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/scope_filter.rb
Ruby
mit
97
main
730
# frozen_string_literal: true module Filterameter module Filters # # Scope Filter # # Class ScopeFilter applies the named scope passing in the parameter value. class ScopeFilter include Filterameter::Errors def initialize(scope_name) @scope_name = scope_name end def ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/minimum_filter.rb
Ruby
mit
97
main
332
# frozen_string_literal: true module Filterameter module Filters # # Minimum Filter # # Class MinimumFilter adds criteria for all values greater than or equal to a minimum. class MinimumFilter < ArelFilter def apply(query, value) query.where(@arel_attribute.gteq(value)) end en...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/nested_filter.rb
Ruby
mit
97
main
1,068
# frozen_string_literal: true module Filterameter module Filters # # Nested Attribute Filter # # Class NestedFilter joins the nested table(s) then merges the filter to the association's model. class NestedFilter include Filterameter::Errors def initialize(association_names, association_m...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/filters/attribute_filter.rb
Ruby
mit
97
main
493
# frozen_string_literal: true module Filterameter module Filters # # Attribute Filter # # Class AttributeFilter leverages ActiveRecord's where query method to add criteria for an attribute. class AttributeFilter include Filterameter::Errors include AttributeValidator def initialize...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/helpers/joins_values_builder.rb
Ruby
mit
97
main
845
# frozen_string_literal: true module Filterameter module Helpers # # Joins Values Builder # # Class JoinsValuesBuilder evaluates an array of names to return either the single entry when there is only # one element in the array or a nested hash when there is more than one element. This is the argument...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/helpers/requested_sort.rb
Ruby
mit
97
main
563
# frozen_string_literal: true module Filterameter module Helpers # # Reqested Sort # # Class RequestedSort parses the name and direction from a sort segment. class RequestedSort SIGN_AND_NAME = /(?<sign>[+|-]?)(?<name>\w+)/ attr_reader :name, :direction def self.parse(sort) ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/helpers/declaration_with_model.rb
Ruby
mit
97
main
1,658
# frozen_string_literal: true module Filterameter module Helpers # # Declaration with Model # # Class DeclarationWithModel inspects the declaration under the context of the model. This enables # predicate methods as well as drilling through associations. class DeclarationWithModel def initi...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/validators/inclusion_validator.rb
Ruby
mit
97
main
821
# frozen_string_literal: true module Filterameter module Validators # # Inclusion Validator # # Class InclusionValidator extends ActiveModel::Validations::InclusionValidator to enable validations of multiple # values. # # ## Example # # validates: { inclusion: { in: %w[Small Mediu...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/options/partial_options.rb
Ruby
mit
97
main
2,727
# frozen_string_literal: true module Filterameter module Options # # Partial Options # # Class PartialOptions parses the options passed in as partial, then exposes # those. Here are the options along with their valid values: # * match: anywhere (default), from_start, dynamic # * case_sens...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors/filter_scope_argument_error.rb
Ruby
mit
97
main
653
# frozen_string_literal: true module Filterameter module DeclarationErrors # # Filter Scope Argument Error # # Error FilterScopeArgumentError occurs when a scope used as a filter but does not have either zero or one # arument. A conditional scope filter should take zero arguments; other scope filters...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors/no_such_attribute_error.rb
Ruby
mit
97
main
632
# frozen_string_literal: true module Filterameter module DeclarationErrors # # No Such Attribute Error # # Error NoSuchAttributeError occurs when a filter or sort references an attribute that does not exist on the model. # The most likely case of this is a typo. Note that if the typo was supposed to ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors/sort_scope_requires_one_argument_error.rb
Ruby
mit
97
main
616
# frozen_string_literal: true module Filterameter module DeclarationErrors # # Sort Scope Requires One Argument Error # # Error SortScopeRequiresOneArgumentError occurs when a sort has been declared for a scope that does not take # exactly one argument. Sort scopes must take a single argument and wil...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors/unexpected_error.rb
Ruby
mit
97
main
716
# frozen_string_literal: true module Filterameter module DeclarationErrors # # Unexpected Error # # Error UnexpectedError occurs when the filter or scope factory raises an exception that the validator did not # expect. class UnexpectedError < DeclarationError def initialize(error) s...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors/cannot_be_inline_scope_error.rb
Ruby
mit
97
main
1,245
# frozen_string_literal: true module Filterameter module DeclarationErrors # # Cannot Be Inline Scope Error # # Error CannotBeInlineScopeError occurs when an inline scope has been used to define a filter that takes a # parameter. This is not valid for use as a Filterameter filter because an inline sc...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/declaration_errors/not_a_scope_error.rb
Ruby
mit
97
main
699
# frozen_string_literal: true module Filterameter module DeclarationErrors # # Not A Scope Error # # Error NotAScopeError flags a class method that has been used as a filter but is not a scope. This could occur if # there is a class method of the same name an attribute, in which case the class method...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/sorts/attribute_sort.rb
Ruby
mit
97
main
517
# frozen_string_literal: true module Filterameter module Sorts # # Attribute Sort # # Class AttributeSort leverages ActiveRecord's `order` query method to add sorting for an attribute. class AttributeSort include Filterameter::Errors include Filterameter::Filters::AttributeValidator ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/sorts/scope_sort.rb
Ruby
mit
97
main
790
# frozen_string_literal: true module Filterameter module Sorts # # Scope Sort # # Class ScopeSort applies the scope with the a param that is either :asc or :desc. A scope that does not take # exactly one argument is not valid for sorting. class ScopeSort < Filterameter::Filters::ScopeFilter ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/exceptions/invalid_association_declaration_error.rb
Ruby
mit
97
main
492
# frozen_string_literal: true module Filterameter module Exceptions # # Invalid Association Declaration Error # # Class InvalidAssociationDeclarationError is raised when the declared association(s) are not valid. class InvalidAssociationDeclarationError < FilterameterError def initialize(name, ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/exceptions/collection_association_sort_error.rb
Ruby
mit
97
main
496
# frozen_string_literal: true module Filterameter module Exceptions # # Collection Association Sort Error # # Class CollectionAssociationSortError is raised when a sort is attempted on a # collection association. (Sorting is only valid on *singular* associations.) class CollectionAssociationSortE...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/exceptions/validation_error.rb
Ruby
mit
97
main
575
# frozen_string_literal: true module Filterameter module Exceptions # # Validation Error # # Class ValidationError is raised when a specified parameter fails a validation. Configuration setting # `action_on_validation_failure` determines whether or not the exception is raised. class ValidationErr...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/exceptions/undeclared_parameter_error.rb
Ruby
mit
97
main
609
# frozen_string_literal: true module Filterameter module Exceptions # # Undeclared Parameter Error # # Class UndeclaredParameterError is raised when a request contains filter parameters that have not been declared. # Configuration setting `action_on_undeclared_parameters` determines whether or not th...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/exceptions/cannot_determine_model_error.rb
Ruby
mit
97
main
862
# frozen_string_literal: true module Filterameter module Exceptions # # Cannot Determine Model Error # # Class CannotDetermineModelError is raised when the model class cannot be determined from either the controller # name or controller path. This is a setup issue; the resolution is for the controlle...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/registries/sort_registry.rb
Ruby
mit
97
main
547
# frozen_string_literal: true module Filterameter module Registries # # Sort Registry # # Class SortRegistry is a collection of the sorts. It captures the declarations when classes are loaded, # then uses the injected SortFactory to build the sorts on demand as they are needed. class SortRegistry...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/registries/filter_registry.rb
Ruby
mit
97
main
2,395
# frozen_string_literal: true module Filterameter module Registries # # Filter Registry # # Class FilterRegistry is a collection of the filters. It captures the filter declarations when classes are loaded, # then uses the injected FilterFactory to build the filters on demand as they are needed. c...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/registries/sub_registry.rb
Ruby
mit
97
main
930
# frozen_string_literal: true module Filterameter module Registries # # SubRegistry # # Class SubRegistry provides add and fetch methods as well as the initialization for sub-registries. # # Subclasses must implement build_declaration. class SubRegistry def initialize(factory) @...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
lib/filterameter/registries/registry.rb
Ruby
mit
97
main
1,246
# frozen_string_literal: true module Filterameter module Registries # # Registry # # Class Registry records declarations and allows resulting filters and sorts to be fetched from sub-registries. class Registry delegate :filter_declarations, :ranges, to: :@filter_registry delegate :paramet...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/rails_helper.rb
Ruby
mit
97
main
714
# frozen_string_literal: true require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('dummy/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 'rspec/rails' beg...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/spec_helper.rb
Ruby
mit
97
main
1,335
# frozen_string_literal: true require 'filterameter' require 'simplecov' SimpleCov.start do add_filter 'spec/' enable_coverage :branch end RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_wi...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/controllers/activities_controller_spec.rb
Ruby
mit
97
main
1,419
# frozen_string_literal: true require 'rails_helper' RSpec.describe ActivitiesController do let(:error_messages) do <<~ERROR.chomp Invalid filter for 'inline_with_arg': #{Filterameter::DeclarationErrors::CannotBeInlineScopeError.new('Activity', :inline_with_arg)} Invalid filter for 'not_a_...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/controllers/projects_controller_spec.rb
Ruby
mit
97
main
230
# frozen_string_literal: true require 'rails_helper' RSpec.describe ProjectsController do it 'has valid declarations' do declarations = described_class.declarations_validator expect(declarations).to be_valid end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/config/application.rb
Ruby
mit
97
main
1,142
require_relative 'boot' require "rails" # Pick the frameworks you want: require "active_model/railtie" # require "active_job/railtie" require "active_record/railtie" # require "active_storage/engine" require "action_controller/railtie" # require "action_mailer/railtie" # require "action_view/railtie" # require "action...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/config/routes.rb
Ruby
mit
97
main
273
Rails.application.routes.draw do resources :tasks, only: :index resources :activities, only: :index resources :projects, only: :index resources :legacy_projects, only: :index resources :active_activities, only: :index resources :active_tasks, only: :index end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/config/environments/production.rb
Ruby
mit
97
main
4,431
require 'active_support/core_ext/integer/time' 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 applica...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/config/environments/test.rb
Ruby
mit
97
main
2,035
require 'active_support/core_ext/integer/time' # 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 suite and is wiped # and recreated between test runs. Don't rely on the data the...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/config/environments/development.rb
Ruby
mit
97
main
2,100
require 'active_support/core_ext/integer/time' 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 any time # it changes. This slows down response time but is perfect for developme...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/db/schema.rb
Ruby
mit
97
main
2,552
# 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. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/db/migrate/20240528223943_create_activities.rb
Ruby
mit
97
main
362
class CreateActivities < ActiveRecord::Migration[7.1] def change create_table :activities do |t| t.references :project, null: false, foreign_key: true t.references :activity_manager, null: false, foreign_key: { to_table: :users } t.string :name t.integer :task_count t.boolean :comple...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/db/migrate/20240528224846_create_tasks.rb
Ruby
mit
97
main
247
class CreateTasks < ActiveRecord::Migration[7.1] def change create_table :tasks do |t| t.references :activity, null: false, foreign_key: true t.string :description t.boolean :completed t.timestamps end end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/db/migrate/20240528221556_create_projects.rb
Ruby
mit
97
main
240
class CreateProjects < ActiveRecord::Migration[7.1] def change create_table :projects do |t| t.string :name t.integer :priority t.datetime :start_date t.datetime :end_date t.timestamps end end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/db/migrate/20240528224644_create_activity_members.rb
Ruby
mit
97
main
270
class CreateActivityMembers < ActiveRecord::Migration[7.1] def change create_table :activity_members do |t| t.references :activity, null: false, foreign_key: true t.references :user, null: false, foreign_key: true t.timestamps end end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/controllers/activities_controller.rb
Ruby
mit
97
main
1,013
# frozen_string_literal: true class ActivitiesController < ApplicationController before_action :build_filtered_query, only: :index filter :activity_manager_id filter :manager_id, name: :activity_manager_id filter :incomplete filter :in_progress, name: :incomplete filter :task_count, range: true filter :...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/controllers/active_tasks_controller.rb
Ruby
mit
97
main
300
# frozen_string_literal: true class ActiveTasksController < ApplicationController filter_model Task filters :activity_id, :completed def index @tasks = build_query_from_filters render json: @tasks end private def filter_parameters super.merge(completed: false) end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/controllers/legacy_projects_controller.rb
Ruby
mit
97
main
365
# frozen_string_literal: true class LegacyProjectsController < ApplicationController filter_model Project filter :priority, validates: { inclusion: { in: Project.priorities.keys } } def index @projects = build_query_from_filters render json: @projects end private def filter_parameters param...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/controllers/active_activities_controller.rb
Ruby
mit
97
main
221
# frozen_string_literal: true class ActiveActivitiesController < ApplicationController filter_model 'Activity' filter :project_id def index render json: build_query_from_filters(Activity.incomplete) end end
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/controllers/projects_controller.rb
Ruby
mit
97
main
681
# frozen_string_literal: true class ProjectsController < ApplicationController filter :priority, validates: { inclusion: { in: Project.priorities.keys } } filter :activity_manager_active, name: :active, association: %i[activities activity_manager] filter :tasks_completed, name: :completed, association: %i[activi...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/controllers/tasks_controller.rb
Ruby
mit
97
main
1,058
# frozen_string_literal: true class TasksController < ApplicationController filter :completed filter :description, partial: true filter :description_starts_with, name: :description, partial: :from_start filter :description_case_sensitive, name: :description, partial: { case_sensitive: true } filter :descript...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/models/activity.rb
Ruby
mit
97
main
1,299
# frozen_string_literal: true class Activity < ApplicationRecord belongs_to :project belongs_to :activity_manager, class_name: 'User' has_many :activity_members, dependent: :destroy has_many :tasks, dependent: :destroy scope :incomplete, -> { where(completed: false) } # this could be handled by attribute...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/dummy/app/models/project.rb
Ruby
mit
97
main
780
# frozen_string_literal: true class Project < ApplicationRecord has_many :activities, dependent: :destroy # enum signature changed in Rails 7 if method(:enum).arity == 1 enum priority: { low: 0, medium: 1, high: 2 }, _suffix: true # rubocop:disable Rails/EnumSyntax else enum :priority, { low: 0, mediu...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/attribute_sorts_spec.rb
Ruby
mit
97
main
3,008
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Attribute sorts' do context 'with filter declaration' do before { get '/activities', params: { filter: { sort: :activity_manager_id } } } it 'sorts' do expect(response).to have_http_status(:success) ordered = response.parsed_b...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/range_filters_spec.rb
Ruby
mit
97
main
3,372
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Range filters' do context 'when range: true' do context 'with exact value' do before { get '/activities', params: { filter: { task_count: 3 } } } it 'returns the correct number of rows' do count = Activity.where(task_count...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/filter_key_configuration_spec.rb
Ruby
mit
97
main
1,881
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Filter Key configuration' do before { allow(Filterameter).to receive(:configuration).and_return(custom_config) } context 'with key overriden to f' do let(:custom_config) { Filterameter::Configuration.new.tap { |c| c.filter_key = :f } } ...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/default_sorts_spec.rb
Ruby
mit
97
main
585
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Default sorts' do context 'with no default specified' do before { get '/projects' } it 'sorts by primary key desc' do ordered = response.parsed_body.pluck('id') expect(ordered).to eq Project.order(id: :desc).pluck(:id) end...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/scope_sorts_spec.rb
Ruby
mit
97
main
584
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Scope sorts' do context 'with class method scope' do before { get '/projects', params: { filter: { sort: :by_created_at } } } it 'returns successfully' do expect(response).to have_http_status(:success) end end context 'with...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/scope_filters_spec.rb
Ruby
mit
97
main
2,149
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Scope filters' do context 'when conditional' do context 'when true' do before { get '/activities', params: { filter: { incomplete: true } } } it 'returns the correct number of rows' do count = Activity.where(completed: fal...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/attribute_filters_spec.rb
Ruby
mit
97
main
3,829
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Attribute filters' do context 'with no options' do before { get '/activities', params: { filter: { activity_manager_id: users(:joe_jackson).id } } } it 'returns the correct number of rows' do count = Activity.where(activity_manager_...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/multi_level_nested_attribute_filters_spec.rb
Ruby
mit
97
main
3,150
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Multi-level nested attribute filters' do context 'with singular-to-singular association' do before { get '/tasks', params: { filter: { project_priority: 'high' } } } it 'returns the correct number of rows' do count = Task.joins(acti...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/partial_filters_spec.rb
Ruby
mit
97
main
2,540
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Partial filters' do context 'with defaults' do before { get '/tasks', params: { filter: { description: 'beans' } } } it 'returns the correct number of rows' do count = Task.where("description like '%beans%'").count expect(resp...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/controller_overrides_spec.rb
Ruby
mit
97
main
1,786
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Controller overrides' do context 'with nested key overridden' do before { get '/legacy_projects', params: { criteria: { priority: 'high' } } } it 'returns the correct number of rows' do count = Project.high_priority.count expe...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/multi_level_nested_scope_filters_spec.rb
Ruby
mit
97
main
2,522
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Nested scope filters' do context 'with singular-to-singular association' do before { get '/tasks', params: { filter: { low_priority_projects: 'low' } } } it 'returns the correct number of rows' do count = Task.joins(activity: :proje...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/requests/nested_filters_spec.rb
Ruby
mit
97
main
2,626
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Nested filters' do describe 'attribute filters' do context 'with singular association' do before { get '/activities', params: { filter: { project_priority: 'high' } } } it 'returns the correct number of rows' do count = Ac...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/filterameter/declarative_filters_spec.rb
Ruby
mit
97
main
2,078
# frozen_string_literal: true require 'rails_helper' RSpec.describe Filterameter::DeclarativeFilters do describe '.filter_model' do let(:model_class) { controller.filter_coordinator.instance_variable_get('@model_class') } context 'with model as string' do let(:controller) do Class.new(Applica...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/filterameter/filter_coordinator_spec.rb
Ruby
mit
97
main
1,251
# frozen_string_literal: true require 'rails_helper' RSpec.describe Filterameter::FilterCoordinator do describe 'constructor tries to populate model class from controller name and path' do let(:controller_name) { 'my_models' } let(:controller_path) { 'foo_bar/my_models' } let(:model) { instance_double(C...
github
RockSolt/filterameter
https://github.com/RockSolt/filterameter
spec/filterameter/sort_factory_spec.rb
Ruby
mit
97
main
1,212
# frozen_string_literal: true require 'rails_helper' RSpec.describe Filterameter::SortFactory do let(:factory) { described_class.new(Project) } let(:sort) { factory.build(declaration) } context 'with attribute declaration' do let(:declaration) { Filterameter::SortDeclaration.new(:name, {}) } it('is an...