redgraph 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/tests-falkordb.yml +26 -0
- data/.github/workflows/{main.yml → tests-redisgraph.yml} +3 -3
- data/CHANGELOG.md +4 -0
- data/CHEATSHEET.md +13 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +22 -6
- data/README.md +23 -0
- data/lib/redgraph/graph.rb +5 -1
- data/lib/redgraph/version.rb +1 -1
- data/lib/redgraph.rb +4 -0
- data/test/graph_node_methods_test.rb +1 -1
- data/test/graph_queries_test.rb +11 -0
- data/test/node_model_class_methods_test.rb +1 -1
- data/test/node_test.rb +1 -1
- data/test/test_helper.rb +1 -0
- metadata +6 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a48865b552ec9fdcb51a032b9dbafacc7f63cb9f08b980fdb6ad512732132131
         | 
| 4 | 
            +
              data.tar.gz: 369db06d98cada1d39d962dd88b3f265fd8d300ba96876716f503971bd6dc010
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cd8fca4012fd1392201c28496e90201c90819d8dd7ac988c71daeb5a7ce3e3d21c7c6249a1c2ef3af3025b7e8afcfde6de4ecf1d88f930960a3784b4701084ac
         | 
| 7 | 
            +
              data.tar.gz: 77c95eff0ef122edb13a8644467510477c703b16d97d155b2938de38d9ed70dd59d4d8cfda5173bfec41a8caf2f6a0b255287a55e0f466983ab6c9b2ee7deacb
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            name: Test with FalkorDB
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            on: [push,pull_request]
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            jobs:
         | 
| 6 | 
            +
              build:
         | 
| 7 | 
            +
                runs-on: ubuntu-latest
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                services:
         | 
| 10 | 
            +
                  redis:
         | 
| 11 | 
            +
                    image: falkordb/falkordb
         | 
| 12 | 
            +
                    ports: ["6379:6379"]
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                steps:
         | 
| 15 | 
            +
                - uses: actions/checkout@v2
         | 
| 16 | 
            +
                - name: Set up Ruby
         | 
| 17 | 
            +
                  uses: ruby/setup-ruby@v1
         | 
| 18 | 
            +
                  with:
         | 
| 19 | 
            +
                    ruby-version: 3.2.2
         | 
| 20 | 
            +
                - name: Run the default task
         | 
| 21 | 
            +
                  env:
         | 
| 22 | 
            +
                    TEST_REDIS_URL: redis://localhost:6379/0
         | 
| 23 | 
            +
                  run: |
         | 
| 24 | 
            +
                    gem install bundler -v 2.4.10
         | 
| 25 | 
            +
                    bundle install
         | 
| 26 | 
            +
                    bundle exec rake
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            name:  | 
| 1 | 
            +
            name: Test with RedisGraph
         | 
| 2 2 |  | 
| 3 3 | 
             
            on: [push,pull_request]
         | 
| 4 4 |  | 
| @@ -16,11 +16,11 @@ jobs: | |
| 16 16 | 
             
                - name: Set up Ruby
         | 
| 17 17 | 
             
                  uses: ruby/setup-ruby@v1
         | 
| 18 18 | 
             
                  with:
         | 
| 19 | 
            -
                    ruby-version: 3. | 
| 19 | 
            +
                    ruby-version: 3.2.2
         | 
| 20 20 | 
             
                - name: Run the default task
         | 
| 21 21 | 
             
                  env:
         | 
| 22 22 | 
             
                    TEST_REDIS_URL: redis://localhost:6379/0
         | 
| 23 23 | 
             
                  run: |
         | 
| 24 | 
            -
                    gem install bundler -v 2. | 
| 24 | 
            +
                    gem install bundler -v 2.4.10
         | 
| 25 25 | 
             
                    bundle install
         | 
| 26 26 | 
             
                    bundle exec rake
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/CHEATSHEET.md
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            # Cheatsheet
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Add node
         | 
| 4 | 
            +
            ```
         | 
| 5 | 
            +
            GRAPH.QUERY movies "CREATE(:actor {name: 'Al Pacino'})"
         | 
| 6 | 
            +
            GRAPH.QUERY movies "CREATE(:actor {name: 'John Travolta'})"
         | 
| 7 | 
            +
            ```
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Query graph
         | 
