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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b51ea5b1c1c11aab62f08cfe08508130f65def1a3b527ddcaf9419140c4e12a
4
- data.tar.gz: 6518c572f6a4c14c733653acf1282c9b8473a8737b028a5695f93f953766f0bd
3
+ metadata.gz: a48865b552ec9fdcb51a032b9dbafacc7f63cb9f08b980fdb6ad512732132131
4
+ data.tar.gz: 369db06d98cada1d39d962dd88b3f265fd8d300ba96876716f503971bd6dc010
5
5
  SHA512:
6
- metadata.gz: 634966fdde2e4567654b9a2d3e77eb77b26b8d1c8def562deeef8015d0b798ef8c7a9dd993dd15eabeeac4e2cc32013b748649c3f599dcc524742edd67d0b252
7
- data.tar.gz: 9dba064e18ded1c51b80eca7d17cf487e1748b31fcbc18be656d57dcbe70954c563f3e7ee7bcd6ed847e4d9e170b40c0a498007980642349f1a4aa1ba5f0c706
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: Ruby
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.0.0
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.2.15
24
+ gem install bundler -v 2.4.10
25
25
  bundle install
26
26
  bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.3] - 2023-12-17
2
+
3
+ - Add ActiveSupport notifications
4
+
1
5
  ## [0.2.2] - 2022-05-15
2
6
 
3
7
  - Nodes allow multiple labels
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
@@ -8,6 +8,6 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "minitest", "~> 5.0"
11
+ gem "minitest-focus", "~> 1.4.0"
11
12
  gem "pry", "~> 0.14.0"
12
13
  gem "simplecov", "~> 0.21.2"
13
-
data/Gemfile.lock CHANGED
@@ -1,45 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redgraph (0.2.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.0.3)
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.1.10)
24
+ concurrent-ruby (1.2.2)
25
+ connection_pool (2.4.1)
18
26
  docile (1.3.5)
19
- i18n (1.10.0)
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.6.0)
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.4)
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.
@@ -99,7 +99,11 @@ module Redgraph
99
99
  private
100
100
 
101
101
  def _query(cmd)
102
- data = @connection.call("GRAPH.QUERY", graph_name, cmd, "--compact")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Redgraph
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
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
@@ -26,7 +26,7 @@ class GraphNodeMethodsTest < Minitest::Test
26
26
  end
27
27
 
28
28
  def test_find_node_by_wrong_id
29
- node = @graph.find_node_by_id("-1")
29
+ node = @graph.find_node_by_id(999999)
30
30
 
31
31
  assert_nil(node)
32
32
  end
@@ -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
@@ -65,7 +65,7 @@ class NodeModelClassMethodsTest < Minitest::Test
65
65
 
66
66
  def test_find_bad_id
67
67
  quick_add_node(label: 'actor', properties: {name: "Al Pacino"})
68
- item = Actor.find("-1")
68
+ item = Actor.find(999999)
69
69
  assert_nil(item)
70
70
  end
71
71
 
data/test/node_test.rb CHANGED
@@ -17,7 +17,7 @@ class NodeTest < Minitest::Test
17
17
 
18
18
  def test_conflicting_labels
19
19
  assert_raises(Redgraph::Error) do
20
- node = Redgraph::Node.new(labels: ["film", "drama"], label: "film")
20
+ Redgraph::Node.new(labels: ["film", "drama"], label: "film")
21
21
  end
22
22
  end
23
23
  end
data/test/test_helper.rb CHANGED
@@ -13,6 +13,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
13
13
  require "redgraph"
14
14
 
15
15
  require "minitest/autorun"
16
+ require "minitest/focus"
16
17
  require "pry"
17
18
 
18
19
  unless $REDIS_URL = ENV['TEST_REDIS_URL']
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.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: 2022-05-15 00:00:00.000000000 Z
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/main.yml"
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.2.22
109
+ rubygems_version: 3.4.10
108
110
  signing_key:
109
111
  specification_version: 4
110
112
  summary: A simple RedisGraph client