redisgraph 2.0.2 → 2.0.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: bdd856161112d91a2415f7e305acdd33942a07f7b904d29f5b944feaffa274d8
4
- data.tar.gz: 1e4b223e139602df62b95b3e9c05d6d7de4cf11ceb75c756032995e365133594
3
+ metadata.gz: 6d49963c89e143060931e2fc7a20c73a0fe41a06f0002ec84494e6182ad28728
4
+ data.tar.gz: 90b9a339ae932fcea45bbf355518e54db7ddcad137739d5d2ad95bcb72b5bd99
5
5
  SHA512:
6
- metadata.gz: da84d8a649e3b00a5c34a894787368d730327eeb8209c0cc15c229700e078bfbf6c32b4d6d29052baa7867b9439beb8186160e3f550501526f1879ee92aceb41
7
- data.tar.gz: 75f764f6989c5d2bcb379daae2646347d140447f89260935127ce7df80076418bb232c8ee035fa6ed0271d80e55eaa0bfafc71a9efa10d1a24a37aa529786b10
6
+ metadata.gz: d4b3bc2e45a843c4328786fc1ce99e07873f9f0d09de3773ca572491867ccdc9b0f06653830167160fcf4e036349150166262890cc783e180569faecfd43bc6b
7
+ data.tar.gz: 8a0f6138c785a35ede21619c98960e3bdf96a557b98cdb3a183f1ee41ad3f99890c1e011ac6588e49efab2bcaa4f998b44cd0a44aff222155b3d0ece2b10f803
@@ -0,0 +1,21 @@
1
+ name-template: 'Version $NEXT_PATCH_VERSION'
2
+ tag-template: 'v$NEXT_PATCH_VERSION'
3
+ categories:
4
+ - title: 'Features'
5
+ labels:
6
+ - 'feature'
7
+ - 'enhancement'
8
+ - title: 'Bug Fixes'
9
+ labels:
10
+ - 'fix'
11
+ - 'bugfix'
12
+ - 'bug'
13
+ - title: 'Maintenance'
14
+ label: 'chore'
15
+ change-template: '- $TITLE (#$NUMBER)'
16
+ exclude-labels:
17
+ - 'skip-changelog'
18
+ template: |
19
+ ## Changes
20
+
21
+ $CHANGES
@@ -0,0 +1,20 @@
1
+ name: Release Drafter
2
+
3
+ on:
4
+ push:
5
+ # branches to consider in the event; optional, defaults to all
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ update_release_draft:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ # Drafts your next Release notes as Pull Requests are merged into "master"
14
+ - uses: release-drafter/release-drafter@v5
15
+ with:
16
+ # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
17
+ config-name: release-drafter-config.yml
18
+ env:
19
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20
+
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'redis', '~> 4'
6
- gem 'terminal-table', '~> 1', '>= 1.8'
7
6
  gem 'rspec'
8
7
  gem 'codecov', :require => false, :group => :test
9
8
 
