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 |
|---|---|---|---|---|---|---|---|---|
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/and_node.rb | lib/rubocop/ast/node/and_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `until` nodes. This will be used in place of a plain
# node when the builder constructs the AST, making its methods available
# to all `until` nodes within RuboCop.
class AndNode < Node
include BinaryOperatorNode
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/procarg0_node.rb | lib/rubocop/ast/node/procarg0_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `procarg0` nodes.
# This will be used in place of a plain node when the builder constructs
# the AST, making its methods available to all `arg` nodes within RuboCop.
class Procarg0Node < ArgNode
# Returns the name of... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/case_node.rb | lib/rubocop/ast/node/case_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `case` nodes. This will be used in place of a plain
# node when the builder constructs the AST, making its methods available
# to all `case` nodes within RuboCop.
class CaseNode < Node
include ConditionalNode
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/arg_node.rb | lib/rubocop/ast/node/arg_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `arg`, `optarg`, `restarg`, `kwarg`, `kwoptarg`,
# `kwrestarg`, `blockarg`, `shadowarg` and `forward_arg` nodes.
# This will be used in place of a plain node when the builder constructs
# the AST, making its methods availa... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/break_node.rb | lib/rubocop/ast/node/break_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `break` nodes. This will be used in place of a
# plain node when the builder constructs the AST, making its methods
# available to all `break` nodes within RuboCop.
class BreakNode < Node
include ParameterizedNode::W... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/str_node.rb | lib/rubocop/ast/node/str_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `str`, `dstr`, and `xstr` nodes. This will be used
# in place of a plain node when the builder constructs the AST, making
# its methods available to all `str` nodes within RuboCop.
class StrNode < Node
include BasicL... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/const_node.rb | lib/rubocop/ast/node/const_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `const` nodes.
class ConstNode < Node
include ConstantNode
end
end
end
| ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/var_node.rb | lib/rubocop/ast/node/var_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `lvar`, `ivar`, `cvar` and `gvar` nodes.
# This will be used in place of a plain node when the builder constructs
# the AST, making its methods available to all assignment nodes within RuboCop.
class VarNode < Node
#... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/and_asgn_node.rb | lib/rubocop/ast/node/and_asgn_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `op_asgn` nodes.
# This will be used in place of a plain node when the builder constructs
# the AST, making its methods available to all assignment nodes within RuboCop.
class AndAsgnNode < OpAsgnNode
# The operator ... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/super_node.rb | lib/rubocop/ast/node/super_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `super`- and `zsuper` nodes. This will be used in
# place of a plain node when the builder constructs the AST, making its
# methods available to all `super`- and `zsuper` nodes within RuboCop.
class SuperNode < Node
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/keyword_begin_node.rb | lib/rubocop/ast/node/keyword_begin_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `kwbegin` nodes. This will be used in place of a plain
# node when the builder constructs the AST, making its methods available
# to all `kwbegin` nodes within RuboCop.
class KeywordBeginNode < Node
# Returns the bod... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/casgn_node.rb | lib/rubocop/ast/node/casgn_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `casgn` nodes.
# This will be used in place of a plain node when the builder constructs
# the AST, making its methods available to all assignment nodes within RuboCop.
class CasgnNode < Node
include ConstantNode
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/index_node.rb | lib/rubocop/ast/node/index_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Used for modern support only!
# Not as thoroughly tested as legacy equivalent
#
# $ ruby-parse -e "foo[:bar]"
# (index
# (send nil :foo)
# (sym :bar))
# $ ruby-parse --legacy -e "foo[:bar]"
# (send
# ... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/dstr_node.rb | lib/rubocop/ast/node/dstr_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `dstr` nodes. This will be used
# in place of a plain node when the builder constructs the AST, making
# its methods available to all `dstr` nodes within RuboCop.
class DstrNode < StrNode
def value
child_node... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/until_node.rb | lib/rubocop/ast/node/until_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `until` nodes. This will be used in place of a plain
# node when the builder constructs the AST, making its methods available
# to all `until` nodes within RuboCop.
class UntilNode < Node
include ConditionalNode
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/keyword_splat_node.rb | lib/rubocop/ast/node/keyword_splat_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `kwsplat` and `forwarded_kwrestarg` nodes. This will be used in
# place of a plain node when the builder constructs the AST, making its methods available to
# all `kwsplat` and `forwarded_kwrestarg` nodes within RuboCop.
c... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/csend_node.rb | lib/rubocop/ast/node/csend_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `csend` nodes. This will be used in place of a plain
# node when the builder constructs the AST, making its methods available
# to all `csend` nodes within RuboCop.
class CsendNode < SendNode
def send_type?
f... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/args_node.rb | lib/rubocop/ast/node/args_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `args` nodes. This will be used in place of a plain
# node when the builder constructs the AST, making its methods available
# to all `args` nodes within RuboCop.
class ArgsNode < Node
include CollectionNode
#... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/self_class_node.rb | lib/rubocop/ast/node/self_class_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A node extension for `sclass` nodes. This will be used in place of a
# plain node when the builder constructs the AST, making its methods
# available to all `sclass` nodes within RuboCop.
class SelfClassNode < Node
# The identifier for t... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/basic_literal_node.rb | lib/rubocop/ast/node/mixin/basic_literal_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for primitive literal nodes: `sym`, `str`,
# `int`, `float`, `rational`, `complex`...
module BasicLiteralNode
# Returns the value of the literal.
#
# @return [mixed] the value of the literal
def value
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/constant_node.rb | lib/rubocop/ast/node/mixin/constant_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that deal with constants:
# `const`, `casgn`.
module ConstantNode
# @return [Node, nil] the node associated with the scope (e.g. cbase, const, ...)
def namespace
children[0]
end
# @re... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/conditional_node.rb | lib/rubocop/ast/node/mixin/conditional_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that have conditions:
# `if`, `while`, `until`, `case`.
# This currently doesn't include `when` nodes, because they have multiple
# conditions, and need to be checked for that.
module ConditionalNode
# ... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/binary_operator_node.rb | lib/rubocop/ast/node/mixin/binary_operator_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that are binary operations:
# `or`, `and` ...
module BinaryOperatorNode
# Returns the left hand side node of the binary operation.
#
# @return [Node] the left hand side of the binary operation
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/collection_node.rb | lib/rubocop/ast/node/mixin/collection_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# A mixin that helps give collection nodes array polymorphism.
module CollectionNode
extend SimpleForwardable
ARRAY_METHODS =
(Array.instance_methods - Object.instance_methods - [:to_a]).freeze
private_constant :ARRAY_METHODS
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/method_dispatch_node.rb | lib/rubocop/ast/node/mixin/method_dispatch_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that are a kind of method dispatch:
# `send`, `csend`, `super`, `zsuper`, `yield`, `defined?`,
# and (modern only): `index`, `indexasgn`, `lambda`
module MethodDispatchNode # rubocop:disable Metrics/ModuleLength
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb | lib/rubocop/ast/node/mixin/method_identifier_predicates.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common predicates for nodes that reference method identifiers:
# `send`, `csend`, `def`, `defs`, `super`, `zsuper`
#
# @note this mixin expects `#method_name` and `#receiver` to be implemented
module MethodIdentifierPredicates # rubocop:di... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/modifier_node.rb | lib/rubocop/ast/node/mixin/modifier_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that can be used as modifiers:
# `if`, `while`, `until`
module ModifierNode
# Checks whether the node is in a modifier form, i.e. a condition
# trailing behind an expression.
#
# @return [Bool... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/descendence.rb | lib/rubocop/ast/node/mixin/descendence.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for primitive literal nodes: `sym`, `str`,
# `int`, `float`, ...
module Descendence
# Calls the given block for each child node.
# If no block is given, an `Enumerator` is returned.
#
# Note that this i... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/parameterized_node.rb | lib/rubocop/ast/node/mixin/parameterized_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Requires implementing `arguments`.
#
# Common functionality for nodes that are parameterized:
# `send`, `super`, `zsuper`, `def`, `defs`
# and (modern only): `index`, `indexasgn`, `lambda`
module ParameterizedNode
# Checks whethe... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/hash_element_node.rb | lib/rubocop/ast/node/mixin/hash_element_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that can be used as hash elements:
# `pair`, `kwsplat`
module HashElementNode
# Returns the key of this `hash` element.
#
# @note For keyword splats, this returns the whole node
#
# @ret... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/numeric_node.rb | lib/rubocop/ast/node/mixin/numeric_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for primitive numeric nodes: `int`, `float`, `rational`, `complex`...
module NumericNode
SIGN_REGEX = /\A[+-]/.freeze
private_constant :SIGN_REGEX
# Checks whether this is literal has a sign.
#
# @ex... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node/mixin/predicate_operator_node.rb | lib/rubocop/ast/node/mixin/predicate_operator_node.rb | # frozen_string_literal: true
module RuboCop
module AST
# Common functionality for nodes that are predicates:
# `or`, `and` ...
module PredicateOperatorNode
LOGICAL_AND = '&&'
private_constant :LOGICAL_AND
SEMANTIC_AND = 'and'
private_constant :SEMANTIC_AND
LOGICAL_OR = '||'... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/with_meta.rb | lib/rubocop/ast/node_pattern/with_meta.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
class Parser
# Overrides Parser to use `WithMeta` variants and provide additional methods
class WithMeta < Parser
# Overrides Lexer to token locations and comments
class Lexer < NodePattern::Lexer
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler.rb | lib/rubocop/ast/node_pattern/compiler.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
# The top-level compiler holding the global state
# Defers work to its subcompilers
#
# Doc on how this fits in the compiling process:
# /docs/modules/ROOT/pages/node_pattern.adoc
class Compiler
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/sets.rb | lib/rubocop/ast/node_pattern/sets.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
# Utility to assign a set of values to a constant
module Sets
REGISTRY = Hash.new do |h, set|
name = Sets.name(set).freeze
Sets.const_set(name, set)
h[set] = "::RuboCop::AST::NodePattern::S... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/node.rb | lib/rubocop/ast/node_pattern/node.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
# Base class for AST Nodes of a `NodePattern`
class Node < ::Parser::AST::Node
extend SimpleForwardable
include ::RuboCop::AST::Descendence
MATCHES_WITHIN_SET = %i[symbol number string].to_set.freeze
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/method_definer.rb | lib/rubocop/ast/node_pattern/method_definer.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
# Functionality to turn `match_code` into methods/lambda
module MethodDefiner
def def_node_matcher(base, method_name, **defaults)
def_helper(base, method_name, **defaults) do |name|
params = emit_p... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/parser.rb | lib/rubocop/ast/node_pattern/parser.rb | # frozen_string_literal: true
require_relative 'parser.racc'
module RuboCop
module AST
class NodePattern
# Parser for NodePattern
# Note: class reopened in `parser.racc`
#
# Doc on how this fits in the compiling process:
# /docs/modules/ROOT/pages/node_pattern.adoc
class Pa... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/comment.rb | lib/rubocop/ast/node_pattern/comment.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
# A NodePattern comment, simplified version of ::Parser::Source::Comment
class Comment
attr_reader :location
alias loc location
##
# @param [Parser::Source::Range] range
#
def in... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/lexer.rb | lib/rubocop/ast/node_pattern/lexer.rb | # frozen_string_literal: true
begin
require_relative 'lexer.rex'
rescue LoadError
msg = '*** You must run `rake generate` to generate the lexer and the parser ***'
puts '*' * msg.length, msg, '*' * msg.length
raise
end
module RuboCop
module AST
class NodePattern
# Lexer class for `NodePattern`
... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/builder.rb | lib/rubocop/ast/node_pattern/builder.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
# Responsible to build the AST nodes for `NodePattern`
#
# Doc on how this fits in the compiling process:
# /docs/modules/ROOT/pages/node_pattern.adoc
class Builder
def emit_capture(capture_token, no... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler/subcompiler.rb | lib/rubocop/ast/node_pattern/compiler/subcompiler.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
class Compiler
# Base class for subcompilers
# Implements visitor pattern
#
# Doc on how this fits in the compiling process:
# /docs/modules/ROOT/pages/node_pattern.adoc
class Subcomp... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler/node_pattern_subcompiler.rb | lib/rubocop/ast/node_pattern/compiler/node_pattern_subcompiler.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
class Compiler
# Compiles code that evalues to true or false
# for a given value `var` (typically a RuboCop::AST::Node)
# or it's `node.type` if `seq_head` is true
#
# Doc on how this fits in t... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler/binding.rb | lib/rubocop/ast/node_pattern/compiler/binding.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
class Compiler
# Holds the list of bound variable names
class Binding
def initialize
@bound = {}
end
# Yields the first time a given name is bound
#
# @re... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler/debug.rb | lib/rubocop/ast/node_pattern/compiler/debug.rb | # frozen_string_literal: true
require 'rainbow'
module RuboCop
module AST
class NodePattern
class Compiler
# Variant of the Compiler with tracing information for nodes
class Debug < Compiler
# Compiled node pattern requires a named parameter `trace`,
# which should be a... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler/atom_subcompiler.rb | lib/rubocop/ast/node_pattern/compiler/atom_subcompiler.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
class Compiler
# Generates code that evaluates to a value (Ruby object)
# This value responds to `===`.
#
# Doc on how this fits in the compiling process:
# /docs/modules/ROOT/pages/node_patt... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb | lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb | # frozen_string_literal: true
module RuboCop
module AST
class NodePattern
class Compiler
# Compiles terms within a sequence to code that evalues to true or false.
# Compilation of the nodes that can match only a single term is deferred to
# `NodePatternSubcompiler`; only nodes that ... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/ext/range.rb | lib/rubocop/ast/ext/range.rb | # frozen_string_literal: true
module RuboCop
module AST
module Ext
# Extensions to Parser::AST::Range
module Range
# @return [Range] the range of line numbers for the node
# If `exclude_end` is `true`, then the range will be exclusive.
#
# Assume that `node` correspond... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
rubocop/rubocop-ast | https://github.com/rubocop/rubocop-ast/blob/69036498c11ca944c6099d1b672ba408f34a3eb4/lib/rubocop/ast/utilities/simple_forwardable.rb | lib/rubocop/ast/utilities/simple_forwardable.rb | # frozen_string_literal: true
module RuboCop
# Similar to `Forwardable#def_delegators`, but simpler & faster
module SimpleForwardable
def def_delegators(accessor, *methods)
methods.each do |method|
if method.end_with?('=') && method.to_s != '[]='
# Defining a delegator for `foo=` can't ... | ruby | MIT | 69036498c11ca944c6099d1b672ba408f34a3eb4 | 2026-01-04T17:49:41.556809Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path('dummy/config/environment.rb', __dir__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path('dummy/db/migrate', __dir__)]
ActiveRecord::Migrat... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/support/pundit_stubs.rb | spec/support/pundit_stubs.rb | # frozen_string_literal: true
module PunditStubs
def allow_action(record, action)
policy = ::Pundit::PolicyFinder.new(record).policy
allow(policy).to(
receive(:new).with(any_args, record) { instance_double(policy, action => true) }
)
end
def disallow_action(record, action)
policy = ::Pundi... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/support/custom_matchers.rb | spec/support/custom_matchers.rb | # frozen_string_literal: true
# Add better debuggability to be_forbidden failures
RSpec::Matchers.define :be_forbidden do
match(&:forbidden?)
failure_message do |actual|
debug_text_for_failure('forbidden', response: actual, last_request: last_request)
end
end
# Add better debuggability to be_not_found fail... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/support/authorization_stubs.rb | spec/support/authorization_stubs.rb | # frozen_string_literal: true
module AuthorizationStubs
AUTHORIZER_CLASS = JSONAPI::Authorization::DefaultPunditAuthorizer
def allow_operation(operation, authorizer: instance_double(AUTHORIZER_CLASS), **kwargs)
allow(authorizer).to receive(operation).with(**kwargs).and_return(nil)
allow(AUTHORIZER_CLASS)... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/requests/resource_operations_spec.rb | spec/requests/resource_operations_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe 'Resource operations', type: :request do
include AuthorizationStubs
fixtures :all
let(:article) { Article.all.sample }
let(:policy_scope) { Article.none }
subject { last_response }
let(:json_data) { JSON.parse(last_response.body)["data"] }
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/requests/tricky_operations_spec.rb | spec/requests/tricky_operations_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Tricky operations', type: :request do
include AuthorizationStubs
fixtures :all
let(:article) { Article.all.sample }
let(:policy_scope) { Article.none }
subject { last_response }
let(:json_data) { JSON.parse(last_response.body)["data"] }... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/requests/relationship_operations_spec.rb | spec/requests/relationship_operations_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Relationship operations', type: :request do
include AuthorizationStubs
fixtures :all
let(:article) { Article.all.sample }
let(:policy_scope) { Article.none }
let(:json_data) { JSON.parse(last_response.body)["data"] }
before do
allo... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/requests/custom_name_relationship_operations_spec.rb | spec/requests/custom_name_relationship_operations_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'including custom name relationships', type: :request do
include AuthorizationStubs
fixtures :all
subject { last_response }
let(:json_included) { JSON.parse(last_response.body) }
let(:comments_policy_scope) { Comment.all }
before do
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/requests/related_resources_operations_spec.rb | spec/requests/related_resources_operations_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Related resources operations', type: :request do
include AuthorizationStubs
fixtures :all
let(:article) { Article.all.sample }
let(:authorizations) { {} }
let(:policy_scope) { Article.none }
let(:user_policy_scope) { User.all }
before... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/requests/included_resources_spec.rb | spec/requests/included_resources_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'including resources alongside normal operations', type: :request do
include AuthorizationStubs
fixtures :all
subject { last_response }
let(:json_included) { JSON.parse(last_response.body)['included'] }
let(:comments_policy_scope) { Commen... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/jsonapi/authorization/configuration_spec.rb | spec/jsonapi/authorization/configuration_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe JSONAPI::Authorization::Configuration do
after do
# Set this back to the default after each
JSONAPI::Authorization.configuration.pundit_user = :user
end
describe '#user_context' do
context "given a symbol" do
it "returns the 'u... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/jsonapi/authorization/default_pundit_authorizer_spec.rb | spec/jsonapi/authorization/default_pundit_authorizer_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe JSONAPI::Authorization::DefaultPunditAuthorizer do
include PunditStubs
fixtures :all
let(:source_record) { Article.new }
let(:authorizer) { described_class.new(context: {}) }
shared_examples_for :update_singular_fallback do |related_record... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | true |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/policies/comment_policy.rb | spec/dummy/app/policies/comment_policy.rb | # frozen_string_literal: true
class CommentPolicy
Scope = Struct.new(:user, :scope) do
def resolve
raise NotImplementedError
end
end
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
raise NotImplementedError
end
def show?... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/policies/article_policy.rb | spec/dummy/app/policies/article_policy.rb | # frozen_string_literal: true
class ArticlePolicy
Scope = Struct.new(:user, :scope) do
def resolve
raise NotImplementedError
end
end
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
raise NotImplementedError
end
def show?... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/policies/user_policy.rb | spec/dummy/app/policies/user_policy.rb | # frozen_string_literal: true
class UserPolicy
Scope = Struct.new(:user, :scope) do
def resolve
raise NotImplementedError
end
end
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
raise NotImplementedError
end
def show?
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/policies/tag_policy.rb | spec/dummy/app/policies/tag_policy.rb | # frozen_string_literal: true
class TagPolicy
Scope = Struct.new(:user, :scope) do
def resolve
raise NotImplementedError
end
end
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
raise NotImplementedError
end
def show?
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/controllers/articles_controller.rb | spec/dummy/app/controllers/articles_controller.rb | # frozen_string_literal: true
class ArticlesController < ApplicationController
include JSONAPI::ActsAsResourceController
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def context
{ user: nil }
end
# https://github.com/cerebris/jsonapi-resources/pull/573
def handle_exce... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/controllers/taggable_controller.rb | spec/dummy/app/controllers/taggable_controller.rb | # frozen_string_literal: true
# http://jsonapi-resources.com/v0.9/guide/resources.html#Relationships
#
# > The polymorphic relationship will require the resource
# > and controller to exist, although routing to them will
# > cause an error.
class TaggablesController < JSONAPI::ResourceController; end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/controllers/tags_controller.rb | spec/dummy/app/controllers/tags_controller.rb | # frozen_string_literal: true
class TagsController < ApplicationController
include JSONAPI::ActsAsResourceController
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def context
{ user: nil }
end
# https://github.com/cerebris/jsonapi-resources/pull/573
def handle_exceptio... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/controllers/users_controller.rb | spec/dummy/app/controllers/users_controller.rb | # frozen_string_literal: true
class UsersController < ApplicationController
include JSONAPI::ActsAsResourceController
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def context
{ user: nil }
end
# https://github.com/cerebris/jsonapi-resources/pull/573
def handle_excepti... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/controllers/comments_controller.rb | spec/dummy/app/controllers/comments_controller.rb | # frozen_string_literal: true
class CommentsController < ApplicationController
include JSONAPI::ActsAsResourceController
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def context
{ user: nil }
end
# https://github.com/cerebris/jsonapi-resources/pull/573
def handle_exce... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/controllers/application_controller.rb | spec/dummy/app/controllers/application_controller.rb | # frozen_string_literal: true
class ApplicationController < ActionController::Base
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/models/tag.rb | spec/dummy/app/models/tag.rb | # frozen_string_literal: true
class Tag < ActiveRecord::Base
belongs_to :taggable, polymorphic: true
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/models/article.rb | spec/dummy/app/models/article.rb | # frozen_string_literal: true
class Article < ActiveRecord::Base
has_many :comments
has_many :tags, as: :taggable
belongs_to :author, class_name: 'User'
def to_param
external_id
end
# Hack for easy include directive checks
has_many :articles, -> { limit(2) }, foreign_key: :id
has_one :article, fo... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/models/comment.rb | spec/dummy/app/models/comment.rb | # frozen_string_literal: true
class Comment < ActiveRecord::Base
has_many :tags, as: :taggable
belongs_to :article
belongs_to :author, class_name: 'User'
belongs_to :reviewing_user, class_name: 'User'
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/models/user.rb | spec/dummy/app/models/user.rb | # frozen_string_literal: true
class User < ActiveRecord::Base
has_many :articles, foreign_key: :author_id
has_many :comments, foreign_key: :author_id
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/resources/comment_resource.rb | spec/dummy/app/resources/comment_resource.rb | # frozen_string_literal: true
class CommentResource < JSONAPI::Resource
include JSONAPI::Authorization::PunditScopedResource
has_many :tags
has_one :article
has_one :reviewer, relation_name: "reviewing_user", class_name: "User"
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/resources/user_resource.rb | spec/dummy/app/resources/user_resource.rb | # frozen_string_literal: true
class UserResource < JSONAPI::Resource
include JSONAPI::Authorization::PunditScopedResource
has_many :comments
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/resources/tag_resource.rb | spec/dummy/app/resources/tag_resource.rb | # frozen_string_literal: true
class TagResource < JSONAPI::Resource
include JSONAPI::Authorization::PunditScopedResource
has_one :taggable, polymorphic: true
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/resources/taggable_resource.rb | spec/dummy/app/resources/taggable_resource.rb | # frozen_string_literal: true
# http://jsonapi-resources.com/v0.9/guide/resources.html#Relationships
#
# > The polymorphic relationship will require the resource
# > and controller to exist, although routing to them will
# > cause an error.
class TaggableResource < JSONAPI::Resource
def self.verify_key(key, _context... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/app/resources/article_resource.rb | spec/dummy/app/resources/article_resource.rb | # frozen_string_literal: true
class ArticleResource < JSONAPI::Resource
include JSONAPI::Authorization::PunditScopedResource
has_many :comments, acts_as_set: true
has_many :tags
has_one :author, class_name: 'User'
primary_key :external_id
def self.verify_key(key, _context = nil)
key && String(key)
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/db/schema.rb | spec/dummy/db/schema.rb | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/db/migrate/20160125083537_create_models.rb | spec/dummy/db/migrate/20160125083537_create_models.rb | # frozen_string_literal: true
class CreateModels < ActiveRecord::Migration
def change
create_table :comments do |t|
t.string :article_id
t.belongs_to :author
t.belongs_to :reviewing_user, references: :user
end
create_table :users
create_table :articles do |t|
t.string :exter... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/config/application.rb | spec/dummy/config/application.rb | # frozen_string_literal: true
require File.expand_path('boot', __dir__)
require "rails/all"
Bundler.require(:default, Rails.env)
class Application < Rails::Application
config.root = File.expand_path('..', __dir__)
config.cache_classes = true
config.eager_load = false
config.serve_static_files = true
confi... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/config/environment.rb | spec/dummy/config/environment.rb | # frozen_string_literal: true
# Load the Rails application.
require File.expand_path('application', __dir__)
# Initialize the Rails application.
Rails.application.initialize!
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/config/routes.rb | spec/dummy/config/routes.rb | # frozen_string_literal: true
Rails.application.routes.draw do
jsonapi_resources :articles do
jsonapi_relationships
end
jsonapi_resources :comments do
jsonapi_relationships
end
jsonapi_resources :tags
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/spec/dummy/config/boot.rb | spec/dummy/config/boot.rb | # frozen_string_literal: true
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi-authorization.rb | lib/jsonapi-authorization.rb | # frozen_string_literal: true
require 'jsonapi/authorization'
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi/authorization.rb | lib/jsonapi/authorization.rb | # frozen_string_literal: true
require "jsonapi-resources"
require "jsonapi/authorization/authorizing_processor"
require "jsonapi/authorization/configuration"
require "jsonapi/authorization/default_pundit_authorizer"
require "jsonapi/authorization/pundit_scoped_resource"
require "jsonapi/authorization/version"
module ... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi/authorization/version.rb | lib/jsonapi/authorization/version.rb | # frozen_string_literal: true
module JSONAPI
module Authorization
VERSION = "3.0.2"
end
end
| ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi/authorization/default_pundit_authorizer.rb | lib/jsonapi/authorization/default_pundit_authorizer.rb | # frozen_string_literal: true
module JSONAPI
module Authorization
# An authorizer is a class responsible for linking JSONAPI operations to
# your choice of authorization mechanism.
#
# This class uses Pundit for authorization. You can use your own authorizer
# class instead if you have different ... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi/authorization/authorizing_processor.rb | lib/jsonapi/authorization/authorizing_processor.rb | # frozen_string_literal: true
require 'pundit'
module JSONAPI
module Authorization
class AuthorizingProcessor < JSONAPI::Processor
set_callback :find, :before, :authorize_find
set_callback :show, :before, :authorize_show
set_callback :show_relationship, :before, :authorize_show_relationship
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi/authorization/pundit_scoped_resource.rb | lib/jsonapi/authorization/pundit_scoped_resource.rb | # frozen_string_literal: true
require 'pundit'
module JSONAPI
module Authorization
module PunditScopedResource
extend ActiveSupport::Concern
module ClassMethods
def records(options = {})
user_context = JSONAPI::Authorization.configuration.user_context(options[:context])
... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
venuu/jsonapi-authorization | https://github.com/venuu/jsonapi-authorization/blob/3184da84e3d83ae2bef4e472232680efa6e5b52c/lib/jsonapi/authorization/configuration.rb | lib/jsonapi/authorization/configuration.rb | # frozen_string_literal: true
require 'jsonapi/authorization/default_pundit_authorizer'
module JSONAPI
module Authorization
class Configuration
attr_accessor :authorizer, :pundit_user
def initialize
self.authorizer = ::JSONAPI::Authorization::DefaultPunditAuthorizer
self.pundit_use... | ruby | MIT | 3184da84e3d83ae2bef4e472232680efa6e5b52c | 2026-01-04T17:49:48.253126Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/test/test_summarize_average.rb | test/test_summarize_average.rb | require_relative "./test_helper"
require_relative "./test_data"
class TestSummarize < Minitest::Test
include AssertNoopEqual
def test_simple_average_age
compare_noop do |noop|
Person.summarize(noop: noop) { |p| p.average(:age).round(10) }
end
end
def test_grouped_average_age
compare_noop do... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/test/test_data.rb | test/test_data.rb | require_relative "./test_helper"
# Choose a connection. In the future, we'll come up with some way to automate it.
ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: ":memory:"
)
# ActiveRecord::Base.establish_connection(
# adapter: "postgresql",
# encoding: "unicode",
# database: "summ... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/test/test_chainable_result.rb | test/test_chainable_result.rb | require_relative "./test_helper"
require_relative "./test_data"
class TestChainableResult < Minitest::Test
def test_with_invocations
counts, factor, addends = toy_values.map { |v| ChainableResult.wrap(v) }
# A single value
assert_equal(
{123 => :foo, 200 => :bar},
ChainableResult::WITH_RESOLV... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/test/test_helper.rb | test/test_helper.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "active_record"
require "activerecord/summarize"
require "minitest/autorun"
module AssertNoopEqual
def compare_noop(message = "was not equal with noop: true and noop: false")
noop_result = yield(true)
result = yiel... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/test/test_summarize_minimum_maximum.rb | test/test_summarize_minimum_maximum.rb | require_relative "./test_helper"
require_relative "./test_data"
class TestSummarize < Minitest::Test
include AssertNoopEqual
def test_simple_minmax_age
compare_noop do |noop|
Person.summarize(noop: noop) do |p|
[p.minimum(:age), p.maximum(:age)]
end
end
end
def test_grouped_minmax... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/test/test_summarize.rb | test/test_summarize.rb | require_relative "./test_helper"
require_relative "./test_data"
class TestSummarize < Minitest::Test
include AssertNoopEqual
def test_that_it_has_a_version_number
refute_nil ::ActiveRecord::Summarize::VERSION
end
def test_data_sanity
assert_equal 500, Person.count
# 1 in ~2.679 E 300 chance this ... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
midnightmonster/activerecord-summarize | https://github.com/midnightmonster/activerecord-summarize/blob/7371f06ce47b2bc6966a5b8297aa95aaee2c59de/lib/chainable_result.rb | lib/chainable_result.rb | class ChainableResult
def initialize(source, method = nil, args = [], opts = {}, &block)
@source = source
@method = method || (block ? :then : :itself)
@args = args
@opts = opts
@block = block
@cached = false
end
def value
if use_cache?
return @value if @cached
@cached = t... | ruby | MIT | 7371f06ce47b2bc6966a5b8297aa95aaee2c59de | 2026-01-04T17:49:56.082596Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.