dune 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b9a2988f9192b1f80fcecbb1044363e2c62838a9c75a3357ac66f62dc2218556
4
+ data.tar.gz: 62ca7157be56f75540a6a05cd4abdf69a90efe64e1a04e26d8c69deeccc3c856
5
+ SHA512:
6
+ metadata.gz: 1a718db979627349568b17b37eca835829a63fd2c6d6c44660261b10402c45c99c3a8e15c70e5e85d0c1fbf541a82c32d79ca2eea8831a60a0181589f9a74a5e
7
+ data.tar.gz: 66b14f9f6eed5bb65d1ceee20d74039c7c108e32a8f6831540e1a31f9d2d278e6ec3a4f9dc87ac16fcc67afb9faf5ee9b00ecc1d8c0930eec2b0ee9b1de04fc8
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022 by @shellandbull on telegram
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Dune [![shellandbull](https://circleci.com/gh/shellandbull/dune.svg?style=svg)](<LINK>)
2
+
3
+ Welcome to the Ruby SDK of the [Dune Analytics API](https://dune.com/docs/api/)
4
+
5
+
@@ -0,0 +1,49 @@
1
+ class Dune
2
+ class Client
3
+ attr_accessor :api_key, :connection
4
+
5
+ def initialize(api_key:, faraday_settings: {}, logger: Logger.new(IO::NULL))
6
+ @api_key = api_key
7
+ @connection = Faraday.new(default_faraday_settings.merge(faraday_settings))
8
+ @logger = logger
9
+ end
10
+
11
+ def query(id, body = nil, headers = nil, &block)
12
+ parse(connection.post("query/#{id}/execute", body, headers, &block))
13
+ end
14
+
15
+ def execution_status(id, params = nil, headers = nil, &block)
16
+ parse(connection.get("execution/#{id}/status", params, headers, &block))
17
+ end
18
+
19
+ def execution(id, params = nil, headers = nil, &block)
20
+ parse(connection.get("execution/#{id}/results", params, headers, &block))
21
+ end
22
+
23
+ def cancel(id, params = nil, headers = nil, &block)
24
+ parse(connection.post("execution/#{id}/cancel", params, headers, &block))
25
+ end
26
+
27
+ private
28
+
29
+ def parse(response)
30
+ if (200..299).include?(response.status)
31
+ JSON.parse(response.body)
32
+ else
33
+ error = Dune::Error.new("Dune API replied with status #{response.status}")
34
+ error.response = response
35
+ raise error
36
+ end
37
+ end
38
+
39
+ def default_faraday_settings
40
+ {
41
+ url: Dune::BASE_URL,
42
+ headers: {
43
+ "Content-Type": "application/json",
44
+ "x-dune-api-key": api_key
45
+ }
46
+ }
47
+ end
48
+ end
49
+ end
data/lib/dune/error.rb ADDED
@@ -0,0 +1,5 @@
1
+ class Dune
2
+ class Error < StandardError
3
+ attr_accessor :response
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class Dune
2
+ VERSION = "0.0.1"
3
+ end
data/lib/dune.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "faraday"
2
+ require "logger"
3
+ require "json"
4
+
5
+ class Dune
6
+ BASE_URL = "https://api.dune.com/api/v1"
7
+ autoload :VERSION, "dune/version"
8
+ autoload :Client, "dune/client"
9
+ autoload :Error, "dune/error"
10
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dune
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - shellandbull
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - sudo@morph.tech
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE.txt
21
+ - README.md
22
+ - lib/dune.rb
23
+ - lib/dune/client.rb
24
+ - lib/dune/error.rb
25
+ - lib/dune/version.rb
26
+ homepage: https://github.com/shellandbull/dune
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ bug_tracker_uri: https://github.com/shellandbull/dune/issues
31
+ changelog_uri: https://github.com/shellandbull/dune/releases
32
+ source_code_uri: https://github.com/shellandbull/dune
33
+ homepage_uri: https://github.com/shellandbull/dune
34
+ rubygems_mfa_required: 'true'
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '2.6'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubygems_version: 3.3.7
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: A Ruby API client for the Dune Analytics API
54
+ test_files: []