data/README.md CHANGED
@@ -2,10 +2,11 @@
2
2
  [![CircleCI](https://circleci.com/gh/RedisGraph/redisgraph-rb/tree/master.svg?style=svg)](https://circleci.com/gh/RedisGraph/redisgraph-rb/tree/master)
3
3
  [![GitHub issues](https://img.shields.io/github/release/RedisGraph/redisgraph-rb.svg)](https://github.com/RedisGraph/redisgraph-rb/releases/latest)
4
4
  [![Codecov](https://codecov.io/gh/RedisGraph/redisgraph-rb/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisGraph/redisgraph-rb)
5
+ [![Gem Version](https://badge.fury.io/rb/redisgraph.svg)](https://badge.fury.io/rb/redisgraph)
5
6
 
6
7
  # redisgraph-rb
7
8
  [![Forum](https://img.shields.io/badge/Forum-RedisGraph-blue)](https://forum.redislabs.com/c/modules/redisgraph)
8
- [![Gitter](https://badges.gitter.im/RedisLabs/RedisGraph.svg)](https://gitter.im/RedisLabs/RedisGraph?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
9
+ [![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/gWBRT6P)
9
10
 
10
11
  `redisgraph-rb` is a Ruby gem client for the [RedisGraph](https://github.com/RedisLabsModules/RedisGraph) module. It relies on `redis-rb` for Redis connection management and provides support for graph QUERY, EXPLAIN, and DELETE commands.
11
12
 
@@ -44,11 +45,11 @@ cmd = """MATCH ()-[:works]->(e:employer) RETURN e"""
44
45
  response = r.query(cmd)
45
46
 
46
47
  response.print_resultset
47
- +----------------+
48
- | e.name |
49
- +----------------+
50
- | Dunder Mifflin |
51
- +----------------+
48
+ --------------------------------
49
+ | e |
50
+ --------------------------------
51
+ | [{"name"=>"Dunder Mifflin"}] |
52
+ --------------------------------
52
53
 
53
54
  r.delete
54
55
  => "Graph removed, internal execution time: 0.416024 milliseconds"
@@ -1,19 +1,26 @@
1
1
  class RedisGraph
2
2
  def connect_to_server(options)
3
3
  @connection = Redis.new(options)
4
- @module_version = module_version()
5
- raise ServerError, "RedisGraph module not loaded." if @module_version.nil?
6
- raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if @module_version < 19900
4
+ check_module_version
7
5
  end
8
6
 
9
7
  # Ensure that the connected Redis server supports modules
10
8
  # and has loaded the RedisGraph module
11
- def module_version()
9
+ def check_module_version()
12
10
  redis_version = @connection.info["redis_version"]
13
11
  major_version = redis_version.split('.').first.to_i
14
12
  raise ServerError, "Redis 4.0 or greater required for RedisGraph support." unless major_version >= 4
15
- modules = @connection.call("MODULE", "LIST")
13
+
14
+ begin
15
+ modules = @connection.call("MODULE", "LIST")
16
+ rescue Redis::CommandError
17
+ # Ignore check if the connected server does not support the "MODULE LIST" command
18
+ return
19
+ end
20
+
16
21
  module_graph = modules.detect { |_name_key, name, _ver_key, _ver| name == 'graph' }
17
- module_graph[3] if module_graph
22
+ module_version = module_graph[3] if module_graph
23
+ raise ServerError, "RedisGraph module not loaded." if module_version.nil?
24
+ raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if module_version < 19900
18
25
  end
19
26
  end
@@ -39,10 +39,25 @@ class QueryResult
39
39
  def print_resultset
40
40
  return unless columns
41
41
 
42
- pretty = Terminal::Table.new headings: columns do |t|
43
- resultset.each { |record| t << record }
42
+ # Compute max length of each column
43
+ column_sizes = resultset.reduce([]) do |lengths, row|
44
+ row.each_with_index.map{|iterand, index| [lengths[index] || 0, iterand.to_s.length].max}
44
45
  end
45
- puts pretty
46
+
47
+ # Print column headers
48
+ puts head = '-' * (column_sizes.inject(&:+) + (3 * column_sizes.count) + 1)
49
+ row = columns.fill(nil, columns.size..(column_sizes.size - 1))
50
+ row = row.each_with_index.map{|v, i| v = v.to_s + ' ' * (column_sizes[i] - v.to_s.length)}
51
+ puts '| ' + row.join(' | ') + ' |'
52
+ puts head
53
+
54
+ # Print result set rows
55
+ resultset.each do |row|
56
+ row = row.fill(nil, row.size..(column_sizes.size - 1))
57
+ row = row.each_with_index.map{|v, i| v = v.to_s + ' ' * (column_sizes[i] - v.to_s.length)}
58
+ puts '| ' + row.join(' | ') + ' |'
59
+ end
60
+ puts head
46
61
  end
47
62
 
48
63
  def parse_resultset(response)
@@ -1,3 +1,3 @@
1
1
  class RedisGraph
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
data/lib/redisgraph.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'redis'
2
- require 'terminal-table'
3
2
 
4
3
  require_relative 'redisgraph/errors.rb'
5
4
  require_relative 'redisgraph/query_result.rb'
data/redisgraph.gemspec CHANGED
@@ -20,5 +20,4 @@ Gem::Specification.new do |s|
20
20
  s.files = `git ls-files`.split("\n")
21
21
 
22
22
  s.add_runtime_dependency('redis', '~> 4')
23
- s.add_runtime_dependency('terminal-table', '~> 1', '>= 1.8')
24
23
  end
@@ -89,7 +89,7 @@ describe RedisGraph do
89
89
  it "should print property strings correctly after updates" do
90
90
  q = """MATCH (a {name: 'src1'}) RETURN a"""
91
91
  res = @r.query(q)
92
- expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>TRUE}]]])
92
+ expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>true}]]])
93
93
  end
94
94
  end
95
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redisgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redis Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-09 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -24,26 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4'
27
- - !ruby/object:Gem::Dependency
28
- name: terminal-table
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: '1.8'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '1.8'
47
27
  description: A client that extends redis-rb to provide explicit support for the RedisGraph
48
28
  module.
49
29
  email: jeffrey@redislabs.com
@@ -52,6 +32,8 @@ extensions: []
52
32
  extra_rdoc_files: []
53
33
  files:
54
34
  - ".circleci/config.yml"
35
+ - ".github/release-drafter-config.yml"
36
+ - ".github/workflows/release-drafter.yml"
55
37
  - ".gitignore"
56
38
  - Gemfile
57
39
  - LICENSE
@@ -84,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
66
  - !ruby/object:Gem::Version
85
67
  version: '0'
86
68
  requirements: []
87
- rubygems_version: 3.0.8
69
+ rubygems_version: 3.2.22
88
70
  signing_key:
89
71
  specification_version: 4
90
72
  summary: A client for RedisGraph