Skip to content

Commit

Permalink
working for activesupport 7.0.8, and 7.1.1 except 1 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
klobuczek committed Oct 18, 2023
1 parent 8ec60f4 commit 09eccd4
Show file tree
Hide file tree
Showing 63 changed files with 267 additions and 497 deletions.
6 changes: 3 additions & 3 deletions activegraph.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ DESCRIPTION
s.add_dependency('activesupport', '>= 4.0', '< 7.1')
s.add_dependency('i18n', '!= 1.8.8') # https://github.com/jruby/jruby/issues/6547
s.add_dependency('neo4j-ruby-driver', '>= 5.13.0.alpha.3')
s.add_dependency('orm_adapter', '~> 0.5.0')
s.add_dependency('orm_adapter', '>= 0.5.0')
s.add_dependency('sorted_set')
s.add_dependency('psych', '5.1.0') # Tempprary workaround
s.add_development_dependency('guard')
s.add_development_dependency('guard-rspec')
s.add_development_dependency('guard-rubocop')
Expand All @@ -49,5 +48,6 @@ DESCRIPTION
s.add_development_dependency('rubocop', '>= 0.56.0')
s.add_development_dependency('yard')
s.add_development_dependency('dryspec')
s.add_development_dependency('rspec', '< 3.10') # Cannot proxy frozen objects
# s.add_development_dependency('rspec', '< 3.10') # Cannot proxy frozen objects
s.add_development_dependency('rspec') # Cannot proxy frozen objects
end
157 changes: 43 additions & 114 deletions lib/active_graph.rb
Original file line number Diff line number Diff line change
@@ -1,125 +1,54 @@
require 'benchmark'
require 'bigdecimal'
require 'bigdecimal/util'
require 'date'
require 'forwardable'
require 'active_graph/version'

require 'active_graph/core'
require 'active_graph/core/query_ext' # From this gem

require 'active_support/core_ext/module/attribute_accessors_per_thread'
require 'active_graph/secure_random_ext'
require 'active_graph/transactions'
require 'active_graph/base'
require 'active_graph/model_schema'

require 'active_model'
require 'active_support/concern'
require 'active_support/core_ext/class/attribute.rb'
require 'active_support/core_ext/class/subclasses.rb'
require 'active_model/attribute_set'
require 'active_support/core_ext/big_decimal/conversions'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/class/subclasses'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/attribute_accessors_per_thread'
require 'active_support/core_ext/string/conversions'
require 'active_support/inflector'
require 'active_support/inflector/inflections'
require 'active_support/notifications'
require 'json'
require 'neo4j/driver'
require 'orm_adapter'
require 'rake'
require 'set'
require 'sorted_set'
require 'yaml'

require 'active_graph/lazy_attribute_hash'
require 'active_graph/attribute_set'
require 'active_graph/errors'
require 'active_graph/config'
require 'active_graph/wrapper'
require 'active_graph/relationship/rel_wrapper'
require 'active_graph/node/node_wrapper'
require 'active_graph/shared/type_converters'
require 'active_graph/shared/rel_type_converters'
require 'active_graph/shared/marshal'
require 'active_graph/type_converters'
require 'active_graph/paginated'
require 'active_graph/schema/operation'

require 'active_graph/timestamps'
require 'active_graph/undeclared_properties'

require 'active_graph/shared/callbacks'
require 'active_graph/shared/filtered_hash'
require 'active_graph/shared/declared_property/index'
require 'active_graph/shared/declared_property'
require 'active_graph/shared/declared_properties'
require 'active_graph/shared/enum'
require 'active_graph/shared/mass_assignment'
require 'active_graph/shared/attributes'
require 'active_graph/shared/typecasted_attributes'
require 'active_graph/shared/property'
require 'active_graph/shared/persistence'
require 'active_graph/shared/validations'
require 'active_graph/shared/identity'
require 'active_graph/shared/serialized_properties'
require 'active_graph/shared/typecaster'
require 'active_graph/shared/initialize'
require 'active_graph/shared/query_factory'
require 'active_graph/shared/cypher'
require 'active_graph/shared/permitted_attributes'
require 'active_graph/shared'

require 'active_graph/relationship/callbacks'
require 'active_graph/relationship/initialize'
require 'active_graph/relationship/property'
require 'active_graph/relationship/persistence/query_factory'
require 'active_graph/relationship/persistence'
require 'active_graph/relationship/validations'
require 'active_graph/relationship/query'
require 'active_graph/relationship/related_node'
require 'active_graph/relationship/types'
require 'active_graph/relationship'

require 'active_graph/node/dependent_callbacks'
require 'active_graph/node/node_list_formatter'
require 'active_graph/node/dependent'
require 'active_graph/node/dependent/query_proxy_methods'
require 'active_graph/node/dependent/association_methods'
require 'active_graph/node/enum'
require 'active_graph/node/query_methods'
require 'active_graph/node/query/query_proxy_methods'
require 'active_graph/node/query/query_proxy_methods_of_mass_updating'
require 'active_graph/node/query/query_proxy_enumerable'
require 'active_graph/node/query/query_proxy_find_in_batches'
require 'active_graph/node/query/query_proxy_eager_loading'
require 'active_graph/node/query/query_proxy_eager_loading/association_tree'
require 'active_graph/node/query/query_proxy_link'
require 'active_graph/node/labels/index'
require 'active_graph/node/labels/reloading'
require 'active_graph/node/labels'
require 'active_graph/node/id_property/accessor'
require 'active_graph/node/id_property'
require 'active_graph/node/callbacks'
require 'active_graph/node/initialize'
require 'active_graph/node/property'
require 'active_graph/node/persistence'
require 'active_graph/node/validations'
require 'active_graph/node/rels'
require 'active_graph/node/reflection'
require 'active_graph/node/unpersisted'
require 'active_graph/node/has_n'
require 'active_graph/node/has_n/association_cypher_methods'
require 'active_graph/node/has_n/association/rel_wrapper'
require 'active_graph/node/has_n/association/rel_factory'
require 'active_graph/node/has_n/association'
require 'active_graph/node/query/query_proxy'
require 'active_graph/node/query'
require 'active_graph/node/scope'
require 'active_graph/node'

require 'active_support/concern'
require 'active_graph/core/cypher_error'
require 'active_graph/core/schema_errors'

module ActiveGraph
extend ActiveSupport::Autoload
autoload :Migrations
autoload :Migration
end

load 'active_graph/tasks/migration.rake'

require 'active_graph/node/orm_adapter'
if defined?(Rails)
# Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
require 'action_dispatch/railtie'
require 'rails/generators'
require 'rails/generators/active_graph_generator'
require 'rails/generators/active_model'
require 'rails/generators/named_base'
require 'rails/railtie'
end

loader = Zeitwerk::Loader.for_gem
unless defined?(Rails)
loader.ignore(File.expand_path('active_graph/generators', __dir__))
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
end
loader.inflector.inflect("ansi" => "ANSI")
loader.setup
# loader.eager_load

Neo4j::Driver::Result.prepend ActiveGraph::Core::Result
Neo4j::Driver::Record.prepend ActiveGraph::Core::Record
Neo4j::Driver::Transaction.prepend ActiveGraph::Transaction
Neo4j::Driver::Types::Entity.include ActiveGraph::Core::Wrappable
Neo4j::Driver::Types::Entity.prepend ActiveGraph::Core::Entity
Neo4j::Driver::Types::Node.prepend ActiveGraph::Core::Node
Neo4j::Driver::Types::Node.wrapper_callback(&ActiveGraph::Node::Wrapping.method(:wrapper))
Neo4j::Driver::Types::Relationship.wrapper_callback(&ActiveGraph::Relationship::Wrapping.method(:wrapper))
SecureRandom.singleton_class.prepend ActiveGraph::SecureRandomExt
Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute if defined?(Rails)

load 'active_graph/tasks/migration.rake'
4 changes: 0 additions & 4 deletions lib/active_graph/attribute_set.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# frozen_string_literal: true

require 'active_model/attribute_set'

module ActiveGraph
class AttributeSet < ActiveModel::AttributeSet
def initialize(attr_hash, attr_list)
Expand Down
3 changes: 0 additions & 3 deletions lib/active_graph/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require 'active_graph/core/querable'
require 'active_graph/core/schema'

module ActiveGraph
# To contain any base login for Node/Relationship which
# is external to the main classes
Expand Down
1 change: 0 additions & 1 deletion lib/active_graph/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def default_file=(file_path)

# @return [Hash] the default file loaded by yaml
def defaults
require 'yaml'
@defaults ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(default_file))
end

Expand Down
14 changes: 0 additions & 14 deletions lib/active_graph/core.rb

This file was deleted.

