rexpro 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 308c2cbddd465d7c79555e519b7a9af6c2fb8f0a
4
+ data.tar.gz: 811346f26a03c3a18d68d8b8cf870fd5d032aca8
5
+ SHA512:
6
+ metadata.gz: d1a0595fec310bcbb61116ccda3110298b7567c437f49856c428bdfc15c52bd25f03a70f0f9541b296ead55a1a8cdfd7fe09d11e691dc3e61ff841540f6ed959
7
+ data.tar.gz: 7b89cc9bf3fb18f963d016e76bcfe77ba1065c6ce5bebc41d79cbfd8b1538b0f66968021da2f8ef9c91a3f6044609c0b4020ee892a20cf4bc16129c85d32c5ec
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ before_script: rake run_rexster && sleep 10
3
+ script: rake test
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
data/README.md CHANGED
@@ -1,11 +1,18 @@
1
1
  # Rexpro
2
2
 
3
- *This is an early release and should not be considered stable!*
3
+ [![Build Status](https://travis-ci.org/lann/rexpro-ruby.png)](https://travis-ci.org/lann/rexpro-ruby)
4
+
5
+ Tested against rexster-server-2.4.0 on Ruby 1.9.3 and 2.0.0.
4
6
 
5
7
  https://github.com/tinkerpop/rexster/wiki/RexPro
6
8
 
7
9
  ## Installation
8
10
 
11
+ **NOTE: Version 1.0.0 breaks compatibility with rexster-server <2.4!**
12
+
13
+ Use gem versions <1.0.0 for older versions of rexster, or follow the protocol-0
14
+ branch, which may still recieve critical updates.
15
+
9
16
  Add this line to your application's Gemfile:
10
17
 
11
18
  gem 'rexpro'
data/Rakefile CHANGED
@@ -21,3 +21,26 @@ Rake::TestTask.new do |test|
21
21
  test.verbose = true
22
22
  test.test_files = ['spec/**/*_spec.rb']
23
23
  end
24
+
25
+ REXSTER_SERVER_URL = 'http://tinkerpop.com/downloads/rexster/rexster-server-2.4.0.zip'
26
+
27
+ desc 'Install and run rexster-server'
28
+ task :run_rexster do
29
+ tmpdir = File.expand_path('../tmp', __FILE__)
30
+ rexster_filename = File.join(tmpdir, 'rexster-server.zip')
31
+
32
+ unless File.exists? rexster_filename
33
+ FileUtils.mkdir_p tmpdir
34
+ sh "wget '#{REXSTER_SERVER_URL}' -O '#{rexster_filename}'"
35
+ end
36
+
37
+ rexster_glob = File.join(tmpdir, 'rexster-server-*/bin')
38
+
39
+ if Dir[rexster_glob].empty?
40
+ sh "unzip '#{rexster_filename}' -d '#{tmpdir}'"
41
+ end
42
+
43
+ Dir.chdir(File.join(Dir[rexster_glob].first, '..')) do
44
+ sh 'nohup bin/rexster.sh -s > rexster.log &'
45
+ end
46
+ end
@@ -15,7 +15,7 @@ module Rexpro
15
15
  @port = opts.delete(:port) || DEFAULT_PORT
16
16
 
17
17
  @request_opts = {}
18
- [:channel, :graph_name, :graph_obj_name].each do |key|
18
+ [:graph_name, :graph_obj_name].each do |key|
19
19
  value = opts.delete(key)
20
20
  @request_opts[key] = value if value
21
21
  end
@@ -62,7 +62,7 @@ module Rexpro
62
62
  opts = @request_opts.merge(opts)
63
63
  req = Rexpro::Message::SessionRequest.new(opts)
64
64
  resp = request(req)
65
- Rexpro::Session.new(self, resp.session_uuid, req.channel, resp.languages)
65
+ Rexpro::Session.new(self, resp.session_uuid, resp.languages)
66
66
  end
67
67
 
68
68
  def execute(script, opts = {})
@@ -5,21 +5,18 @@ require 'uuid'
5
5
 
6
6
  module Rexpro
7
7
  module Message
8
- PROTOCOL_VERSION = 0
8
+ PROTOCOL_VERSION = 1
9
9
 
10
- ZERO_UUID = [0, 0, 0, 0].pack('NNNN')
10
+ SERIALIZER_MSGPACK = 0
11
+ SERIALIZER_JSON = 1
11
12
 
12
- TYPE_ERROR = 0
13
- TYPE_SESSION_REQUEST = 1
14
- TYPE_SESSION_RESPONSE = 2
15
- TYPE_SCRIPT_REQUEST = 3
16
- TYPE_CONSOLE_SCRIPT_RESPONSE = 4
17
- TYPE_MSGPACK_SCRIPT_RESPONSE = 5
18
- TYPE_GRAPHSON_SCRIPT_RESPONSE = 6
13
+ ZERO_UUID = [0, 0, 0, 0].pack('NNNN')
19
14
 
20
- CHANNEL_CONSOLE = 1
21
- CHANNEL_MSGPACK = 2
22
- CHANNEL_GRAPHSON = 3
15
+ TYPE_ERROR = 0
16
+ TYPE_SESSION_REQUEST = 1
17
+ TYPE_SESSION_RESPONSE = 2
18
+ TYPE_SCRIPT_REQUEST = 3
19
+ TYPE_SCRIPT_RESPONSE = 5
23
20
 
24
21
  class << self
25
22
  def generate_uuid
@@ -39,12 +36,12 @@ module Rexpro
39
36
  raise RexproException, "Unknown protocol version #{version}"
40
37
  end
41
38
 
42
- header = io.read(5)
43
- if header.nil? || header.size < 5
39
+ header = io.read(10)
40
+ if header.nil? || header.size < 10
44
41
  raise RexproException, "Unexpected EOF: #{header.inspect}"
45
42
  end
46
43
 
47
- type, size = header.unpack('CN')
44
+ serializer_type, reserved, type, size = header.unpack('CNCN')
48
45
  type_class = types[type]
49
46
  unless type_class
50
47
  raise RexproException, "Unknown message type #{type}"
@@ -65,6 +62,8 @@ module Rexpro
65
62
  memo
66
63
  end
67
64
 
65
+ attrs[:serializer_type] = serializer_type
66
+
68
67
  type_class.new(attrs)
69
68
  end
70
69
  end
@@ -113,14 +112,21 @@ module Rexpro
113
112
  end
114
113
  end
115
114
 
115
+ attr_reader :serializer_type
116
+
116
117
  def initialize(attrs = {})
118
+ @serializer_type = attrs.delete(:serializer_type) || SERIALIZER_MSGPACK
117
119
  self.meta ||= {}
118
120
  attrs.each { |k, v| send("#{k}=", v) }
119
121
  self.session_uuid ||= ZERO_UUID
120
122
  self.request_uuid ||= Message.generate_uuid
121
123
  end
122
124
 
123
- def to_msgpack(*args)
125
+ def serialize_body(*args)
126
+ if serializer_type != SERIALIZER_MSGPACK
127
+ raise NotImplementedError, 'only MsgPack serialization is supported'
128
+ end
129
+
124
130
  self.class.fields.map do |field|
125
131
  value = send(field)
126
132
  field_method = self.class.field_methods[field]
@@ -130,8 +136,10 @@ module Rexpro
130
136
  end
131
137
 
132
138
  def write_to(io)
133
- body = to_msgpack
134
- header = [PROTOCOL_VERSION, self.class.type, body.size].pack('CCN')
139
+ body = serialize_body
140
+ header = [
141
+ PROTOCOL_VERSION, serializer_type, 0, self.class.type, body.size
142
+ ].pack('CCNCN')
135
143
  io.write(header)
136
144
  io.write(body)
137
145
  end
@@ -147,13 +155,8 @@ module Rexpro
147
155
  class SessionRequest
148
156
  include Base
149
157
  self.type = TYPE_SESSION_REQUEST
150
- define_fields channel: :to_i, username: :to_s, password: :to_s
158
+ define_fields username: :to_s, password: :to_s
151
159
  define_meta_fields :graph_name, :graph_obj_name, :kill_session
152
-
153
- def initialize(*_)
154
- super
155
- self.channel ||= CHANNEL_MSGPACK
156
- end
157
160
  end
158
161
 
159
162
  class SessionResponse
@@ -167,33 +170,20 @@ module Rexpro
167
170
  include Base
168
171
  self.type = TYPE_SCRIPT_REQUEST
169
172
  define_fields language_name: :to_s, script: :to_s, bindings: :to_hash
170
- define_meta_fields :channel, :in_session, :isolate, :transaction,
173
+ define_meta_fields :in_session, :isolate, :transaction,
171
174
  :graph_name, :graph_obj_name
172
175
 
173
176
  def initialize(*_)
174
177
  super
175
178
  self.language_name ||= 'groovy'
176
179
  self.bindings ||= {}
177
- self.channel ||= CHANNEL_MSGPACK
178
180
  end
179
181
  end
180
182
 
181
- class ConsoleScriptResponse
182
- include Base
183
- self.type = TYPE_CONSOLE_SCRIPT_RESPONSE
184
- define_fields console_lines: :to_a, bindings: :to_hash
185
- end
186
-
187
- class MsgpackScriptResponse
183
+ class ScriptResponse
188
184
  include Base
189
- self.type = TYPE_MSGPACK_SCRIPT_RESPONSE
185
+ self.type = TYPE_SCRIPT_RESPONSE
190
186
  define_fields results: nil, bindings: :to_hash
191
187
  end
192
-
193
- class GraphsonScriptResponse
194
- include Base
195
- self.type = TYPE_GRAPHSON_SCRIPT_RESPONSE
196
- define_fields results: :to_s, bindings: :to_hash
197
- end
198
188
  end
199
189
  end
@@ -1,10 +1,10 @@
1
1
  require 'rexpro'
2
2
 
3
3
  class Rexpro::Session
4
- attr_reader :client, :uuid, :channel, :languages
4
+ attr_reader :client, :uuid, :languages
5
5
 
6
- def initialize(client, uuid, channel, languages = nil)
7
- @client, @uuid, @channel, @languages = client, uuid, channel, languages
6
+ def initialize(client, uuid, languages = nil)
7
+ @client, @uuid, @languages = client, uuid, languages
8
8
  end
9
9
 
10
10
  def kill
@@ -15,7 +15,7 @@ class Rexpro::Session
15
15
 
16
16
  def execute(script, attrs = {})
17
17
  attrs = attrs.merge(
18
- session_uuid: uuid, channel: channel, in_session: true, script: script)
18
+ session_uuid: uuid, in_session: true, script: script)
19
19
  msg = Rexpro::Message::ScriptRequest.new(attrs)
20
20
  client.request(msg)
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module Rexpro
2
- VERSION = "0.0.6"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -16,6 +16,14 @@ DESC
16
16
  spec.homepage = "https://github.com/lann/rexpro-ruby"
17
17
  spec.license = "MIT"
18
18
 
19
+ spec.post_install_message = <<-MESSAGE
20
+
21
+ ! ***UPDGRADE WARNING***
22
+ ! rexpro-ruby 1.x breaks compatibility with rexster-server-2.3 and below.
23
+ ! Continue using 0.x versions if you cannot upgrade rexster.
24
+
25
+ MESSAGE
26
+
19
27
  spec.files = `git ls-files`.split($/)
20
28
  spec.test_files = spec.files.grep(%r{^spec/})
21
29
  spec.require_paths = ["lib"]
@@ -19,8 +19,8 @@ describe Rexpro::Message do
19
19
  end
20
20
 
21
21
  describe '.read_from' do
22
- let(:data) { "\x00\x00\x00\x00\x00/\x94\xB01234567812345678" +
23
- "\xB0abcdefghijklmnop\x81\xA4flag\a\xA4boom" }
22
+ let(:data) { "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00/\x94\xB0" +
23
+ "1234567812345678\xB0abcdefghijklmnop\x81\xA4flag\a\xA4boom" }
24
24
  let(:io) { StringIO.new data }
25
25
  let(:msg) { Rexpro::Message.read_from(io) }
26
26
 
@@ -50,8 +50,8 @@ describe Rexpro::Message::SessionRequest do
50
50
  it 'correctly writes to the io object' do
51
51
  subject.session_uuid = 'abcdefghijklmnop'
52
52
  subject.write_to(io)
53
- io.string.must_equal "\x00\x01\x00\x00\x00'\x96\xB0abcdefghijklmnop" +
54
- "\xB01234567812345678\x80\x02\xA0\xA0"
53
+ io.string.must_equal "\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00&\x95\xB0abcdefghijklmnop" +
54
+ "\xB01234567812345678\x80\xA0\xA0"
55
55
  end
56
56
 
57
57
  it 'is symmetrical with .read_from' do
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexpro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lann Martin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-13 00:00:00.000000000 Z
11
+ date: 2013-08-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: msgpack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: uuid
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: tcp_timeout
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,17 +69,15 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: RexPro, a binary protocol for Rexster
@@ -99,6 +88,7 @@ extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
101
90
  - .gitignore
91
+ - .travis.yml
102
92
  - Gemfile
103
93
  - LICENSE.txt
104
94
  - README.md
@@ -117,27 +107,31 @@ files:
117
107
  homepage: https://github.com/lann/rexpro-ruby
118
108
  licenses:
119
109
  - MIT
120
- post_install_message:
110
+ metadata: {}
111
+ post_install_message: |2+
112
+
113
+ ! ***UPDGRADE WARNING***
114
+ ! rexpro-ruby 1.x breaks compatibility with rexster-server-2.3 and below.
115
+ ! Continue using 0.x versions if you cannot upgrade rexster.
116
+
121
117
  rdoc_options: []
122
118
  require_paths:
123
119
  - lib
124
120
  required_ruby_version: !ruby/object:Gem::Requirement
125
- none: false
126
121
  requirements:
127
- - - ! '>='
122
+ - - '>='
128
123
  - !ruby/object:Gem::Version
129
124
  version: '0'
130
125
  required_rubygems_version: !ruby/object:Gem::Requirement
131
- none: false
132
126
  requirements:
133
- - - ! '>='
127
+ - - '>='
134
128
  - !ruby/object:Gem::Version
135
129
  version: '0'
136
130
  requirements: []
137
131
  rubyforge_project:
138
- rubygems_version: 1.8.23
132
+ rubygems_version: 2.0.3
139
133
  signing_key:
140
- specification_version: 3
134
+ specification_version: 4
141
135
  summary: RexPro is a binary protocol for Rexster that can be used to send Gremlin
142
136
  scripts to a remote Rexster instance.
143
137
  test_files: