mylk 0.1.0
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 +7 -0
- data/.editorconfig +9 -0
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +16 -0
- data/lib/mylk/base.rb +66 -0
- data/lib/mylk/http.rb +75 -0
- data/lib/mylk/response.rb +22 -0
- data/lib/mylk/version.rb +5 -0
- data/lib/mylk/websocket.rb +113 -0
- data/lib/mylk.rb +8 -0
- data/mylk.gemspec +38 -0
- data/sig/mylk.rbs +31 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8cd7535fb4dab7f6534b2c3b12a5e8f1af9884a016fab89c3929e87609f1ca2b
|
4
|
+
data.tar.gz: '0927531fad655748a154d1d04c86423bbf418b69f2e2a78f6638a7eb6a9bd28f'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f24e7818672c0e1fe84c785d4e60ec9d5da33e7a132ff5bbaac925e51b619fadf9f5f53aa27868ed4c402bcb8f658c2239830eac35426b2feb8224ce728ddd63
|
7
|
+
data.tar.gz: bea072d18f45d0fee689b2ccd02e53295c640063f991c2654d6c74ca69a70f2ddb1974154dbe68303c4b5c2c281f65bdfc3b48c58b26c31c65ba25e74db4c2a4
|
data/.editorconfig
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## v0.1.2 (2023-02-22)
|
2
|
+
|
3
|
+
### Feat
|
4
|
+
|
5
|
+
- add type definitions
|
6
|
+
|
7
|
+
## v0.1.1 (2023-02-22)
|
8
|
+
|
9
|
+
### Fix
|
10
|
+
|
11
|
+
- **http**: ensure thread-safety
|
12
|
+
|
13
|
+
### Refactor
|
14
|
+
|
15
|
+
- rename gem to `surrealdb-client`
|
16
|
+
|
17
|
+
## v0.1.0 (2023-02-21)
|
18
|
+
|
19
|
+
### Feat
|
20
|
+
|
21
|
+
- implement websocket client (#2)
|
22
|
+
|
23
|
+
### Refactor
|
24
|
+
|
25
|
+
- rename `Websockets` to `Websocket`
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mylk (0.1.0)
|
5
|
+
websocket-client-simple (~> 0.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
event_emitter (0.2.6)
|
12
|
+
json (2.6.1)
|
13
|
+
minitest (5.16.3)
|
14
|
+
parallel (1.22.1)
|
15
|
+
parser (3.1.3.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
rainbow (3.1.1)
|
18
|
+
rake (13.0.6)
|
19
|
+
rbs (2.8.4)
|
20
|
+
regexp_parser (2.6.1)
|
21
|
+
rexml (3.2.5)
|
22
|
+
rubocop (1.41.1)
|
23
|
+
json (~> 2.3)
|
24
|
+
parallel (~> 1.10)
|
25
|
+
parser (>= 3.1.2.1)
|
26
|
+
rainbow (>= 2.2.2, < 4.0)
|
27
|
+
regexp_parser (>= 1.8, < 3.0)
|
28
|
+
rexml (>= 3.2.5, < 4.0)
|
29
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
30
|
+
ruby-progressbar (~> 1.7)
|
31
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
32
|
+
rubocop-ast (1.24.0)
|
33
|
+
parser (>= 3.1.1.0)
|
34
|
+
ruby-progressbar (1.11.0)
|
35
|
+
unicode-display_width (2.3.0)
|
36
|
+
websocket (1.2.9)
|
37
|
+
websocket-client-simple (0.6.0)
|
38
|
+
event_emitter
|
39
|
+
websocket
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
minitest (~> 5.0)
|
46
|
+
mylk!
|
47
|
+
rake (~> 13.0)
|
48
|
+
rbs (~> 2.8)
|
49
|
+
rubocop (~> 1.21)
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
2.3.26
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Rinat Shaykhutdinov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Mylk — The SurrealDB Ruby client
|
2
|
+
|
3
|
+
[](https://github.com/ri-nat/mylk/actions/workflows/main.yml)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add gem to the application's Gemfile:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem "mylk"
|
11
|
+
```
|
12
|
+
|
13
|
+
Install it:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Both the HTTP and WebSocket clients provide the same interface for executing commands. The only difference is the underlying transport mechanism.
|
22
|
+
|
23
|
+
If you are building concurrent (multi-threaded) applications, it is recommended to use the WebSocket client due to its superior performance. However, the HTTP client is still thread-safe and can also be used if you prefer.
|
24
|
+
|
25
|
+
### WebSocket Client
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require "mylk/websocket"
|
29
|
+
|
30
|
+
client = Mylk::WebSocket.new("surrealdb://root:root@localhost:8000/test/test").tap(&:connect)
|
31
|
+
response = client.execute("INFO FOR DB")
|
32
|
+
|
33
|
+
response.success? # => true
|
34
|
+
response.time # => "265.625µs"
|
35
|
+
response.result # => {"dl"=>{}, "dt"=>{}, "pa"=>{}, "sc"=>{}, "tb"=>{}}
|
36
|
+
```
|
37
|
+
|
38
|
+
### HTTP Client
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
require "mylk/http"
|
42
|
+
|
43
|
+
client = Mylk::HTTP.new("surrealdb://root:root@localhost:8000/test/test").tap(&:connect)
|
44
|
+
response = client.execute("INFO FOR DB")
|
45
|
+
|
46
|
+
response.success? # => true
|
47
|
+
response.time # => "265.625µs"
|
48
|
+
response.result # => {"dl"=>{}, "dt"=>{}, "pa"=>{}, "sc"=>{}, "tb"=>{}}
|
49
|
+
```
|
50
|
+
|
51
|
+
### Database connection string format
|
52
|
+
|
53
|
+
```text
|
54
|
+
surreal://<username>:<password>@<host>:<port>/<namespace>/<database>
|
55
|
+
```
|
56
|
+
|
57
|
+
## Development
|
58
|
+
|
59
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
60
|
+
|
61
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/ri-nat/mylk>.
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/lib/mylk/base.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mylk
|
4
|
+
# Base class for SurrealDB clients
|
5
|
+
class Base
|
6
|
+
attr_accessor :uri, :username, :password, :namespace, :database
|
7
|
+
|
8
|
+
# Parameters:
|
9
|
+
# uri: String
|
10
|
+
# The URI of the SurrealDB server
|
11
|
+
# Example: "http://user:password@localhost:8080/namespace/database"
|
12
|
+
def initialize(uri)
|
13
|
+
parse_connection_params(uri)
|
14
|
+
end
|
15
|
+
|
16
|
+
def connect
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
|
20
|
+
def disconnect
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
def connected?
|
25
|
+
!!@connected
|
26
|
+
end
|
27
|
+
|
28
|
+
def disconnected?
|
29
|
+
!connected?
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def endpoint_path
|
35
|
+
raise NotImplementedError
|
36
|
+
end
|
37
|
+
|
38
|
+
def endpoint_scheme
|
39
|
+
raise NotImplementedError
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_connection_params(url) # rubocop:disable Metrics/AbcSize
|
43
|
+
self.uri = URI(url)
|
44
|
+
self.username = uri.user
|
45
|
+
self.password = uri.password
|
46
|
+
self.namespace, self.database = uri.path.split("/")[1..2]
|
47
|
+
uri.path = endpoint_path
|
48
|
+
uri.scheme = endpoint_scheme
|
49
|
+
end
|
50
|
+
|
51
|
+
def format_error(response)
|
52
|
+
json = parse_json_body(response)
|
53
|
+
|
54
|
+
"Query failed with status code #{response.code}\n" \
|
55
|
+
"details: #{json["details"]}\n" \
|
56
|
+
"information: #{json["information"]}\n" \
|
57
|
+
"description: #{json["description"]}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_json_body(response)
|
61
|
+
JSON.parse(response.body)
|
62
|
+
rescue JSON::ParserError
|
63
|
+
raise Error, "Invalid JSON response from SurrealDB: #{response.body}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/mylk/http.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
require "net/http"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
require_relative "base"
|
8
|
+
|
9
|
+
module Mylk
|
10
|
+
# HTTP client for the SurrealDB
|
11
|
+
class HTTP < Base
|
12
|
+
def initialize(url)
|
13
|
+
super
|
14
|
+
|
15
|
+
@connection = Net::HTTP.new(uri.host, uri.port)
|
16
|
+
# Mutex to prevent multiple threads from using the same connection
|
17
|
+
@mutex = Mutex.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def connect
|
21
|
+
return true if connected?
|
22
|
+
|
23
|
+
@mutex.synchronize do
|
24
|
+
@connection.start
|
25
|
+
@connected = true
|
26
|
+
end
|
27
|
+
|
28
|
+
# Ping the server to check if the connection is established
|
29
|
+
execute("INFO FOR DB").success?
|
30
|
+
rescue Error
|
31
|
+
disconnect
|
32
|
+
end
|
33
|
+
|
34
|
+
def disconnect
|
35
|
+
return if disconnected?
|
36
|
+
|
37
|
+
@mutex.synchronize do
|
38
|
+
@connection.finish
|
39
|
+
@connected = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def execute(query) # rubocop:disable Metrics/AbcSize
|
44
|
+
connect if disconnected?
|
45
|
+
|
46
|
+
request = Net::HTTP::Post.new(uri.path, headers).tap { |r| r.body = query }
|
47
|
+
response = @mutex.synchronize { @connection.request(request) }
|
48
|
+
|
49
|
+
raise Error, format_error(response) unless (200..300).include?(response.code.to_i)
|
50
|
+
|
51
|
+
Response.new(parse_json_body(response).first)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def endpoint_path
|
57
|
+
"/sql"
|
58
|
+
end
|
59
|
+
|
60
|
+
def endpoint_scheme
|
61
|
+
"http"
|
62
|
+
end
|
63
|
+
|
64
|
+
def headers
|
65
|
+
@headers ||= {
|
66
|
+
"User-Agent" => "Mylk #{Mylk::VERSION}",
|
67
|
+
"Accept" => "application/json",
|
68
|
+
"Authorization" => "Basic #{Base64.strict_encode64("#{username}:#{password}")}",
|
69
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
70
|
+
"NS" => namespace,
|
71
|
+
"DB" => database
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mylk
|
4
|
+
# Response from the SurrealDB
|
5
|
+
class Response
|
6
|
+
attr_reader :result, :status, :time
|
7
|
+
|
8
|
+
def initialize(response)
|
9
|
+
@result = response["result"]
|
10
|
+
@status = response["status"]
|
11
|
+
@time = response["time"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def success?
|
15
|
+
@status == "OK"
|
16
|
+
end
|
17
|
+
|
18
|
+
def error?
|
19
|
+
!success?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/mylk/version.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "websocket-client-simple"
|
4
|
+
|
5
|
+
require_relative "base"
|
6
|
+
|
7
|
+
module Mylk
|
8
|
+
# WebSocket client for the SurrealDB
|
9
|
+
class WebSocket < Base
|
10
|
+
WAIT_SLEEP_DURATION = 0.001 # 1 millisecond
|
11
|
+
CONNECTION_TIMEOUT = 2 # 2 seconds
|
12
|
+
REQUEST_TIMEOUT = 2 # 2 seconds
|
13
|
+
|
14
|
+
def initialize(url)
|
15
|
+
super
|
16
|
+
|
17
|
+
@connection = nil
|
18
|
+
# Mutex to synchronize the access to the requests hash
|
19
|
+
@mutex = Mutex.new
|
20
|
+
@requests = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def connect
|
24
|
+
@connection = ::WebSocket::Client::Simple.connect(uri.to_s, headers: headers)
|
25
|
+
|
26
|
+
attach_on_message_handler
|
27
|
+
wait_for_connection_establishment
|
28
|
+
|
29
|
+
@connected = true
|
30
|
+
|
31
|
+
# Authenticate and select the database
|
32
|
+
call_rpc("signin", [{ user: username, pass: password }])
|
33
|
+
call_rpc("use", [namespace, database])
|
34
|
+
|
35
|
+
# Ping the server to check if the connection is established
|
36
|
+
execute("INFO FOR DB").success?
|
37
|
+
end
|
38
|
+
|
39
|
+
def disconnect
|
40
|
+
return if disconnected?
|
41
|
+
|
42
|
+
@connection.close
|
43
|
+
@connected = false
|
44
|
+
end
|
45
|
+
|
46
|
+
def execute(query)
|
47
|
+
Response.new(call_rpc("query", [query]))
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def call_rpc(method, params)
|
53
|
+
raise Error, "Not connected to SurrealDB" unless connected? || connect
|
54
|
+
|
55
|
+
request_id = SecureRandom.uuid
|
56
|
+
@connection.send({ id: request_id, method: method, params: params }.to_json)
|
57
|
+
|
58
|
+
Timeout.timeout(REQUEST_TIMEOUT) do
|
59
|
+
sleep WAIT_SLEEP_DURATION until @mutex.synchronize { @requests[request_id] }
|
60
|
+
end
|
61
|
+
|
62
|
+
@mutex.synchronize { @requests.delete(request_id) }
|
63
|
+
rescue Timeout::Error
|
64
|
+
raise Error, "Request to SurrealDB timed out"
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_message(parsed)
|
68
|
+
@mutex.synchronize do
|
69
|
+
@requests[parsed["id"]] = parsed["result"].is_a?(Array) ? parsed["result"].first : true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def attach_on_message_handler
|
74
|
+
am = method(:add_message)
|
75
|
+
|
76
|
+
@connection.on :message do |msg|
|
77
|
+
next if msg.data == ""
|
78
|
+
|
79
|
+
am.call(JSON.parse(msg.data))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def wait_for_connection_establishment
|
84
|
+
connected = false
|
85
|
+
@connection.on :open do
|
86
|
+
connected = true
|
87
|
+
end
|
88
|
+
|
89
|
+
# If the connection became opened before the handler was attached, we need to check it
|
90
|
+
connected ||= @connection.open?
|
91
|
+
|
92
|
+
Timeout.timeout(CONNECTION_TIMEOUT) do
|
93
|
+
sleep WAIT_SLEEP_DURATION until connected
|
94
|
+
end
|
95
|
+
rescue Timeout::Error
|
96
|
+
raise Error, "Connection to SurrealDB timed out"
|
97
|
+
end
|
98
|
+
|
99
|
+
def endpoint_path
|
100
|
+
"/rpc"
|
101
|
+
end
|
102
|
+
|
103
|
+
def endpoint_scheme
|
104
|
+
"ws"
|
105
|
+
end
|
106
|
+
|
107
|
+
def headers
|
108
|
+
{
|
109
|
+
"User-Agent" => "Mylk #{Mylk::VERSION}"
|
110
|
+
}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/mylk.rb
ADDED
data/mylk.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/mylk/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mylk"
|
7
|
+
spec.version = Mylk::VERSION
|
8
|
+
spec.authors = ["Rinat Shaykhutdinov"]
|
9
|
+
spec.email = ["mail@rinatshay.com"]
|
10
|
+
|
11
|
+
spec.summary = "SurrealDB client for Ruby (HTTP and WebSocket)"
|
12
|
+
spec.homepage = "https://github.com/ri-nat/mylk"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/ri-nat/mylk"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/ri-nat/mylk/CHANGELOG.md"
|
19
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency "websocket-client-simple", "~> 0.6"
|
33
|
+
|
34
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
36
|
+
spec.add_development_dependency "rbs", "~> 2.8"
|
37
|
+
spec.add_development_dependency "rubocop", "~> 1.21"
|
38
|
+
end
|
data/sig/mylk.rbs
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module SurrealDB
|
2
|
+
module Client
|
3
|
+
VERSION: String
|
4
|
+
|
5
|
+
class Response
|
6
|
+
attr_reader result: Array[Object]
|
7
|
+
attr_reader status: String
|
8
|
+
attr_reader time: String
|
9
|
+
|
10
|
+
def initialize: (Object) -> void
|
11
|
+
def success?: () -> bool
|
12
|
+
def error?: () -> bool
|
13
|
+
end
|
14
|
+
|
15
|
+
class Base
|
16
|
+
def initialize: (String) -> void
|
17
|
+
def connect: () -> void
|
18
|
+
def disconnect: () -> void
|
19
|
+
def connected?: () -> bool
|
20
|
+
def disconnected?: () -> bool
|
21
|
+
end
|
22
|
+
|
23
|
+
class HTTP < Base
|
24
|
+
def execute: (String) -> Response
|
25
|
+
end
|
26
|
+
|
27
|
+
class WebSocket < Base
|
28
|
+
def execute: (String) -> Response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mylk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rinat Shaykhutdinov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: websocket-client-simple
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rbs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.21'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.21'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- mail@rinatshay.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".editorconfig"
|
91
|
+
- ".rubocop.yml"
|
92
|
+
- CHANGELOG.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- lib/mylk.rb
|
99
|
+
- lib/mylk/base.rb
|
100
|
+
- lib/mylk/http.rb
|
101
|
+
- lib/mylk/response.rb
|
102
|
+
- lib/mylk/version.rb
|
103
|
+
- lib/mylk/websocket.rb
|
104
|
+
- mylk.gemspec
|
105
|
+
- sig/mylk.rbs
|
106
|
+
homepage: https://github.com/ri-nat/mylk
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata:
|
110
|
+
homepage_uri: https://github.com/ri-nat/mylk
|
111
|
+
source_code_uri: https://github.com/ri-nat/mylk
|
112
|
+
changelog_uri: https://github.com/ri-nat/mylk/CHANGELOG.md
|
113
|
+
rubygems_mfa_required: 'true'
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.6.0
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubygems_version: 3.3.26
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: SurrealDB client for Ruby (HTTP and WebSocket)
|
133
|
+
test_files: []
|