repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/renderers/slim.rb
middleman-core/lib/middleman-core/renderers/slim.rb
# Load gem require 'slim' module SafeTemplate def render(*) super.html_safe end end class ::Slim::Template include SafeTemplate def initialize(file, line, opts, &block) if opts.key?(:context) ::Slim::Embedded::SassEngine.disable_option_validator! %w(sass scss markdown).each do |engine| ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/dns_resolver/local_link_resolver.rb
middleman-core/lib/middleman-core/dns_resolver/local_link_resolver.rb
require 'middleman-core/dns_resolver/basic_network_resolver' module Middleman class DnsResolver # Use network name server to resolve ips and names class LocalLinkResolver < BasicNetworkResolver def initialize(opts={}) super @timeouts = opts.fetch(:timeouts, 1) @resolver = opts....
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/dns_resolver/basic_network_resolver.rb
middleman-core/lib/middleman-core/dns_resolver/basic_network_resolver.rb
module Middleman class DnsResolver # Use network name server to resolve ips and names class BasicNetworkResolver private attr_reader :resolver, :timeouts public def initialize(opts={}) @timeouts = opts.fetch(:timeouts, 2) end # Get names for ip # # @...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core/lib/middleman-core/dns_resolver/network_resolver.rb
require 'middleman-core/dns_resolver/basic_network_resolver' module Middleman class DnsResolver # Use network name server to resolve ips and names class NetworkResolver < BasicNetworkResolver def initialize(opts={}) super @resolver = opts.fetch(:resolver, Resolv::DNS.new(nameserver_con...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/dns_resolver/hosts_resolver.rb
middleman-core/lib/middleman-core/dns_resolver/hosts_resolver.rb
module Middleman class DnsResolver # Use network name server to resolve ips and names class HostsResolver private attr_reader :resolver public def initialize(opts={}) # using the splat operator works around a non-existing HOSTSRC variable # using nil as input does no...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/resource.rb
middleman-core/lib/middleman-core/sitemap/resource.rb
require 'rack/mime' require 'middleman-core/sitemap/extensions/traversal' require 'middleman-core/file_renderer' require 'middleman-core/template_renderer' require 'middleman-core/contracts' module Middleman # Sitemap namespace module Sitemap # Sitemap Resource class class Resource include Contracts ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/store.rb
middleman-core/lib/middleman-core/sitemap/store.rb
# Used for merging results of metadata callbacks require 'active_support/core_ext/hash/deep_merge' require 'monitor' require 'hamster' require 'middleman-core/extensions' # Files on Disk ::Middleman::Extensions.register :sitemap_ondisk, auto_activate: :before_configuration do require 'middleman-core/sitemap/extensi...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb
middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb
require 'middleman-core/sitemap/resource' require 'middleman-core/contracts' module Middleman module Sitemap module Extensions # Manages the list of proxy configurations and manipulates the sitemap # to include new resources based on those configurations class Redirects < ConfigExtension ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb
middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb
require 'middleman-core/sitemap/resource' require 'middleman-core/core_extensions/collections/step_context' module Middleman module Sitemap module Extensions # Manages the list of proxy configurations and manipulates the sitemap # to include new resources based on those configurations class Pro...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/on_disk.rb
middleman-core/lib/middleman-core/sitemap/extensions/on_disk.rb
require 'set' require 'middleman-core/contracts' module Middleman module Sitemap module Extensions class OnDisk < Extension self.resource_list_manipulator_priority = 0 def initialize(app, config={}, &block) super @file_paths_on_disk = Set.new @waiting_for_rea...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/move_file.rb
middleman-core/lib/middleman-core/sitemap/extensions/move_file.rb
require 'middleman-core/sitemap/resource' require 'middleman-core/core_extensions/collections/step_context' module Middleman module Sitemap module Extensions # Manages the list of proxy configurations and manipulates the sitemap # to include new resources based on those configurations class Mov...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb
middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb
require 'middleman-core/sitemap/resource' module Middleman module Sitemap module Extensions class RequestEndpoints < ConfigExtension self.resource_list_manipulator_priority = 0 # Expose `endpoint` expose_to_config :endpoint EndpointDescriptor = Struct.new(:path, :request_p...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/import.rb
middleman-core/lib/middleman-core/sitemap/extensions/import.rb
require 'set' require 'middleman-core/contracts' module Middleman module Sitemap module Extensions class Import < ConfigExtension self.resource_list_manipulator_priority = 1 # Expose methods expose_to_config :import_file, :import_path ImportFileDescriptor = Struct.new(:fro...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/ignores.rb
middleman-core/lib/middleman-core/sitemap/extensions/ignores.rb
module Middleman module Sitemap module Extensions # Class to handle managing ignores class Ignores < ConfigExtension self.resource_list_manipulator_priority = 0 expose_to_application :ignore expose_to_config :ignore # Ignore a path or add an ignore callback # ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb
middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb
module Middleman module Sitemap module Extensions module Traversal def traversal_root root = if !@app.extensions[:i18n] '/' else @app.extensions[:i18n].path_root(::I18n.locale) end root.sub(/^\//, '') end # This resour...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/server_ip_address.rb
middleman-core/lib/middleman-core/preview_server/server_ip_address.rb
require 'ipaddr' require 'forwardable' module Middleman class PreviewServer class ServerIpAddress def self.new(ip_address) @parser = [] @parser << ServerIpv6Address @parser << ServerIpv4Address @parser.find { |p| p.match? ip_address }.new(ip_address) end end ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/information.rb
middleman-core/lib/middleman-core/preview_server/information.rb
require 'ipaddr' require 'active_support/core_ext/object/blank' require 'middleman-core/preview_server/checks' require 'middleman-core/preview_server/server_hostname' require 'middleman-core/preview_server/server_ip_address' module Middleman class PreviewServer # Basic information class to wrap common behaviour ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/server_information_callback_proxy.rb
middleman-core/lib/middleman-core/preview_server/server_information_callback_proxy.rb
module Middleman class PreviewServer # This class wraps server information to be used in call back # # * listeners # * port # * server name # * site_addresses # # All information is "dupped" and the callback is not meant to be used to # modify these information. class ServerInf...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/tcp_port_prober.rb
middleman-core/lib/middleman-core/preview_server/tcp_port_prober.rb
module Middleman class PreviewServer # Probe for tcp ports # # This one first tries `try_port` if this is not available use the free # port returned by TCPServer. class TcpPortProber # Check for port # # @param [Integer] try_port # The port to be checked # # @...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/server_information.rb
middleman-core/lib/middleman-core/preview_server/server_information.rb
require 'middleman-core/dns_resolver' require 'middleman-core/preview_server/information' require 'middleman-core/preview_server/network_interface_inventory' require 'middleman-core/preview_server/tcp_port_prober' require 'middleman-core/preview_server/server_information_validator' module Middleman class PreviewServ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/network_interface_inventory.rb
middleman-core/lib/middleman-core/preview_server/network_interface_inventory.rb
require 'middleman-core/preview_server/server_ip_address' module Middleman class PreviewServer # This holds information about local network interfaces on the user systemd class NetworkInterfaceInventory # Return all ip interfaces class All def network_interfaces ipv4_addresses =...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/server_hostname.rb
middleman-core/lib/middleman-core/preview_server/server_hostname.rb
module Middleman class PreviewServer class ServerHostname class ServerFullHostname < SimpleDelegator def to_s __getobj__.gsub(/\s/, '+') end def self.match?(*) true end alias to_browser to_s end class ServerPlainHostname < SimpleDele...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/server_information_validator.rb
middleman-core/lib/middleman-core/preview_server/server_information_validator.rb
module Middleman class PreviewServer # Validate user input class ServerInformationValidator # Validate the input # # @param [ServerInformation] information # The information instance which holds information about the preview # server settings # # @param [Array] ch...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/server_url.rb
middleman-core/lib/middleman-core/preview_server/server_url.rb
require 'ipaddr' module Middleman class PreviewServer # This builds the server urls for the preview server class ServerUrl private attr_reader :hosts, :port, :https, :format_output public def initialize(opts={}) @hosts = opts.fetch(:hosts) @port = opts.fetch(:port)...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/preview_server/checks.rb
middleman-core/lib/middleman-core/preview_server/checks.rb
require 'ipaddr' module Middleman class PreviewServer # Checks for input of preview server module Checks # This one will get all default setup class BasicCheck; end # This checks if the server name resolves to the bind_address # # If the users enters: # # 1. server_...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/step_definitions/middleman_steps.rb
middleman-core/lib/middleman-core/step_definitions/middleman_steps.rb
require 'fileutils' Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name| target = File.join(PROJECT_ROOT_PATH, 'fixtures', path) config_path = File.join(expand_path("."), "config-#{config_name}.rb") config_dest = File.join(expand_path("."), 'config.rb') FileUtils.cp(config_path, config_de...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb
middleman-core/lib/middleman-core/step_definitions/server_steps.rb
require 'middleman-core/rack' require 'rspec/expectations' require 'capybara/cucumber' require 'addressable/uri' Given /^a clean server$/ do @initialize_commands = [] @activation_commands = [] end Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state| @activation_commands ||= [] if state == 'enabled'...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/step_definitions/commandline_steps.rb
middleman-core/lib/middleman-core/step_definitions/commandline_steps.rb
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected| begin Timeout.timeout(aruba.config.exit_timeout) do loop do fail "You need to start middleman interactively first." unless last_command_started if unescape_text(last_command...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/step_definitions/builder_steps.rb
middleman-core/lib/middleman-core/step_definitions/builder_steps.rb
require 'fileutils' Before do @modification_times = Hash.new end Given /^a built app at "([^\"]*)"$/ do |path| step %Q{a fixture app "#{path}"} step %Q{I run `middleman build --verbose`} end Given /^was successfully built$/ do step %Q{the output should contain "Project built successfully."} step %Q{the exi...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/meta_pages/sitemap_tree.rb
middleman-core/lib/middleman-core/meta_pages/sitemap_tree.rb
require 'middleman-core/meta_pages/sitemap_resource' module Middleman module MetaPages # View class for a sitemap tree class SitemapTree def initialize @children = {} end def add_resource(resource) add_path(resource.path.split('/'), resource) end def render ...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/meta_pages/config_setting.rb
middleman-core/lib/middleman-core/meta_pages/config_setting.rb
require 'pp' module Middleman module MetaPages # View class for a config entry class ConfigSetting include Padrino::Helpers::OutputHelpers include Padrino::Helpers::TagHelpers def initialize(setting) @setting = setting end def render content = '' key_cl...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
middleman/middleman
https://github.com/middleman/middleman/blob/b497703afb715044bc5cfcd5616bd3825323505b/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb
middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb
require 'padrino-helpers' require 'padrino-helpers/output_helpers' require 'padrino-helpers/tag_helpers' module Middleman module MetaPages # View class for a sitemap resource class SitemapResource include Padrino::Helpers::OutputHelpers include Padrino::Helpers::TagHelpers def initialize(r...
ruby
MIT
b497703afb715044bc5cfcd5616bd3825323505b
2026-01-04T15:39:40.166212Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/init.rb
init.rb
# frozen_string_literal: true require 'cancan'
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/matchers.rb
spec/matchers.rb
# frozen_string_literal: true RSpec::Matchers.define :orderlessly_match do |original_string| match do |given_string| original_string.split('').sort == given_string.split('').sort end failure_message do |given_string| "expected \"#{given_string}\" to have the same characters as \"#{original_string}\"" ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/changelog_spec.rb
spec/changelog_spec.rb
# frozen_string_literal: true # credits to https://github.com/rubocop-hq/rubocop for this CHANGELOG checker RSpec.describe 'changelog' do subject(:changelog) do path = File.join(File.dirname(__FILE__), '..', 'CHANGELOG.md') File.read(path) end it 'has newline at end of file' do expect(changelog.end_...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/spec_helper.rb
spec/spec_helper.rb
# frozen_string_literal: true require 'rubygems' require 'bundler/setup' Bundler.require require 'matchers' require 'cancan/matchers' # I8n setting to fix deprecation. I18n.enforce_available_locales = false if defined?(I18n) && I18n.respond_to?('enforce_available_locales=') # Add support to load paths $LOAD_PATH.u...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/support/ability.rb
spec/support/ability.rb
# frozen_string_literal: true class Ability include CanCan::Ability def initialize(user) end end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/support/sql_helpers.rb
spec/support/sql_helpers.rb
# frozen_string_literal: true module SQLHelpers def normalized_sql(adapter) adapter.database_records.to_sql.strip.squeeze(' ') end def sqlite? ENV['DB'] == 'sqlite' end def postgres? ENV['DB'] == 'postgres' end def connect_db # ActiveRecord::Base.logger = Logger.new(STDOUT) ActiveR...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/rule_spec.rb
spec/cancan/rule_spec.rb
# frozen_string_literal: true require 'spec_helper' require 'ostruct' # for OpenStruct below # Most of Rule functionality is tested in Ability specs RSpec.describe CanCan::Rule do before(:each) do @conditions = {} @rule = CanCan::Rule.new(true, :read, Integer, @conditions) end it 'returns no associatio...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/controller_resource_spec.rb
spec/cancan/controller_resource_spec.rb
# frozen_string_literal: true require 'spec_helper' describe CanCan::ControllerResource do let(:ability) { Ability.new(nil) } let(:params) { HashWithIndifferentAccess.new(controller: 'models') } let(:controller_class) { Class.new } let(:controller) { controller_class.new } before(:each) do class Model ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/exceptions_spec.rb
spec/cancan/exceptions_spec.rb
# frozen_string_literal: true require 'spec_helper' describe CanCan::AccessDenied do describe 'with action, subject, and conditions' do before(:each) do @exception = CanCan::AccessDenied.new(nil, :some_action, :some_subject, :some_conditions) end it 'has action, subject, and conditions accessors'...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/controller_additions_spec.rb
spec/cancan/controller_additions_spec.rb
# frozen_string_literal: true require 'spec_helper' describe CanCan::ControllerAdditions do before(:each) do @controller_class = Class.new @controller = @controller_class.new allow(@controller).to receive(:params) { {} } allow(@controller).to receive(:current_user) { :current_user } expect(@cont...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/ability_spec.rb
spec/cancan/ability_spec.rb
# frozen_string_literal: true require 'spec_helper' describe CanCan::Ability do before(:each) do (@ability = double).extend(CanCan::Ability) connect_db ActiveRecord::Migration.verbose = false ActiveRecord::Schema.define do create_table(:named_users) do |t| t.string :first_name ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/rule_compressor_spec.rb
spec/cancan/rule_compressor_spec.rb
# frozen_string_literal: true require 'spec_helper' describe CanCan::RulesCompressor do before do class Blog end end def can(action, subject, args = nil) CanCan::Rule.new(true, action, subject, args, nil) end def cannot(action, subject, args = nil) CanCan::Rule.new(false, action, subject, ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/matchers_spec.rb
spec/cancan/matchers_spec.rb
# frozen_string_literal: true require 'spec_helper' describe 'be_able_to' do subject { double } context 'check single ability' do it 'delegates to can?' do is_expected.to receive(:can?).with(:read, 123) { true } is_expected.to be_able_to(:read, 123) end it 'reports a nice failure message...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/accessible_by_has_many_through_spec.rb
spec/cancan/model_adapters/accessible_by_has_many_through_spec.rb
require 'spec_helper' # integration tests for latest ActiveRecord version. RSpec.describe CanCan::ModelAdapters::ActiveRecord5Adapter do let(:ability) { double.extend(CanCan::Ability) } let(:users_table) { Post.table_name } let(:posts_table) { Post.table_name } let(:likes_table) { Like.table_name } before :e...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/conditions_extractor_spec.rb
spec/cancan/model_adapters/conditions_extractor_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe CanCan::ModelAdapters::ConditionsExtractor do before do connect_db ActiveRecord::Migration.verbose = false ActiveRecord::Schema.define do create_table(:categories) do |t| t.string :name t.boolean :visible t....
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/active_record_adapter_spec.rb
spec/cancan/model_adapters/active_record_adapter_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe CanCan::ModelAdapters::ActiveRecordAdapter do let(:true_v) do ActiveRecord::Base.connection.quoted_true end let(:false_v) do ActiveRecord::Base.connection.quoted_false end let(:false_condition) { "#{true_v}=#{false_v}" } before :...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
true
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/active_record_5_adapter_spec.rb
spec/cancan/model_adapters/active_record_5_adapter_spec.rb
# frozen_string_literal: true require 'spec_helper' if CanCan::ModelAdapters::ActiveRecordAdapter.version_greater_or_equal?('5.0.0') describe CanCan::ModelAdapters::ActiveRecord5Adapter do CanCan.valid_accessible_by_strategies.each do |strategy| context "with sqlite3 and #{strategy} strategy" do b...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/has_and_belongs_to_many_spec.rb
spec/cancan/model_adapters/has_and_belongs_to_many_spec.rb
require 'spec_helper' RSpec.describe CanCan::ModelAdapters::ActiveRecord5Adapter do let(:ability) { double.extend(CanCan::Ability) } let(:users_table) { User.table_name } let(:posts_table) { Post.table_name } before :all do connect_db ActiveRecord::Migration.verbose = false ActiveRecord::Schema.d...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/accessible_by_integration_spec.rb
spec/cancan/model_adapters/accessible_by_integration_spec.rb
# frozen_string_literal: true require 'spec_helper' # integration tests for latest ActiveRecord version. RSpec.describe CanCan::ModelAdapters::ActiveRecord5Adapter do let(:ability) { double.extend(CanCan::Ability) } let(:users_table) { Post.table_name } let(:posts_table) { Post.table_name } let(:likes_table) ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/conditions_normalizer_spec.rb
spec/cancan/model_adapters/conditions_normalizer_spec.rb
require 'spec_helper' RSpec.describe CanCan::ModelAdapters::ConditionsNormalizer do before do connect_db ActiveRecord::Migration.verbose = false ActiveRecord::Schema.define do create_table(:articles) do |t| end create_table(:users) do |t| t.string :name end create_...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/active_record_4_adapter_spec.rb
spec/cancan/model_adapters/active_record_4_adapter_spec.rb
# frozen_string_literal: true require 'spec_helper' if CanCan::ModelAdapters::ActiveRecordAdapter.version_lower?('5.0.0') describe CanCan::ModelAdapters::ActiveRecord4Adapter do # only the `left_join` strategy works in AR4 CanCan.valid_accessible_by_strategies.each do |strategy| context "with sqlite3 ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/spec/cancan/model_adapters/default_adapter_spec.rb
spec/cancan/model_adapters/default_adapter_spec.rb
# frozen_string_literal: true require 'spec_helper' describe CanCan::ModelAdapters::DefaultAdapter do it 'is default for generic classes' do expect(CanCan::ModelAdapters::AbstractAdapter.adapter_class(Object)).to eq(CanCan::ModelAdapters::DefaultAdapter) end end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan.rb
lib/cancan.rb
# frozen_string_literal: true require 'cancan/version' require 'cancan/config' require 'cancan/parameter_validators' require 'cancan/ability' require 'cancan/rule' require 'cancan/controller_resource' require 'cancan/controller_additions' require 'cancan/model_additions' require 'cancan/exceptions' require 'cancan/mo...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancancan.rb
lib/cancancan.rb
# frozen_string_literal: true require 'cancan' module CanCanCan end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/version.rb
lib/cancan/version.rb
# frozen_string_literal: true module CanCan VERSION = '3.6.0'.freeze end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/matchers.rb
lib/cancan/matchers.rb
# frozen_string_literal: true rspec_module = defined?(RSpec::Core) ? 'RSpec' : 'Spec' # RSpec 1 compatability if rspec_module == 'RSpec' require 'rspec/core' require 'rspec/expectations' else ActiveSupport::Deprecation.warn('RSpec < 3 will not be supported in the CanCanCan >= 2.0.0') end Kernel.const_get(rspec...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_additions.rb
lib/cancan/model_additions.rb
# frozen_string_literal: true module CanCan # This module adds the accessible_by class method to a model. It is included in the model adapters. module ModelAdditions module ClassMethods # Returns a scope which fetches only the records that the passed ability # can perform a given action on. The act...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/exceptions.rb
lib/cancan/exceptions.rb
# frozen_string_literal: true module CanCan # A general CanCan exception class Error < StandardError; end # Raised when behavior is not implemented, usually used in an abstract class. class NotImplemented < Error; end # Raised when removed code is called, an alternative solution is provided in message. c...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/ability.rb
lib/cancan/ability.rb
# frozen_string_literal: true require_relative 'ability/rules.rb' require_relative 'ability/actions.rb' require_relative 'unauthorized_message_resolver.rb' require_relative 'ability/strong_parameter_support' module CanCan # This module is designed to be included into an Ability class. This will # provide the "can...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_resource_name_finder.rb
lib/cancan/controller_resource_name_finder.rb
# frozen_string_literal: true module CanCan module ControllerResourceNameFinder protected def name_from_controller @params[:controller].split('/').last.singularize end def namespaced_name [namespace, name].join('/').singularize.camelize.safe_constantize || name end def name ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/sti_detector.rb
lib/cancan/sti_detector.rb
# frozen_string_literal: true class StiDetector def self.sti_class?(subject) return false unless defined?(ActiveRecord::Base) return false unless subject.respond_to?(:descends_from_active_record?) return false if subject == :all || subject.descends_from_active_record? return false unless subject < Ac...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_resource_loader.rb
lib/cancan/controller_resource_loader.rb
# frozen_string_literal: true require_relative 'controller_resource_finder.rb' require_relative 'controller_resource_name_finder.rb' require_relative 'controller_resource_builder.rb' require_relative 'controller_resource_sanitizer.rb' module CanCan module ControllerResourceLoader include CanCan::ControllerResour...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_resource_sanitizer.rb
lib/cancan/controller_resource_sanitizer.rb
# frozen_string_literal: true module CanCan module ControllerResourceSanitizer protected def sanitize_parameters case params_method when Symbol @controller.send(params_method) when String @controller.instance_eval(params_method) when Proc params_method.call(@c...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_resource_builder.rb
lib/cancan/controller_resource_builder.rb
# frozen_string_literal: true module CanCan module ControllerResourceBuilder protected def build_resource resource = resource_base.new(resource_params || {}) assign_attributes(resource) end def assign_attributes(resource) resource.send("#{parent_name}=", parent_resource) if @optio...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/relevant.rb
lib/cancan/relevant.rb
# frozen_string_literal: true module CanCan module Relevant # Matches both the action, subject, and attribute, not necessarily the conditions def relevant?(action, subject) subject = subject.values.first if subject.class == Hash @match_all || (matches_action?(action) && matches_subject?(subject))...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/class_matcher.rb
lib/cancan/class_matcher.rb
require_relative 'sti_detector' # This class is responsible for matching classes and their subclasses as well as # upmatching classes to their ancestors. # This is used to generate sti connections class SubjectClassMatcher def self.matches_subject_class?(subjects, subject) subjects.any? do |sub| has_subcla...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/parameter_validators.rb
lib/cancan/parameter_validators.rb
# frozen_string_literal: true module CanCan module ParameterValidators def valid_attribute_param?(attribute) attribute.nil? || attribute.is_a?(Symbol) || (attribute.is_a?(Array) && attribute.all? { |a| a.is_a?(Symbol) }) end end end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_resource.rb
lib/cancan/controller_resource.rb
# frozen_string_literal: true require_relative 'controller_resource_loader.rb' module CanCan # Handle the load and authorization controller logic # so we don't clutter up all controllers with non-interface methods. # This class is used internally, so you do not need to call methods directly on it. class Contro...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/rule.rb
lib/cancan/rule.rb
# frozen_string_literal: true require_relative 'conditions_matcher.rb' require_relative 'class_matcher.rb' require_relative 'relevant.rb' module CanCan # This class is used internally and should only be called through Ability. # it holds the information about a "can" call made on Ability and provides # helpful ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/config.rb
lib/cancan/config.rb
# frozen_string_literal: true module CanCan def self.valid_accessible_by_strategies strategies = [:left_join] unless does_not_support_subquery_strategy? strategies.push(:joined_alias_exists_subquery, :joined_alias_each_rule_as_exists_subquery, :subquery) end strategies end # You can disa...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_additions.rb
lib/cancan/controller_additions.rb
# frozen_string_literal: true module CanCan # This module is automatically included into all controllers. # It also makes the "can?" and "cannot?" methods available to all views. module ControllerAdditions module ClassMethods # Sets up a before filter which loads and authorizes the current resource. Th...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/controller_resource_finder.rb
lib/cancan/controller_resource_finder.rb
# frozen_string_literal: true module CanCan module ControllerResourceFinder protected def find_resource if @options[:singleton] && parent_resource.respond_to?(name) parent_resource.send(name) elsif @options[:find_by] find_resource_using_find_by else adapter.find(res...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/rules_compressor.rb
lib/cancan/rules_compressor.rb
# frozen_string_literal: true require_relative 'conditions_matcher.rb' module CanCan class RulesCompressor attr_reader :initial_rules, :rules_collapsed def initialize(rules) @initial_rules = rules @rules_collapsed = compress(@initial_rules) end def compress(array) array = simplify...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/unauthorized_message_resolver.rb
lib/cancan/unauthorized_message_resolver.rb
# frozen_string_literal: true module CanCan module UnauthorizedMessageResolver def unauthorized_message(action, subject) subject = subject.values.last if subject.is_a?(Hash) keys = unauthorized_message_keys(action, subject) variables = {} variables[:action] = I18n.translate("actions.#{act...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/conditions_matcher.rb
lib/cancan/conditions_matcher.rb
# frozen_string_literal: true module CanCan module ConditionsMatcher # Matches the block or conditions hash def matches_conditions?(action, subject, attribute = nil, *extra_args) return call_block_with_all(action, subject, extra_args) if @match_all return matches_block_conditions(subject, attribu...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/ability/actions.rb
lib/cancan/ability/actions.rb
# frozen_string_literal: true module CanCan module Ability module Actions # Alias one or more actions into another one. # # alias_action :update, :destroy, :to => :modify # can :modify, Comment # # Then :modify permission will apply to both :update and :destroy requests. ...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/ability/strong_parameter_support.rb
lib/cancan/ability/strong_parameter_support.rb
# frozen_string_literal: true module CanCan module Ability module StrongParameterSupport # Returns an array of attributes suitable for use with strong parameters # # Note: reversing the relevant rules is important. Normal order means that 'cannot' # rules will come before 'can' rules. How...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/ability/rules.rb
lib/cancan/ability/rules.rb
# frozen_string_literal: true module CanCan module Ability module Rules protected # Must be protected as an ability can merge with other abilities. # This means that an ability must expose their rules with another ability. def rules @rules ||= [] end private d...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/default_adapter.rb
lib/cancan/model_adapters/default_adapter.rb
# frozen_string_literal: true module CanCan module ModelAdapters class DefaultAdapter < AbstractAdapter # This adapter is used when no matching adapter is found end end end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/sti_normalizer.rb
lib/cancan/model_adapters/sti_normalizer.rb
require_relative '../sti_detector' # this class is responsible for detecting sti classes and creating new rules for the # relevant subclasses, using the inheritance_column as a merger module CanCan module ModelAdapters class StiNormalizer class << self def normalize(rules) rules_cache = [...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/conditions_extractor.rb
lib/cancan/model_adapters/conditions_extractor.rb
# frozen_string_literal: true # this class is responsible of converting the hash of conditions # in "where conditions" to generate the sql query # it consists of a names_cache that helps calculating the next name given to the association # it tries to reflect the behavior of ActiveRecord when generating aliases for ta...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/active_record_adapter.rb
lib/cancan/model_adapters/active_record_adapter.rb
# frozen_string_literal: true # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity module CanCan module ModelAdapters class ActiveRecordAdapter < AbstractAdapter def self.version_greater_or_equal?(version) Gem::Version.new(Ac...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/conditions_normalizer.rb
lib/cancan/model_adapters/conditions_normalizer.rb
# this class is responsible of normalizing the hash of conditions # by exploding has_many through associations # when a condition is defined with an has_many through association this is exploded in all its parts # TODO: it could identify STI and normalize it module CanCan module ModelAdapters class ConditionsNorm...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/active_record_4_adapter.rb
lib/cancan/model_adapters/active_record_4_adapter.rb
# frozen_string_literal: true module CanCan module ModelAdapters class ActiveRecord4Adapter < ActiveRecordAdapter AbstractAdapter.inherited(self) class << self def for_class?(model_class) version_lower?('5.0.0') && model_class <= ActiveRecord::Base end def override...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/active_record_5_adapter.rb
lib/cancan/model_adapters/active_record_5_adapter.rb
# frozen_string_literal: true module CanCan module ModelAdapters class ActiveRecord5Adapter < ActiveRecord4Adapter AbstractAdapter.inherited(self) def self.for_class?(model_class) version_greater_or_equal?('5.0.0') && model_class <= ActiveRecord::Base end # rails 5 is capable of...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/abstract_adapter.rb
lib/cancan/model_adapters/abstract_adapter.rb
# frozen_string_literal: true module CanCan module ModelAdapters class AbstractAdapter attr_reader :model_class def self.inherited(subclass) @subclasses ||= [] @subclasses.insert(0, subclass) end def self.adapter_class(model_class) @subclasses.detect { |subclass|...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/strategies/joined_alias_each_rule_as_exists_subquery.rb
lib/cancan/model_adapters/strategies/joined_alias_each_rule_as_exists_subquery.rb
# frozen_string_literal: false module CanCan module ModelAdapters class Strategies class JoinedAliasEachRuleAsExistsSubquery < Base def execute! model_class .joins( "JOIN #{quoted_table_name} AS #{quoted_aliased_table_name} ON " \ "#{quoted_aliased_...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/strategies/left_join.rb
lib/cancan/model_adapters/strategies/left_join.rb
module CanCan module ModelAdapters class Strategies class LeftJoin < Base def execute! relation.left_joins(joins).distinct end end end end end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/strategies/base.rb
lib/cancan/model_adapters/strategies/base.rb
module CanCan module ModelAdapters class Strategies class Base attr_reader :adapter, :relation, :where_conditions delegate( :compressed_rules, :extract_multiple_conditions, :joins, :model_class, :quoted_primary_key, :quoted_aliased...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/strategies/subquery.rb
lib/cancan/model_adapters/strategies/subquery.rb
module CanCan module ModelAdapters class Strategies class Subquery < Base def execute! build_joins_relation_subquery(where_conditions) end def build_joins_relation_subquery(where_conditions) inner = model_class.unscoped do model_class.left_joins(joins...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/cancan/model_adapters/strategies/joined_alias_exists_subquery.rb
lib/cancan/model_adapters/strategies/joined_alias_exists_subquery.rb
# frozen_string_literal: true module CanCan module ModelAdapters class Strategies class JoinedAliasExistsSubquery < Base def execute! model_class .joins( "JOIN #{quoted_table_name} AS #{quoted_aliased_table_name} ON " \ "#{quoted_aliased_table_name}...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/generators/cancan/ability/ability_generator.rb
lib/generators/cancan/ability/ability_generator.rb
# frozen_string_literal: true module Cancan module Generators class AbilityGenerator < Rails::Generators::Base source_root File.expand_path('templates', __dir__) def generate_ability copy_file 'ability.rb', 'app/models/ability.rb' end end end end
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan/blob/1100093bd2d3416bb875e1cb407a81ec35a6dab5/lib/generators/cancan/ability/templates/ability.rb
lib/generators/cancan/ability/templates/ability.rb
# frozen_string_literal: true class Ability include CanCan::Ability def initialize(user) # Define abilities for the user here. For example: # # return unless user.present? # can :read, :all # return unless user.admin? # can :manage, :all # # The first argument to `can` is t...
ruby
MIT
1100093bd2d3416bb875e1cb407a81ec35a6dab5
2026-01-04T15:42:48.048224Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/init.rb
init.rb
require 'will_paginate' # This is all duplication of what Railtie does, but is necessary because # the initializer defined by the Railtie won't ever run when loaded as plugin. if defined? ActiveRecord::Base require 'will_paginate/active_record' end if defined? ActionController::Base WillPaginate::Railtie.setup_a...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/console_fixtures.rb
spec/console_fixtures.rb
require 'bundler' Bundler.setup require 'will_paginate/active_record' require 'finders/activerecord_test_connector' ActiverecordTestConnector.setup windows = RUBY_PLATFORM =~ /(:?mswin|mingw)/ # used just for the `color` method log_subscriber = ActiveSupport::LogSubscriber.log_subscribers.first IGNORE_SQL = /\b(sql...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/page_number_spec.rb
spec/page_number_spec.rb
require 'spec_helper' require 'will_paginate/page_number' require 'json' RSpec.describe WillPaginate::PageNumber do describe "valid" do def num WillPaginate::PageNumber.new('12', 'page') end it "== 12" do expect(num).to eq(12) end it "inspects to 'page 12'" do expect(num.inspe...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/per_page_spec.rb
spec/per_page_spec.rb
require 'spec_helper' require 'will_paginate/per_page' RSpec.describe WillPaginate::PerPage do class MyModel extend WillPaginate::PerPage end it "has the default value" do expect(MyModel.per_page).to eq(30) WillPaginate.per_page = 10 begin expect(MyModel.per_page).to eq(10) ensure ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/collection_spec.rb
spec/collection_spec.rb
require 'will_paginate/array' require 'spec_helper' RSpec.describe WillPaginate::Collection do before :all do @simple = ('a'..'e').to_a end it "should be a subset of original collection" do expect(@simple.paginate(:page => 1, :per_page => 3)).to eq(%w( a b c )) end it "can be shorter than per_page...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false