drill-sergeant 0.1.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: 5cdb7282b775f1c7230459d0a2479c1e555f951d
4
+ data.tar.gz: 1233bc819be136fccf7a3016cd703dc7b84835d1
5
+ SHA512:
6
+ metadata.gz: e3f4a2c584488f9cdd57d99d847d735bd705422c912abdf8c6be59e5c363d8b814b6d9497f99b3d29c407207065062bd6f7941a3fe5cd3a21992f621c5f78831
7
+ data.tar.gz: a34d46fd69ceb73ebcc876a8bb9dc24c8f2df2e62513c597d5ab9804dc6fc35e65cb8e4158e3bb12370f42471565d2d936f9f790f1cb699a6dba459e27ad4262
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ ## 0.1.0
2
+
3
+ - First release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,37 @@
1
+ # Drill Sergeant
2
+
3
+ Ruby client for Apache Drill
4
+
5
+ ## Installation
6
+
7
+ First, [download Apache Drill](https://drill.apache.org/docs/installing-drill-on-linux-and-mac-os-x/). Start it with:
8
+
9
+ ```sh
10
+ bin/drill-embedded
11
+ ```
12
+
13
+ Then add this line to your application’s Gemfile:
14
+
15
+ ```ruby
16
+ gem 'drill-sergeant'
17
+ ```
18
+
19
+ ## How to Use
20
+
21
+ ```ruby
22
+ drill = Drill.new(url: "http://localhost:8047")
23
+ drill.query("SELECT * FROM dfs.`/path/to/some/file.csvh`")
24
+ ```
25
+
26
+ ## History
27
+
28
+ View the [changelog](https://github.com/ankane/drill-sergeant/blob/master/CHANGELOG.md)
29
+
30
+ ## Contributing
31
+
32
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
33
+
34
+ - [Report bugs](https://github.com/ankane/drill-sergeant/issues)
35
+ - Fix bugs and [submit pull requests](https://github.com/ankane/drill-sergeant/pulls)
36
+ - Write, clarify, or fix documentation
37
+ - Suggest or add new features
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ t.warning = false
9
+ end
10
+
11
+ task default: :test
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "drill/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "drill-sergeant"
8
+ spec.version = Drill::VERSION
9
+ spec.authors = ["Andrew Kane"]
10
+ spec.email = ["andrew@chartkick.com"]
11
+
12
+ spec.summary = "Ruby client for Apache Drill"
13
+ spec.homepage = "https://github.com/ankane/drill-sergeant"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "minitest"
25
+ end
@@ -0,0 +1,34 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "drill/version"
4
+
5
+ class Drill
6
+ class Error < StandardError; end
7
+
8
+ def initialize(url: nil)
9
+ url ||= ENV["DRILL_URL"] || "http://localhost:8047"
10
+ @uri = URI.parse("#{url}/query.json")
11
+ @http = Net::HTTP.new(@uri.host, @uri.port)
12
+ end
13
+
14
+ def query(statement)
15
+ header = {"Content-Type" => "application/json", "Accept" => "application/json"}
16
+ data = {
17
+ queryType: "sql",
18
+ query: statement
19
+ }
20
+
21
+ begin
22
+ response = @http.post(@uri.request_uri, data.to_json, header)
23
+ rescue Errno::ECONNREFUSED => e
24
+ raise Drill::Error, e.message
25
+ end
26
+
27
+ body = JSON.parse(response.body)
28
+ if body["errorMessage"]
29
+ raise Drill::Error, body["errorMessage"].split("\n")[0]
30
+ end
31
+
32
+ body["rows"]
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ require "drill"
@@ -0,0 +1,3 @@
1
+ class Drill
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drill-sergeant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kane
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - andrew@chartkick.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - drill-sergeant.gemspec
68
+ - lib/drill.rb
69
+ - lib/drill/sergeant.rb
70
+ - lib/drill/version.rb
71
+ homepage: https://github.com/ankane/drill-sergeant
72
+ licenses: []
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.6.8
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Ruby client for Apache Drill
94
+ test_files: []