eventql 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 267dea46bb6e8b656ff613bc6943f58e6cb44f40
4
- data.tar.gz: d4a601064cf96d8167c729468ad4836f022a9ab8
3
+ metadata.gz: bcfe032cca875fd4c881d0d58d8e05daa3200cb2
4
+ data.tar.gz: 61de5b1da00f8824032837e3d352c5efef515f99
5
5
  SHA512:
6
- metadata.gz: d3007ec9e79aa7d7f89f307fcfcf226ad66fcf76327a13bcde0b95b24778850aaf2c56020e992ddeb9c20de6be2f68cc778241f91a268cd2de0f0f05f353b512
7
- data.tar.gz: fc0a2158833a444c4571b216c9c6cb04977eca21bca32ad75a45bdf3c801a4e5a89b26608efdb88f735cf08259fa33750c775179ed5bba55363bed4e80873212
6
+ metadata.gz: 087c4216a70732986b0ea9dde580baa027acb306daac33f689b3384e3ac93828dd4f20d45c5577ab15955075837b86afc8a28835572e4f0a9326db84fc7bf88f
7
+ data.tar.gz: 8136fa14c1eb1d714718fc455ae147e6c124d2cd0904f400367e9ef15c7aac806b2468ba48e6b55910e11d83467fca7a50ad32291f12bd4606eabc4cae27321b
data/eventql.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "eventql"
3
+ s.version = "0.0.2"
4
+ s.authors = ["Paul Asmuth"]
5
+ s.date = "2016-12-18"
6
+ s.description = "EventQL ruby driver"
7
+ s.summary = "EventQL ruby driver"
8
+ s.email = "paul@eventql.io"
9
+ s.files = %w(
10
+ eventql.gemspec
11
+ lib/eventql_client.rb
12
+ lib/eventql_query.rb
13
+ lib/eventql.rb
14
+ )
15
+ s.homepage = "http://github.com/eventql/eventql"
16
+ s.licenses = ["MIT"]
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = "1.8.10"
19
+ end
data/lib/eventql.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "eventql_client"
2
+ require "eventql_query"
3
+
4
+ module EventQL
5
+
6
+ def self.connect(opts = {})
7
+ return EventQL::Client.new(opts)
8
+ end
9
+
10
+ end
@@ -0,0 +1,33 @@
1
+ module EventQL; end
2
+
3
+ class EventQL::Client
4
+
5
+ def initialize(opts = {})
6
+ @opts = opts
7
+ end
8
+
9
+ def query(query_str, opts = {})
10
+ EventQL::Query.new(self, query_str, opts)
11
+ end
12
+
13
+ def get_host
14
+ return @opts[:host]
15
+ end
16
+
17
+ def get_port
18
+ return @opts[:port]
19
+ end
20
+
21
+ def get_database
22
+ return @opts[:database]
23
+ end
24
+
25
+ def get_auth_token
26
+ return @opts[:auth_token]
27
+ end
28
+
29
+ def has_auth_token?
30
+ return !@opts[:auth_token].nil?
31
+ end
32
+
33
+ end
@@ -0,0 +1,43 @@
1
+ module EventQL; end
2
+
3
+ require "net/http"
4
+ require "json"
5
+
6
+ class EventQL::Query
7
+
8
+ def initialize(client, query_str, query_opts = {})
9
+ @client = client
10
+ @query_str = query_str
11
+ @query_opts = query_opts
12
+ end
13
+
14
+ def execute!
15
+ request = Net::HTTP::Post.new("/api/v1/sql")
16
+ request.add_field("Content-Type", "application/json")
17
+
18
+ if @client.has_auth_token?
19
+ request.add_field("Authorization", "Token #{@client.get_auth_token}")
20
+ end
21
+
22
+ request.body = {
23
+ :query => @query_str,
24
+ :database => @client.get_database,
25
+ :format => "json"
26
+ }.to_json
27
+
28
+ http = Net::HTTP.new(@client.get_host, @client.get_port)
29
+ response = http.request(request)
30
+
31
+ response_json = JSON.parse(response.body) rescue nil
32
+ if response_json && response_json.has_key?("error")
33
+ raise response_json["error"]
34
+ end
35
+
36
+ if response_json.nil? || response.code.to_i != 200
37
+ raise "HTTP ERROR (#{response.code}): #{response.body[0..128]}"
38
+ end
39
+
40
+ return response_json["results"]
41
+ end
42
+
43
+ end
metadata CHANGED
@@ -1,23 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventql
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
  - Paul Asmuth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-12-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: EventQL ruby driver
14
- email: paul@asmuth.com
14
+ email: paul@eventql.io
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - readme.md
20
- homepage: http://github.com/eventql/eventql-ruby
19
+ - eventql.gemspec
20
+ - lib/eventql.rb
21
+ - lib/eventql_client.rb
22
+ - lib/eventql_query.rb
23
+ homepage: http://github.com/eventql/eventql
21
24
  licenses:
22
25
  - MIT
23
26
  metadata: {}
@@ -27,17 +30,17 @@ require_paths:
27
30
  - lib
28
31
  required_ruby_version: !ruby/object:Gem::Requirement
29
32
  requirements:
30
- - - '>='
33
+ - - ">="
31
34
  - !ruby/object:Gem::Version
32
35
  version: '0'
33
36
  required_rubygems_version: !ruby/object:Gem::Requirement
34
37
  requirements:
35
- - - '>='
38
+ - - ">="
36
39
  - !ruby/object:Gem::Version
37
40
  version: '0'
38
41
  requirements: []
39
42
  rubyforge_project:
40
- rubygems_version: 2.0.14
43
+ rubygems_version: 2.5.1
41
44
  signing_key:
42
45
  specification_version: 4
43
46
  summary: EventQL ruby driver
data/readme.md DELETED
@@ -1 +0,0 @@
1
- # eventql-ruby