Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP duplicate PR of #1714 to check test builds #1715

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ jruby-9.3.10.0, jruby-9.4.2.0, ruby-3.1.4, ruby-3.2.2 ]
neo4j: [ 3.5.35, 4.0.12, 4.1.12, 4.2.19, 4.3.23, 4.4.19, 5.7.0 ]
ruby: [ jruby-9.4.5.0, ruby-3.1.4 ]
neo4j: [ 3.5.35, 4.0.12, 4.1.13, 4.2.19, 4.3.24, 4.4.29, 5.15.0 ]
active_model: [ 7.0.8, 7.1.2 ]
include:
- ruby: ruby-3.2.2
neo4j: 5.15.0
active_model: 7.1.2
env:
NEO4J_VERSION: ${{ matrix.neo4j }}
ACTIVE_MODEL_VERSION: ${{ matrix.active_model }}
JRUBY_OPTS: --debug -J-Xmx1280m -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xcompile.mode=OFF
steps:
- name: Start neo4j
Expand All @@ -42,5 +48,5 @@ jobs:
- name: Run tests
run: bundle exec rspec

- name: Run tests
run: bundle exec rubocop
# - name: Run tests
# run: bundle exec rubocop
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.0
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ source 'http://rubygems.org'

gemspec

# gem 'neo4j-ruby-driver', path: '../neo4j-ruby-driver'

gem 'listen', '< 3.1'

active_model_version = ENV['ACTIVE_MODEL_VERSION']
gem 'activemodel', "~> #{active_model_version}" if active_model_version&.length&.positive?

Expand Down
11 changes: 5 additions & 6 deletions activegraph.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ DESCRIPTION
'bug_tracker_uri' => 'https://github.com/neo4jrb/activegraph/issues'
}

s.add_dependency('activemodel', '>= 4.0')
s.add_dependency('activesupport', '>= 4.0')
s.add_dependency('activemodel', '>= 7')
s.add_dependency('i18n', '!= 1.8.8') # https://github.com/jruby/jruby/issues/6547
s.add_dependency('neo4j-ruby-driver', '>= 4.4.1')
s.add_dependency('orm_adapter', '~> 0.5.0')
s.add_dependency('neo4j-ruby-driver', '>= 4.4.1', '< 5')
s.add_dependency('orm_adapter', '>= 0.5.0')
s.add_dependency('sorted_set')
s.add_development_dependency('guard')
s.add_development_dependency('guard-rspec')
s.add_development_dependency('guard-rubocop')
s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
s.add_development_dependency('os')
s.add_development_dependency('pry')
s.add_development_dependency('railties', '>= 4.0')
s.add_development_dependency('railties', '>= 7')
s.add_development_dependency('rake')
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')
end
4 changes: 2 additions & 2 deletions docs/activegraph.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Usage: rails new myapp -m activegraph.rb

gem 'activegraph', '=> 11.1'
gem 'activegraph', '>= 11.1'

gem_group :development do
gem 'neo4j-rake_tasks'
Expand All @@ -12,7 +12,7 @@
END
end

gsub_file 'config/application.rb', "require 'rails'", ''
gsub_file 'config/application.rb', 'require "rails"', ''

generator = %q[
# Enable ActiveGraph generators, e.g: rails generate model Admin --parent User
Expand Down
155 changes: 36 additions & 119 deletions lib/active_graph.rb
Original file line number Diff line number Diff line change
@@ -1,125 +1,42 @@
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 '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)
require 'rails/generators'
require 'rails/generators/active_graph_generator'
end

require 'neo4j/driver'
require 'orm_adapter'
require 'rake'
require 'set'
require 'sorted_set'
require 'yaml'

loader = Zeitwerk::Loader.for_gem
loader.ignore(File.expand_path('rails', __dir__))
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
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

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
5 changes: 5 additions & 0 deletions lib/active_graph/core/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def each(&block)
@records&.each(&block) || super
end

## To avoid to_a on Neo4j::Driver::Result as that one does not call the above block
def to_a
map.to_a
end

def store
return if @records
keys
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.
2 changes: 0 additions & 2 deletions lib/active_graph/lazy_attribute_hash.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'active_model/attribute_set'

module ActiveGraph
class LazyAttributeHash < ActiveModel::LazyAttributeHash
def initialize(values, attr_list)
Expand Down
Loading