| 10 | 
            +
            ```
         | 
| 11 | 
            +
            GRAPH.QUERY movies "MATCH (n) RETURN n"
         | 
| 12 | 
            +
            GRAPH.QUERY movies "MATCH (n) WHERE ID(n) = 1  RETURN n"
         | 
| 13 | 
            +
            ```
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,45 +1,61 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                redgraph (0.2. | 
| 4 | 
            +
                redgraph (0.2.3)
         | 
| 5 5 | 
             
                  activesupport (>= 3.0.0)
         | 
| 6 6 | 
             
                  redis (~> 4)
         | 
| 7 7 |  | 
| 8 8 | 
             
            GEM
         | 
| 9 9 | 
             
              remote: https://rubygems.org/
         | 
| 10 10 | 
             
              specs:
         | 
| 11 | 
            -
                activesupport (7. | 
| 11 | 
            +
                activesupport (7.1.2)
         | 
| 12 | 
            +
                  base64
         | 
| 13 | 
            +
                  bigdecimal
         | 
| 12 14 | 
             
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         | 
| 15 | 
            +
                  connection_pool (>= 2.2.5)
         | 
| 16 | 
            +
                  drb
         | 
| 13 17 | 
             
                  i18n (>= 1.6, < 2)
         | 
| 14 18 | 
             
                  minitest (>= 5.1)
         | 
| 19 | 
            +
                  mutex_m
         | 
| 15 20 | 
             
                  tzinfo (~> 2.0)
         | 
| 21 | 
            +
                base64 (0.2.0)
         | 
| 22 | 
            +
                bigdecimal (3.1.5)
         | 
| 16 23 | 
             
                coderay (1.1.3)
         | 
| 17 | 
            -
                concurrent-ruby (1. | 
| 24 | 
            +
                concurrent-ruby (1.2.2)
         | 
| 25 | 
            +
                connection_pool (2.4.1)
         | 
| 18 26 | 
             
                docile (1.3.5)
         | 
| 19 | 
            -
                 | 
| 27 | 
            +
                drb (2.2.0)
         | 
| 28 | 
            +
                  ruby2_keywords
         | 
| 29 | 
            +
                i18n (1.14.1)
         | 
| 20 30 | 
             
                  concurrent-ruby (~> 1.0)
         | 
| 21 31 | 
             
                method_source (1.0.0)
         | 
| 22 32 | 
             
                minitest (5.14.4)
         | 
| 33 | 
            +
                minitest-focus (1.4.0)
         | 
| 34 | 
            +
                  minitest (>= 4, < 6)
         | 
| 35 | 
            +
                mutex_m (0.2.0)
         | 
| 23 36 | 
             
                pry (0.14.0)
         | 
| 24 37 | 
             
                  coderay (~> 1.1)
         | 
| 25 38 | 
             
                  method_source (~> 1.0)
         | 
| 26 39 | 
             
                rake (13.0.3)
         | 
| 27 | 
            -
                redis (4. | 
| 40 | 
            +
                redis (4.8.1)
         | 
| 41 | 
            +
                ruby2_keywords (0.0.5)
         | 
| 28 42 | 
             
                simplecov (0.21.2)
         | 
| 29 43 | 
             
                  docile (~> 1.1)
         | 
| 30 44 | 
             
                  simplecov-html (~> 0.11)
         | 
| 31 45 | 
             
                  simplecov_json_formatter (~> 0.1)
         | 
| 32 46 | 
             
                simplecov-html (0.12.3)
         | 
| 33 47 | 
             
                simplecov_json_formatter (0.1.2)
         | 
| 34 | 
            -
                tzinfo (2.0. | 
| 48 | 
            +
                tzinfo (2.0.6)
         | 
| 35 49 | 
             
                  concurrent-ruby (~> 1.0)
         | 
| 36 50 |  | 
| 37 51 | 
             
            PLATFORMS
         | 
| 38 52 | 
             
              arm64-darwin-21
         | 
| 53 | 
            +
              arm64-darwin-23
         | 
| 39 54 | 
             
              x86_64-darwin-20
         | 
| 40 55 |  | 
| 41 56 | 
             
            DEPENDENCIES
         | 
| 42 57 | 
             
              minitest (~> 5.0)
         | 
| 58 | 
            +
              minitest-focus (~> 1.4.0)
         | 
| 43 59 | 
             
              pry (~> 0.14.0)
         | 
| 44 60 | 
             
              rake (~> 13.0)
         | 
| 45 61 | 
             
              redgraph!
         | 
    
        data/README.md
    CHANGED
    
    | @@ -5,6 +5,18 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            A simple RedisGraph library. This gem owes **a lot** to the existing [redisgraph-rb](https://github.com/RedisGraph/redisgraph-rb) gem, but tries to provide a friendlier interface, similar to the existing [Python](https://github.com/RedisGraph/redisgraph-py) and [Elixir](https://github.com/crflynn/redisgraph-ex) clients.
         | 
| 7 7 |  | 
| 8 | 
            +
            ## July 2023 update:
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Sadly RedisGraph is no longer in active development. More info [here](https://redis.com/blog/redisgraph-eol/).
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ## Nov 2023 update:
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            There is an active fork, [FalkorDB](https://github.com/FalkorDB/FalkorDB/). AFAIK at this time there are no arm64 builds available.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            ## Dec 2023 update:
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            FalkorDB has arm64 builds now.
         | 
| 19 | 
            +
             | 
| 8 20 | 
             
            ## Installation
         | 
| 9 21 |  | 
| 10 22 | 
             
            Add this line to your application's Gemfile:
         | 
| @@ -152,6 +164,10 @@ Actor.query("MATCH (node) RETURN node ORDER BY node.name") | |
| 152 164 | 
             
            ```
         | 
| 153 165 | 
             
            And the result rows object will be instances of the classes defined by the `_type` attribute.
         | 
| 154 166 |  | 
| 167 | 
            +
            ### Notifications
         | 
| 168 | 
            +
             | 
| 169 | 
            +
            You can optionally subscribe to `redgraph.query` ActiveSupport notifications.
         | 
| 170 | 
            +
             | 
| 155 171 | 
             
            ## Development
         | 
| 156 172 |  | 
| 157 173 | 
             
            After checking out the repo, run `bin/setup` to install dependencies. Then, run 
         | 
| @@ -171,6 +187,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. | |
| 171 187 | 
             
            If you're using an Apple silicon mac you might want to use the docker image: I've had issues compiling the module (OpenMP problems). Just do a:
         | 
| 172 188 |  | 
| 173 189 | 
             
                docker run -p 6380:6379 -it --rm redislabs/redisgraph
         | 
| 190 | 
            +
             | 
| 191 | 
            +
            or, to try FalkorDB
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                docker run -p 6380:6379 -it --rm falkordb/falkordb:edge
         | 
| 194 | 
            +
             | 
| 195 | 
            +
            and then
         | 
| 196 | 
            +
             | 
| 174 197 | 
             
                TEST_REDIS_URL=redis://localhost:6380/0 be rake test
         | 
| 175 198 |  | 
| 176 199 | 
             
            I'm using port 6380 to not interphere with the other redis instance.
         | 
    
        data/lib/redgraph/graph.rb
    CHANGED
    
    | @@ -99,7 +99,11 @@ module Redgraph | |
| 99 99 | 
             
                private
         | 
| 100 100 |  | 
| 101 101 | 
             
                def _query(cmd)
         | 
| 102 | 
            -
                  data =  | 
| 102 | 
            +
                  data = nil
         | 
| 103 | 
            +
                  query = ["GRAPH.QUERY", graph_name, cmd, "--compact"]
         | 
| 104 | 
            +
                  ActiveSupport::Notifications.instrument(NOTIFICATIONS_KEY, query: query.join(' ')) do
         | 
| 105 | 
            +
                    data = @connection.call(*query)
         | 
| 106 | 
            +
                  end
         | 
| 103 107 | 
             
                  QueryResponse.new(data, self)
         | 
| 104 108 | 
             
                end
         | 
| 105 109 | 
             
              end
         | 
    
        data/lib/redgraph/version.rb
    CHANGED
    
    
    
        data/lib/redgraph.rb
    CHANGED
    
    | @@ -4,6 +4,8 @@ require "active_support/core_ext/hash/indifferent_access" | |
| 4 4 | 
             
            require "active_support/core_ext/object/blank"
         | 
| 5 5 | 
             
            require "active_support/core_ext/string/inflections"
         | 
| 6 6 | 
             
            require "active_support/concern"
         | 
| 7 | 
            +
            require 'active_support/notifications'
         | 
| 8 | 
            +
            require 'active_support/isolated_execution_state'
         | 
| 7 9 |  | 
| 8 10 | 
             
            require_relative "redgraph/version"
         | 
| 9 11 | 
             
            require_relative "redgraph/util"
         | 
| @@ -14,6 +16,8 @@ require_relative "redgraph/query_response" | |
| 14 16 | 
             
            require_relative "redgraph/node_model"
         | 
| 15 17 |  | 
| 16 18 | 
             
            module Redgraph
         | 
| 19 | 
            +
              NOTIFICATIONS_KEY = "redgraph.query".freeze
         | 
| 20 | 
            +
             | 
| 17 21 | 
             
              class Error < StandardError; end
         | 
| 18 22 | 
             
              class ServerError < Error; end
         | 
| 19 23 | 
             
              class MissingAliasPrefixError < Error
         | 
    
        data/test/graph_queries_test.rb
    CHANGED
    
    | @@ -42,4 +42,15 @@ class GraphQueriesTest < Minitest::Test | |
| 42 42 | 
             
                result = @graph.query("MATCH (src)-[edge:FRIEND_OF]->(dest) RETURN src, edge")
         | 
| 43 43 | 
             
                assert_equal([[@al, edge]], result)
         | 
| 44 44 | 
             
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def test_query_notifications
         | 
| 47 | 
            +
                payload = nil
         | 
| 48 | 
            +
                subscription = ActiveSupport::Notifications.subscribe Redgraph::NOTIFICATIONS_KEY do |name, start, finish, id, _payload|
         | 
| 49 | 
            +
                  payload = _payload
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                query = "MATCH (n) RETURN n.name ORDER BY n.name"
         | 
| 53 | 
            +
                result = @graph.query(query)
         | 
| 54 | 
            +
                assert_includes(payload[:query], query)
         | 
| 55 | 
            +
              end
         | 
| 45 56 | 
             
            end
         | 
    
        data/test/node_test.rb
    CHANGED
    
    
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: redgraph
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Paolo Zaccagnini
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2023-12-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: redis
         | 
| @@ -45,9 +45,11 @@ executables: [] | |
| 45 45 | 
             
            extensions: []
         | 
| 46 46 | 
             
            extra_rdoc_files: []
         | 
| 47 47 | 
             
            files:
         | 
| 48 | 
            -
            - ".github/workflows/ | 
| 48 | 
            +
            - ".github/workflows/tests-falkordb.yml"
         | 
| 49 | 
            +
            - ".github/workflows/tests-redisgraph.yml"
         | 
| 49 50 | 
             
            - ".gitignore"
         | 
| 50 51 | 
             
            - CHANGELOG.md
         | 
| 52 | 
            +
            - CHEATSHEET.md
         | 
| 51 53 | 
             
            - Gemfile
         | 
| 52 54 | 
             
            - Gemfile.lock
         | 
| 53 55 | 
             
            - LICENSE.txt
         | 
| @@ -104,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 104 106 | 
             
                - !ruby/object:Gem::Version
         | 
| 105 107 | 
             
                  version: '0'
         | 
| 106 108 | 
             
            requirements: []
         | 
| 107 | 
            -
            rubygems_version: 3. | 
| 109 | 
            +
            rubygems_version: 3.4.10
         | 
| 108 110 | 
             
            signing_key:
         | 
| 109 111 | 
             
            specification_version: 4
         | 
| 110 112 | 
             
            summary: A simple RedisGraph client
         |