tiny-presto 0.0.1 → 0.0.2

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: d5cfb9c0253ac7eb2b296b4a97710919baf69f42ecbd08f673969108aee898cc
4
- data.tar.gz: bad87113c014874ca0d72220926238ae79991d38ce70493e05331328d982791c
3
+ metadata.gz: 5e2bdd215986246b63650c85c8d78eabd47e481fa51a665e0a22264f079e24af
4
+ data.tar.gz: 3e9d922298a4ff0e9ac6e1d9aaf4993cdad8cc680b5fa1985914d176d2985cdf
5
5
  SHA512:
6
- metadata.gz: 220689da8fdb7a820f5b269b79138d159a7018a891755665b9aa5dbff8a224c318d7fb82194bd2e8b0c9bd1fcaabc9aa07eec202f50f909f9a83c85ed5ff2153
7
- data.tar.gz: 117d7e38e73cf70147afd5fd4c102130bee28e244675330ea186bc93a759ecb4cb82031e8bf8858ce5f89e28293f5926454f242d94b1e49b50c0b294cbe0166f
6
+ metadata.gz: c99b29e972147490ac5fbe3d50b3ce870aff7dd368d77ccbdd73739c36ca7f593718e89b2fc9b56c583d6e8a5b51d90a4a9ae3630f7cf22417cb7c3dfc974390
7
+ data.tar.gz: 4946f97714fab4f02b9235f5f87c2c615d097d4770fa3762115a7a3c8ce023704c182002773d6253e1b384daf81d48813720ccd0711b90a3df3f4d37f47deb3b
@@ -0,0 +1,20 @@
1
+ name: test
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake spec
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'docker-api'
8
8
  gem 'presto-client'
9
9
  gem 'rake'
10
10
  gem 'rubocop'
11
+ gem 'rdoc'
11
12
 
12
13
  group :development, :test do
13
14
  gem 'rspec'
data/Gemfile.lock CHANGED
@@ -21,6 +21,7 @@ GEM
21
21
  msgpack (>= 0.7.0)
22
22
  rainbow (3.0.0)
23
23
  rake (13.0.1)
24
+ rdoc (6.2.1)
24
25
  rspec (3.8.0)
25
26
  rspec-core (~> 3.8.0)
26
27
  rspec-expectations (~> 3.8.0)
@@ -51,6 +52,7 @@ DEPENDENCIES
51
52
  docker-api
52
53
  presto-client
53
54
  rake
55
+ rdoc
54
56
  rspec
55
57
  rubocop
56
58
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # tiny-presto
1
+ # tiny-presto [![Actions Status](https://github.com/Lewuathe/tiny-presto/workflows/test/badge.svg)](https://github.com/Lewuathe/tiny-presto/actions) ![Gem](https://img.shields.io/gem/v/tiny-presto) ![Gem](https://img.shields.io/gem/dt/tiny-presto)
2
2
 
3
3
  Tiny [Presto](https://prestosql.io/) cluster to check the compatibility of query result by using the specific Presto version.
4
4
 
@@ -36,4 +36,10 @@ To check the result consistency, `verify` method is available.
36
36
  ```ruby
37
37
  result = TinyPresto.verify('show schemas', [["default"], ["information_schema"]])
38
38
  # result is true if the returned value by the query matched with the given expected result.
39
- ```
39
+ ```
40
+
41
+ To ensure to delete the tiny-presto cluster, make sure to call `ensure_stop` before exiting.
42
+
43
+ ```ruby
44
+ TinyPresto.ensure_stop
45
+ ```
data/lib/tiny-presto.rb CHANGED
@@ -5,6 +5,7 @@ require 'singleton'
5
5
  require 'presto-client'
6
6
 
7
7
  module TinyPresto
8
+ # Singleton object representing a Presto cluster running in the local machine.
8
9
  class TinyPresto
9
10
  include Singleton
10
11
 
@@ -19,7 +20,7 @@ module TinyPresto
19
20
  begin
20
21
  @client.run('show schemas')
21
22
  break
22
- rescue StandardError => e
23
+ rescue StandardError => _
23
24
  # Waiting for the cluster is launched
24
25
  sleep(1)
25
26
  end
@@ -31,20 +32,23 @@ module TinyPresto
31
32
  end
32
33
  end
33
34
 
35
+ # Run the given SQL.
34
36
  def self.run(sql)
35
37
  presto = TinyPresto.instance
36
38
  _, rows = presto.client.run(sql)
37
39
  rows
38
40
  end
39
41
 
42
+ # Run the given SQL and verify the result.
40
43
  def self.verify(sql, expected_result)
41
44
  presto = TinyPresto.instance
42
45
  _, rows = presto.client.run(sql)
43
46
  rows == expected_result
44
47
  end
45
48
 
49
+ # Make sure to stop the cluster.
46
50
  def self.ensure_stop
47
51
  presto = TinyPresto.instance
48
52
  presto.stop
49
53
  end
50
- end
54
+ end
@@ -1,6 +1,8 @@
1
1
  require 'docker-api'
2
2
 
3
3
  module TinyPresto
4
+ # Represents a Presto cluster
5
+ #
4
6
  class Cluster
5
7
  def initialize(url, tag = 'latest')
6
8
  @url = url
@@ -8,6 +10,7 @@ module TinyPresto
8
10
  @image_name = "prestosql/presto:#{@tag}"
9
11
  end
10
12
 
13
+ # Launch Presto cluster running on Docker container
11
14
  def run
12
15
  # Ensure to pull the specified image
13
16
  Docker::Image.create('fromImage' => @image_name)
@@ -27,6 +30,7 @@ module TinyPresto
27
30
  @container
28
31
  end
29
32
 
33
+ # Kill Presto cluster process
30
34
  def stop
31
35
  @container.stop
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module TinyPresto
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny-presto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Sasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2020-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/ruby.yml"
76
77
  - ".gitignore"
77
78
  - ".pre-commit-config.yaml"
78
79
  - ".rubocop.yml"