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
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/httparty/request/streaming_multipart_body_spec.rb
Ruby
mit
5,889
main
4,182
require 'spec_helper' require 'tempfile' RSpec.describe HTTParty::Request::StreamingMultipartBody do let(:boundary) { '------------------------c772861a5109d5ef' } describe '#read' do context 'with a simple file' do let(:file) { File.open('spec/fixtures/tiny.gif', 'rb') } let(:parts) { [['avatar', ...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/httparty/request/body_spec.rb
Ruby
mit
5,889
main
9,737
require 'spec_helper' require 'tempfile' RSpec.describe HTTParty::Request::Body do describe '#call' do let(:options) { {} } subject { described_class.new(params, **options).call } context 'when params is string' do let(:params) { 'name=Bob%20Jones' } it { is_expected.to eq params } end...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/httparty/logger/apache_formatter_spec.rb
Ruby
mit
5,889
main
1,457
require 'spec_helper' RSpec.describe HTTParty::Logger::ApacheFormatter do let(:subject) { described_class.new(logger_double, :info) } let(:logger_double) { double('Logger') } let(:request_double) { double('Request', http_method: Net::HTTP::Get, path: "http://my.domain.com/my_path") } let(:request_time) { Time....
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/httparty/logger/curl_formatter_spec.rb
Ruby
mit
5,889
main
3,695
require 'spec_helper' RSpec.describe HTTParty::Logger::CurlFormatter do describe "#format" do let(:logger) { double('Logger') } let(:response_object) { Net::HTTPOK.new('1.1', 200, 'OK') } let(:parsed_response) { lambda { {"foo" => "bar"} } } let(:response) do HTTParty::Response.new(re...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/httparty/logger/logger_spec.rb
Ruby
mit
5,889
main
1,454
require 'spec_helper' RSpec.describe HTTParty::Logger do describe ".build" do subject { HTTParty::Logger } it "defaults level to :info" do logger_double = double expect(subject.build(logger_double, nil, nil).level).to eq(:info) end it "defaults format to :apache" do logger_double ...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/httparty/logger/logstash_formatter_spec.rb
Ruby
mit
5,889
main
1,419
require 'json' require 'spec_helper' RSpec.describe HTTParty::Logger::LogstashFormatter do let(:severity) { :info } let(:http_method) { 'GET' } let(:path) { 'http://my.domain.com/my_path' } let(:logger_double) { double('Logger') } let(:request_double) { double('Request', http_method: Net::HTTP::Get, path: "#...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/support/ssl_test_server.rb
Ruby
mit
5,889
main
1,905
require 'openssl' require 'socket' require 'thread' # NOTE: This code is garbage. It probably has deadlocks, it might leak # threads, and otherwise cause problems in a real system. It's really only # intended for testing HTTParty. class SSLTestServer attr_accessor :ctx # SSLContext object attr_reader :port ...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/support/stub_response.rb
Ruby
mit
5,889
main
1,996
module HTTParty module StubResponse def stub_http_response_with(filename) format = filename.split('.').last.intern data = file_fixture(filename) response = Net::HTTPOK.new("1.1", 200, "Content for you") allow(response).to receive(:body).and_return(data) http_request = HTTParty::Req...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
spec/support/ssl_test_helper.rb
Ruby
mit
5,889
main
1,559
require 'pathname' module HTTParty module SSLTestHelper def ssl_verify_test(mode, ca_basename, server_cert_filename, options = {}, &block) options = { format: :json, timeout: 30 }.merge(options) if mode ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_base...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty.rb
Ruby
mit
5,889
main
22,872
# frozen_string_literal: true require 'pathname' require 'net/http' require 'uri' require 'httparty/module_inheritable_attributes' require 'httparty/cookie_hash' require 'httparty/net_digest_auth' require 'httparty/version' require 'httparty/connection_adapter' require 'httparty/logger/logger' require 'httparty/reque...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/module_inheritable_attributes.rb
Ruby
mit
5,889
main
1,510
# frozen_string_literal: true module HTTParty module ModuleInheritableAttributes #:nodoc: def self.included(base) base.extend(ClassMethods) end # borrowed from Rails 3.2 ActiveSupport def self.hash_deep_dup(hash) duplicate = hash.dup duplicate.each_pair do |key, value| if ...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/cookie_hash.rb
Ruby
mit
5,889
main
586
# frozen_string_literal: true class HTTParty::CookieHash < Hash #:nodoc: CLIENT_COOKIES = %w(path expires domain path secure httponly samesite) def add_cookies(data) case data when Hash merge!(data) when String data.split('; ').each do |cookie| key, value = cookie.split('=', 2) ...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/headers_processor.rb
Ruby
mit
5,889
main
853
# frozen_string_literal: true module HTTParty class HeadersProcessor attr_reader :headers, :options def initialize(headers, options) @headers = headers @options = options end def call return unless options[:headers] options[:headers] = headers.merge(options[:headers]) if he...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/exceptions.rb
Ruby
mit
5,889
main
2,168
# frozen_string_literal: true module HTTParty COMMON_NETWORK_ERRORS = [ EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::EINVAL, Errno::ENETUNREACH, Errno::ENOTSOCK, Errno::EPIPE, Errno::ETIMEDOUT, Net::HTTPBadResponse, ...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/request.rb
Ruby
mit
5,889
main
14,391
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/text_encoder.rb
Ruby
mit
5,889
main
1,721
# frozen_string_literal: true module HTTParty class TextEncoder attr_reader :text, :content_type, :assume_utf16_is_big_endian def initialize(text, assume_utf16_is_big_endian: true, content_type: nil) @text = +text @content_type = content_type @assume_utf16_is_big_endian = assume_utf16_is_b...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/hash_conversions.rb
Ruby
mit
5,889
main
2,185
# frozen_string_literal: true require 'erb' module HTTParty module HashConversions # @return <String> This hash as a query string # # @example # { name: "Bob", # address: { # street: '111 Ruby Ave.', # city: 'Ruby Central', # phones: ['111-111-1111', '222-222-...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/connection_adapter.rb
Ruby
mit
5,889
main
7,802
# frozen_string_literal: true module HTTParty # Default connection adapter that returns a new Net::HTTP each time # # == Custom Connection Factories # # If you like to implement your own connection adapter, subclassing # HTTParty::ConnectionAdapter will make it easier. Just override # the #connection met...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/response_fragment.rb
Ruby
mit
5,889
main
467
# frozen_string_literal: true require 'delegate' module HTTParty # Allow access to http_response and code by delegation on fragment class ResponseFragment < SimpleDelegator attr_reader :http_response, :connection def code @http_response.code.to_i end def initialize(fragment, http_response,...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/net_digest_auth.rb
Ruby
mit
5,889
main
3,254
# frozen_string_literal: true require 'digest/md5' require 'net/http' module Net module HTTPHeader def digest_auth(username, password, response) authenticator = DigestAuthenticator.new( username, password, @method, @path, response ) authenticator.author...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/decompressor.rb
Ruby
mit
5,889
main
2,609
# frozen_string_literal: true module HTTParty # Decompresses the response body based on the Content-Encoding header. # # Net::HTTP automatically decompresses Content-Encoding values "gzip" and "deflate". # This class will handle "br" (Brotli) and "compress" (LZW) if the requisite # gems are installed. Otherw...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/response.rb
Ruby
mit
5,889
main
4,444
# frozen_string_literal: true module HTTParty class Response < Object def self.underscore(string) string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2').downcase end def self._load(data) req, resp, parsed_resp, resp_body = Marshal.load(data) new(req, resp, -> { p...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/utils.rb
Ruby
mit
5,889
main
298
# frozen_string_literal: true module HTTParty module Utils def self.stringify_keys(hash) return hash.transform_keys(&:to_s) if hash.respond_to?(:transform_keys) hash.each_with_object({}) do |(key, value), new_hash| new_hash[key.to_s] = value end end end end
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/parser.rb
Ruby
mit
5,889
main
4,091
# frozen_string_literal: true module HTTParty # The default parser used by HTTParty, supports xml, json, html, csv and # plain text. # # == Custom Parsers # # If you'd like to do your own custom parsing, subclassing HTTParty::Parser # will make that process much easier. There are a few different ways you...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/response/headers.rb
Ruby
mit
5,889
main
819
# frozen_string_literal: true require 'delegate' module HTTParty class Response #:nodoc: class Headers < ::SimpleDelegator include ::Net::HTTPHeader def initialize(header_values = nil) @header = {} if header_values header_values.each_pair do |k,v| if v.is_a?(Ar...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/logger/logger.rb
Ruby
mit
5,889
main
826
# frozen_string_literal: true require 'httparty/logger/apache_formatter' require 'httparty/logger/curl_formatter' require 'httparty/logger/logstash_formatter' module HTTParty module Logger def self.formatters @formatters ||= { :curl => Logger::CurlFormatter, :apache => Logger::ApacheFormat...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/logger/curl_formatter.rb
Ruby
mit
5,889
main
2,190
# frozen_string_literal: true module HTTParty module Logger class CurlFormatter #:nodoc: TAG_NAME = HTTParty.name OUT = '>' IN = '<' attr_accessor :level, :logger def initialize(logger, level) @logger = logger @level = level.to_sym @messages...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/logger/logstash_formatter.rb
Ruby
mit
5,889
main
1,449
# frozen_string_literal: true module HTTParty module Logger class LogstashFormatter #:nodoc: TAG_NAME = HTTParty.name attr_accessor :level, :logger def initialize(logger, level) @logger = logger @level = level.to_sym end def format(request, response) @req...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/logger/apache_formatter.rb
Ruby
mit
5,889
main
995
# frozen_string_literal: true module HTTParty module Logger class ApacheFormatter #:nodoc: TAG_NAME = HTTParty.name attr_accessor :level, :logger def initialize(logger, level) @logger = logger @level = level.to_sym end def format(request, response) @reque...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/request/multipart_boundary.rb
Ruby
mit
5,889
main
236
# frozen_string_literal: true require 'securerandom' module HTTParty class Request class MultipartBoundary def self.generate "------------------------#{SecureRandom.urlsafe_base64(12)}" end end end end
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/request/streaming_multipart_body.rb
Ruby
mit
5,889
main
5,021
# frozen_string_literal: true module HTTParty class Request class StreamingMultipartBody NEWLINE = "\r\n" CHUNK_SIZE = 64 * 1024 # 64 KB chunks def initialize(parts, boundary) @parts = parts @boundary = boundary @part_index = 0 @state = :header @current_...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
lib/httparty/request/body.rb
Ruby
mit
5,889
main
3,682
# frozen_string_literal: true require_relative 'multipart_boundary' require_relative 'streaming_multipart_body' module HTTParty class Request class Body NEWLINE = "\r\n" private_constant :NEWLINE def initialize(params, query_string_normalizer: nil, force_multipart: false) @params = pa...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
features/steps/httparty_steps.rb
Ruby
mit
5,889
main
1,988
When /^I set my HTTParty timeout option to (\d+)$/ do |timeout| @request_options[:timeout] = timeout.to_i end When /^I set my HTTParty open_timeout option to (\d+)$/ do |timeout| @request_options[:open_timeout] = timeout.to_i end When /^I set my HTTParty read_timeout option to (\d+)$/ do |timeout| @request_opti...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
features/steps/mongrel_helper.rb
Ruby
mit
5,889
main
3,952
require 'base64' class BasicMongrelHandler < Mongrel::HttpHandler attr_accessor :content_type, :custom_headers, :response_body, :response_code, :preprocessor, :username, :password def initialize @content_type = "text/html" @response_body = "" @response_code = 200 @custom_headers = {} end def p...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
features/steps/httparty_response_steps.rb
Ruby
mit
5,889
main
1,874
# Not needed anymore in ruby 2.0, but needed to resolve constants # in nested namespaces. This is taken from rails :) def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_def...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
features/steps/env.rb
Ruby
mit
5,889
main
490
require 'mongrel' require './lib/httparty' require 'rspec/expectations' require 'aruba/cucumber' def run_server(port) @host_and_port = "0.0.0.0:#{port}" @server = Mongrel::HttpServer.new("0.0.0.0", port) @server.run @request_options = {} end def new_port server = TCPServer.new('0.0.0.0', nil) port = serve...
github
jnunemaker/httparty
https://github.com/jnunemaker/httparty
features/steps/remote_service_steps.rb
Ruby
mit
5,889
main
2,792
Given /a remote service that returns '(.*)'/ do |response_body| @handler = BasicMongrelHandler.new step "the response from the service has a body of '#{response_body}'" end Given /^a remote service that returns:$/ do |response_body| @handler = BasicMongrelHandler.new @handler.response_body = response_body end ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
Rakefile
Ruby
mit
5,853
main
3,404
require 'bundler' require 'rspec/core/rake_task' Bundler::GemHelper.install_tasks RSpec::Core::RakeTask.new(:spec) do |rspec| ENV['SPEC'] = 'spec/ransack/**/*_spec.rb' # With Rails 3, using `--backtrace` raises 'invalid option' when testing. # With Rails 4 and 5 it can be uncommented to see the backtrace: # ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
Gemfile
Ruby
mit
5,853
main
1,417
source 'https://rubygems.org' gemspec gem 'rake' rails = ENV['RAILS'] || '7-2-stable' rails_version = case rails when /\// # A path File.read(File.join(rails, "RAILS_VERSION")) when /^v/ # A tagged version rails.gsub(/^v/, '') else ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
ransack.gemspec
Ruby
mit
5,853
main
1,563
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "ransack/version" Gem::Specification.new do |s| s.name = "ransack" s.version = Ransack::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack", "Sean Carroll", "David Rodríg...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/console.rb
Ruby
mit
5,853
main
232
Bundler.setup require 'factory_bot' require 'faker' require 'ransack' Dir[File.expand_path('../../spec/{helpers,support,factories}/*.rb', __FILE__)] .each do |f| require f end Faker::Config.random = Random.new(0) Schema.create
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/spec_helper.rb
Ruby
mit
5,853
main
1,397
require 'ransack' require 'factory_bot' require 'faker' require 'action_controller' require 'ransack/helpers' require 'pry' require 'simplecov' require 'byebug' require 'rspec' SimpleCov.start I18n.enforce_available_locales = false Time.zone = 'Eastern Time (US & Canada)' I18n.load_path += Dir[File.join(File.dirname(_...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/translate_spec.rb
Ruby
mit
5,853
main
455
require 'spec_helper' module Ransack describe Translate do describe '.attribute' do it 'translate namespaced attribute like AR does' do ar_translation = ::Namespace::Article.human_attribute_name(:title) ransack_translation = Ransack::Translate.attribute( :title, context:...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/invalid_search_error_spec.rb
Ruby
mit
5,853
main
824
require 'spec_helper' module Ransack describe InvalidSearchError do it 'inherits from ArgumentError' do expect(InvalidSearchError.superclass).to eq(ArgumentError) end it 'can be instantiated with a message' do error = InvalidSearchError.new('Test error message') expect(error.message).t...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/ransacker_spec.rb
Ruby
mit
5,853
main
1,864
require 'spec_helper' module Ransack describe Ransacker do let(:klass) { Person } let(:name) { :test_ransacker } let(:opts) { {} } describe '#initialize' do context 'with minimal options' do subject { Ransacker.new(klass, name, opts) } it 'sets the name' do expect(su...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/configuration_spec.rb
Ruby
mit
5,853
main
6,654
require 'spec_helper' module Ransack describe Configuration do it 'yields Ransack on configure' do Ransack.configure { |config| expect(config).to eq Ransack } end it 'adds predicates' do Ransack.configure do |config| config.add_predicate :test_predicate end expect(Ransac...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/predicate_spec.rb
Ruby
mit
5,853
main
18,499
require 'spec_helper' module Ransack TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set describe Predicate do before do @s = Search.new(Person) end shared_examples 'wildcard escaping' do |method, regexp| it ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/search_spec.rb
Ruby
mit
5,853
main
34,318
require 'spec_helper' module Ransack describe Search do describe '#initialize' do it 'removes empty conditions before building' do expect_any_instance_of(Search).to receive(:build).with({}) Search.new(Person, name_eq: '') end it 'keeps conditions with a false value before build...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/helpers/form_builder_spec.rb
Ruby
mit
5,853
main
6,923
require 'spec_helper' module Ransack module Helpers describe FormBuilder do router = ActionDispatch::Routing::RouteSet.new router.draw do resources :people, :comments, :notes end include router.url_helpers # FIXME: figure out a cleaner way to get this behavior before...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/helpers/form_helper_spec.rb
Ruby
mit
5,853
main
36,227
require 'spec_helper' module Ransack module Helpers describe FormHelper do router = ActionDispatch::Routing::RouteSet.new router.draw do resources :people, :notes namespace :admin do resources :comments end end include router.url_helpers # FIXME: ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/nodes/condition_spec.rb
Ruby
mit
5,853
main
12,086
require 'spec_helper' module Ransack module Nodes describe Condition do context 'bug report #1245' do it 'preserves tuple behavior' do ransack_hash = { m: 'and', g: [ { title_type_in: ['["title 1", ""]'] } ] } ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/nodes/value_spec.rb
Ruby
mit
5,853
main
3,321
require 'spec_helper' module Ransack module Nodes describe Value do let(:context) { Context.for(Person) } subject do Value.new(context, raw_value) end context "with a date value" do let(:raw_value) { "2022-05-23" } [:date].each do |type| it "should cas...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/nodes/grouping_spec.rb
Ruby
mit
5,853
main
3,132
require 'spec_helper' module Ransack module Nodes describe Grouping do before do @g = 1 end let(:context) { Context.for(Person) } subject { described_class.new(context) } describe '#attribute_method?' do context 'for attributes of the context' do it 'is ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/adapters/active_record/base_spec.rb
Ruby
mit
5,853
main
36,319
require 'spec_helper' module Ransack module Adapters module ActiveRecord describe Base do subject { ::ActiveRecord::Base } it { should respond_to :ransack } describe '#search' do subject { Person.ransack } it { should be_a Search } it 'has a Relation...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/ransack/adapters/active_record/context_spec.rb
Ruby
mit
5,853
main
9,145
require 'spec_helper' module Ransack module Adapters module ActiveRecord version = ::ActiveRecord::VERSION AR_version = "#{version::MAJOR}.#{version::MINOR}" describe Context do subject { Context.new(Person) } it 'has an Active Record alias tracker method' do expect(...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/helpers/polyamorous_helper.rb
Ruby
mit
5,853
main
429
module PolyamorousHelper def new_join_association(reflection, children, klass) Polyamorous::JoinAssociation.new reflection, children, klass end def new_join_dependency(klass, associations = {}) Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin end def new_...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/helpers/ransack_helper.rb
Ruby
mit
5,853
main
218
module RansackHelper def quote_table_name(table) ActiveRecord::Base.connection.quote_table_name(table) end def quote_column_name(column) ActiveRecord::Base.connection.quote_column_name(column) end end
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/support/schema.rb
Ruby
mit
5,853
main
11,170
require 'active_record' require 'activerecord-postgis-adapter' case ENV['DB'].try(:downcase) when 'mysql', 'mysql2' # To test with MySQL: `DB=mysql bundle exec rake spec` ActiveRecord::Base.establish_connection( adapter: 'mysql2', database: 'ransack', username: ENV.fetch("MYSQL_USERNAME") { "root" }, ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/polyamorous/join_dependency_spec.rb
Ruby
mit
5,853
main
3,123
require 'spec_helper' module Polyamorous describe JoinDependency do context 'with symbol joins' do subject { new_join_dependency Person, articles: :comments } specify { expect(subject.send(:join_root).drop(1).size) .to eq(2) } specify { expect(subject.send(:join_root).drop(1).map(&:joi...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/polyamorous/activerecord_compatibility_spec.rb
Ruby
mit
5,853
main
407
require 'spec_helper' module Polyamorous describe "ActiveRecord Compatibility" do it 'works with self joins and includes' do trade_account = Account.create! Account.create!(trade_account: trade_account) accounts = Account.joins(:trade_account).includes(:trade_account, :agent_account) acc...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/polyamorous/join_association_spec.rb
Ruby
mit
5,853
main
1,063
require 'spec_helper' module Polyamorous describe JoinAssociation do let(:join_dependency) { new_join_dependency Note, {} } let(:reflection) { Note.reflect_on_association(:notable) } let(:parent) { join_dependency.send(:join_root) } let(:join_association) { new_join_association(reflection, pare...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/polyamorous/join_spec.rb
Ruby
mit
5,853
main
371
require 'spec_helper' module Polyamorous describe Join do it 'is a tree node' do join = new_join(:articles, :outer) expect(join).to be_kind_of(TreeNode) end it 'can be added to a tree' do join = new_join(:articles, :outer) tree_hash = {} join.add_to_tree(tree_hash) ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/factories/people.rb
Ruby
mit
5,853
main
341
FactoryBot.define do factory :person do name { Faker::Name.name } email { "test@example.com" } sequence(:salary) { |n| 30000 + (n * 1000) } only_sort { Faker::Lorem.words(number: 3).join(' ') } only_search { Faker::Lorem.words(number: 3).join(' ') } only_admin { Faker::Lorem.words(number: 3).j...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
spec/factories/notes.rb
Ruby
mit
5,853
main
271
FactoryBot.define do factory :note do note { Faker::Lorem.words(number: 7).join(' ') } trait :for_person do association :notable, factory: :person end trait :for_article do association :notable, factory: :article end end end
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack.rb
Ruby
mit
5,853
main
868
require 'active_support/dependencies/autoload' require 'active_support/deprecation' require 'active_support/deprecator' require 'active_support/core_ext' require 'ransack/configuration' require 'polyamorous/polyamorous' module Ransack extend Configuration class UntraversableAssociationError < StandardError; end e...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/swapping_reflection_class.rb
Ruby
mit
5,853
main
379
module Polyamorous module SwappingReflectionClass def swapping_reflection_klass(reflection, klass) new_reflection = reflection.clone new_reflection.instance_variable_set(:@options, reflection.options.clone) new_reflection.options.delete(:polymorphic) new_reflection.instance_variable_set(:@...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/join.rb
Ruby
mit
5,853
main
1,454
module Polyamorous class Join include TreeNode attr_accessor :name attr_reader :type, :klass def initialize(name, type = InnerJoin, klass = nil) @name = name @type = convert_to_arel_join_type(type) @klass = convert_to_class(klass) if klass end def klass=(klass) @klas...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/polyamorous.rb
Ruby
mit
5,853
main
1,137
ActiveSupport.on_load(:active_record) do module Polyamorous InnerJoin = Arel::Nodes::InnerJoin OuterJoin = Arel::Nodes::OuterJoin JoinDependency = ::ActiveRecord::Associations::JoinDependency JoinAssociation = ::ActiveRecord::Associations::JoinDependency::JoinAssociation end require 'polyamorou...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/activerecord/reflection.rb
Ruby
mit
5,853
main
274
module Polyamorous module ReflectionExtensions def join_scope(table, foreign_table, foreign_klass) if respond_to?(:polymorphic?) && polymorphic? super.where!(foreign_table[foreign_type].eq(klass.name)) else super end end end end
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/activerecord/join_association.rb
Ruby
mit
5,853
main
2,317
module Polyamorous module JoinAssociationExtensions include SwappingReflectionClass def self.prepended(base) base.class_eval { attr_reader :join_type } end def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin) @join_type = join_type if pol...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/activerecord/join_dependency.rb
Ruby
mit
5,853
main
3,083
module Polyamorous module JoinDependencyExtensions # Replaces ActiveRecord::Associations::JoinDependency#build def build(associations, base_klass) associations.map do |name, right| if name.is_a? Join reflection = find_reflection base_klass, name.name reflection.check_validity...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/polyamorous/activerecord/join_association_7_2.rb
Ruby
mit
5,853
main
1,865
module Polyamorous module JoinAssociationExtensions # Same as #join_constraints, but instead of constructing tables from the # given block, uses the ones passed def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables) joins = [] chain = [] reflect...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/visitor.rb
Ruby
mit
5,853
main
1,895
module Ransack class Visitor def accept(object) visit(object) end def can_accept?(object) respond_to? DISPATCH[object.class] end def visit_Array(object) object.map { |o| accept(o) }.compact end def visit_Ransack_Nodes_Condition(object) object.arel_predicate if o...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/configuration.rb
Ruby
mit
5,853
main
6,906
require 'ransack/constants' require 'ransack/predicate' module Ransack module Configuration mattr_accessor :predicates, :options class PredicateCollection attr_reader :sorted_names_with_underscores def initialize @collection = {} @sorted_names_with_underscores = [] end ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/search.rb
Ruby
mit
5,853
main
5,353
require 'ransack/nodes/bindable' require 'ransack/nodes/node' require 'ransack/nodes/attribute' require 'ransack/nodes/value' require 'ransack/nodes/condition' require 'ransack/nodes/sort' require 'ransack/nodes/grouping' require 'ransack/context' require 'ransack/naming' require 'ransack/invalid_search_error' module ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/active_record.rb
Ruby
mit
5,853
main
326
require 'ransack/adapters/active_record/base' ActiveSupport.on_load(:active_record) do extend Ransack::Adapters::ActiveRecord::Base Ransack::SUPPORTS_ATTRIBUTE_ALIAS = begin ActiveRecord::Base.respond_to?(:attribute_aliases) rescue NameError false end end require 'ransack/adapters/active_record/con...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/ransacker.rb
Ruby
mit
5,853
main
596
module Ransack class Ransacker attr_reader :name, :type, :formatter, :args delegate :call, to: :@callable def initialize(klass, name, opts = {}, &block) @klass, @name = klass, name @type = opts[:type] || :string @args = opts[:args] || [:parent] @formatter = opts[:formatter] ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/predicate.rb
Ruby
mit
5,853
main
1,719
module Ransack class Predicate attr_reader :name, :arel_predicate, :type, :formatter, :validator, :compound, :wants_array, :case_insensitive class << self def names Ransack.predicates.keys end def named(name) Ransack.predicates[(name || Ransack.options[:def...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/translate.rb
Ruby
mit
5,853
main
5,037
require 'i18n' I18n.load_path += Dir[ File.join(File.dirname(__FILE__), 'locale'.freeze, '*.yml'.freeze) ] module Ransack module Translate class << self def word(key, options = {}) I18n.translate(:"ransack.#{key}", default: key.to_s) end def predicate(key, options = {}) I18n...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/constants.rb
Ruby
mit
5,853
main
5,616
module Ransack module Constants OR = 'or'.freeze AND = 'and'.freeze CAP_SEARCH = 'Search'.freeze SEARCH = 'search'.freeze SEARCHES = 'searches'.freeze ATTRIBUTE = 'attribute'.freeze ATTRIBUTES = 'attribu...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/context.rb
Ruby
mit
5,853
main
5,733
require 'ransack/visitor' module Ransack class Context attr_reader :search, :object, :klass, :base, :engine, :arel_visitor attr_accessor :auth_object, :search_key attr_reader :arel_visitor class << self def for_class(klass, options = {}) if klass < ActiveRecord::Base Adapter...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/naming.rb
Ruby
mit
5,853
main
1,108
module Ransack module Naming def self.included(base) base.extend ClassMethods end def persisted? false end def to_key nil end def to_param nil end def to_model self end def model_name self.class.model_name end end class Nam...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/sort.rb
Ruby
mit
5,853
main
1,197
module Ransack module Nodes class Sort < Node include Bindable attr_reader :name, :dir, :ransacker_args i18n_word :asc, :desc class << self def extract(context, str) return if str.blank? attr, direction = str.split(/\s+/, 2) self.new(context).build(n...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/attribute.rb
Ruby
mit
5,853
main
1,351
module Ransack module Nodes class Attribute < Node include Bindable attr_reader :name, :ransacker_args delegate :blank?, :present?, to: :name delegate :engine, to: :context def initialize(context, name = nil, ransacker_args = []) super(context) self.name = name unl...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/node.rb
Ruby
mit
5,853
main
777
module Ransack module Nodes class Node attr_reader :context delegate :contextualize, to: :context class_attribute :i18n_words class_attribute :i18n_aliases self.i18n_words = [] self.i18n_aliases = {} class << self def i18n_word(*args) self.i18n_words +=...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/grouping.rb
Ruby
mit
5,853
main
5,473
module Ransack module Nodes class Grouping < Node attr_reader :conditions attr_accessor :combinator alias :m :combinator alias :m= :combinator= i18n_word :condition, :and, :or i18n_alias c: :condition, n: :and, o: :or delegate :each, to: :values def initialize(co...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/bindable.rb
Ruby
mit
5,853
main
1,036
module Ransack module Nodes module Bindable attr_accessor :parent, :attr_name def attr @attr ||= get_arel_attribute end alias :arel_attribute :attr def ransacker klass._ransackers[attr_name] end def klass @klass ||= context.klassify(parent) ...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/condition.rb
Ruby
mit
5,853
main
11,972
require 'ransack/invalid_search_error' module Ransack module Nodes class Condition < Node i18n_word :attribute, :predicate, :combinator, :value i18n_alias a: :attribute, p: :predicate, m: :combinator, v: :value attr_accessor :predicate class << self def extract(...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/nodes/value.rb
Ruby
mit
5,853
main
2,496
module Ransack module Nodes class Value < Node attr_accessor :value delegate :present?, :blank?, to: :value def initialize(context, value = nil) super(context) @value = value end def persisted? false end def eql?(other) self.class == oth...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/helpers/form_helper.rb
Ruby
mit
5,853
main
10,549
module Ransack module Helpers module FormHelper # +search_form_for+ # # <%= search_form_for(@q) do |f| %> # def search_form_for(record, options = {}, &proc) search = extract_search_and_set_url(record, options, 'search_form_for') options[:html] ||= {} html_o...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/helpers/form_builder.rb
Ruby
mit
5,853
main
8,630
require 'action_view' module ActionView::Helpers::Tags # TODO: Find a better way to solve this issue! # This patch is needed since this Rails commit: # https://github.com/rails/rails/commit/c1a118a class Base private def value if @allow_method_names_outside_object object.send @method_nam...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/adapters/active_record/context.rb
Ruby
mit
5,853
main
14,610
require 'ransack/context' require 'polyamorous/polyamorous' module Ransack module Adapters module ActiveRecord class Context < ::Ransack::Context def relation_for(object) object.all end def type_for(attr) return nil unless attr && attr.valid? relation...
github
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack
lib/ransack/adapters/active_record/base.rb
Ruby
mit
5,853
main
5,597
module Ransack module Adapters module ActiveRecord module Base def self.extended(base) base.class_eval do class_attribute :_ransackers class_attribute :_ransack_aliases self._ransackers ||= {} self._ransack_aliases ||= {} end ...
github
rack/rack-attack
https://github.com/rack/rack-attack
Rakefile
Ruby
mit
5,726
main
570
# frozen_string_literal: true require "rubygems" require "bundler/setup" require 'bundler/gem_tasks' require 'rake/testtask' require "rubocop/rake_task" RuboCop::RakeTask.new namespace :test do Rake::TestTask.new(:units) do |t| t.pattern = "spec/*_spec.rb" end Rake::TestTask.new(:integration) do |t| t...
github
rack/rack-attack
https://github.com/rack/rack-attack
Appraisals
Ruby
mit
5,726
main
1,201
# frozen_string_literal: true appraise "rack_3" do gem "rack", "~> 3.0" end appraise "rack_2" do gem "rack", "~> 2.0" end appraise "rails_8-1" do gem "railties", "~> 8.1.0" end appraise "rails_8-0" do gem "railties", "~> 8.0.0" end appraise "rails_7-2" do gem "railties", "~> 7.2.0" end appraise "rails_7...
github
rack/rack-attack
https://github.com/rack/rack-attack
rack-attack.gemspec
Ruby
mit
5,726
main
1,886
# frozen_string_literal: true require_relative 'lib/rack/attack/version' Gem::Specification.new do |s| s.name = 'rack-attack' s.version = Rack::Attack::VERSION s.license = 'MIT' s.authors = ["Aaron Suggs"] s.description = "A rack middleware for throttling and blocking abusive requests" s.email = "aaron@k...
github
rack/rack-attack
https://github.com/rack/rack-attack
examples/rack_attack.rb
Ruby
mit
5,726
main
1,129
# frozen_string_literal: true # NB: `req` is a Rack::Request object (basically an env hash with friendly accessor methods) # Throttle 10 requests/ip/second # NB: return value of block is key name for counter # falsy values bypass throttling Rack::Attack.throttle("req/ip", limit: 10, period: 1) { |req| req.ip } #...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/configuration_spec.rb
Ruby
mit
5,726
main
794
# frozen_string_literal: true require_relative "spec_helper" describe Rack::Attack::Configuration do subject { Rack::Attack::Configuration.new } describe 'attributes' do it 'exposes the safelists attribute' do _(subject.safelists).must_equal({}) end it 'exposes the blocklists attribute' do ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_track_spec.rb
Ruby
mit
5,726
main
1,385
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack.track' do let(:notifications) { [] } before do Rack::Attack.track("everything") { |_req| true } end it_allows_ok_requests it "should tag the env" do get '/' _(last_request.env['rack.attack.matched']).must_equ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_spec.rb
Ruby
mit
5,726
main
2,925
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack' do it_allows_ok_requests describe 'normalizing paths' do before do Rack::Attack.blocklist("banned_path") { |req| req.path == '/foo' } end it 'blocks requests with trailing slash' do if Rack::Attack::Path...