5 changes: 0 additions & 5 deletions lib/active_graph/core/instrumentable.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
require 'active_support/concern'
require 'active_support/notifications'
require 'active_graph/ansi'
require 'active_graph/core/logging'

module ActiveGraph
module Core
module Instrumentable
Expand Down
5 changes: 0 additions & 5 deletions lib/active_graph/core/querable.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
require 'active_graph/core/instrumentable'
require 'active_graph/transaction'
require 'active_graph/core/query_builder'
require 'active_graph/core/record'

module ActiveGraph
module Core
module Querable
Expand Down
11 changes: 4 additions & 7 deletions lib/active_graph/core/query.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require 'active_graph/core/query_clauses'
require 'active_graph/core/query_find_in_batches'
require 'active_support/notifications'

module ActiveGraph
module Core
# Allows for generation of cypher queries via ruby method calls (inspired by ActiveRecord / arel syntax)
Expand All @@ -15,9 +11,9 @@ module Core
class Query
include ActiveGraph::Core::QueryClauses
include ActiveGraph::Core::QueryFindInBatches
include QueryExt
DEFINED_CLAUSES = {}


attr_accessor :clauses

class Parameters
Expand Down Expand Up @@ -247,7 +243,7 @@ def match_nodes(hash, optional_match = false)
neo_id = (node_object.respond_to?(:neo_id) ? node_object.neo_id : node_object)

match_method = optional_match ? :optional_match : :match
query.send(match_method, variable).where(variable => {neo_id: neo_id})
query.send(match_method, variable).where(variable => { neo_id: })
end
end

Expand All @@ -271,7 +267,6 @@ def each
# @return [Array]
# @raise [ActiveGraph::Server::CypherResponse::ResponseError] Raises errors from neo4j server


# Executes a query without returning the result
# @return [Boolean] true if successful
# @raise [ActiveGraph::Server::CypherResponse::ResponseError] Raises errors from neo4j server
Expand Down Expand Up @@ -318,6 +313,7 @@ def return_query(columns)
# @return [String] Resulting cypher query string
EMPTY = ' '
NEWLINE = "\n"

def to_cypher(options = {})
join_string = options[:pretty] ? NEWLINE : EMPTY

Expand All @@ -334,6 +330,7 @@ def to_cypher(options = {})
cypher_string = "CYPHER #{@options[:parser]} #{cypher_string}" if @options[:parser]
cypher_string.tap(&:strip!)
end

alias cypher to_cypher

def pretty_cypher
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/core/query_ext.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ActiveGraph
module Core
class Query
module QueryExt
# Creates a ActiveGraph::Node::Query::QueryProxy object that builds off of a Core::Query object.
#
# @param [Class] model An Node model to be used as the start of a new QueryuProxy chain
Expand Down
5 changes: 0 additions & 5 deletions lib/active_graph/core/record.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# frozen_string_literal: true

require 'active_graph/core/result'
require 'active_support/core_ext/module/attribute_accessors'

module ActiveGraph
module Core
module Record
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/core/wrappable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def wrap
end

class_methods do
def wrapper_callback(proc)
def wrapper_callback(&proc)
fail 'Callback already specified!' if @wrapper_callback
@wrapper_callback = proc
end
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions lib/active_graph/generators/active_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class ActiveGraph::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
def self.all(klass)
"#{klass}.all"
end

def self.find(klass, params = nil)
"#{klass}.find(#{params})"
end

def self.build(klass, params = nil)
if params
"#{klass}.new(#{params})"
else
"#{klass}.new"
end
end

def save
"#{name}.save"
end

def update_attributes(params = nil)
"#{name}.update_attributes(#{params})"
end

def errors
"#{name}.errors"
end

def destroy
"#{name}.destroy"
end
end
17 changes: 17 additions & 0 deletions lib/active_graph/generators/generated_attribute.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module ActiveGraph
module Generators
module GeneratedAttribute #:nodoc:
def type_class
case type.to_s.downcase
when 'any' then 'any'
when 'datetime' then 'DateTime'
when 'date' then 'Date'
when 'integer', 'number', 'fixnum' then 'Integer'
when 'float' then 'Float'
else
'String'
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# frozen_string_literal: true

require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'active_graph.rb')

module ActiveGraph
module Generators
class MigrationGenerator < ::Rails::Generators::NamedBase
Expand Down
Loading

0 comments on commit 09eccd4

Please sign in to comment.