metabase_tarot 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tarot.rb +14 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9734972ba59262c1990c46be98895a92e22da1cc4e7ffa802433b7b575f9179e
4
- data.tar.gz: fcd559a8a0e2348c90e8fe06eb9770c7006d34fef527a7bcc54a7f3a02e38b78
3
+ metadata.gz: ce824383ddfdcef67a3b41c786ac7ed4382f31dbb7df8bdd7077deb2c925af75
4
+ data.tar.gz: 39ae136b3838cb2a0959bbca450ed9816267fe8ffbc007eb6ef1ceeffa865b55
5
5
  SHA512:
6
- metadata.gz: cee9bc2358bd1d1d40c7f2b58c927c8c8f570249d2aefb1e16adf648d246562336c2ea0b5279a60b80e6e8afdebd54286c8215a2f08d0c9be545d0684c218657
7
- data.tar.gz: 989da28f119b5a3d8c38b72589d9d5f786b62e5bded93b84f534f5914b8695578d95428a86da1d896f80ba31b3174410250d5d56143301a9b75c3e8f8b1aae21
6
+ metadata.gz: daee68d3753663f5c22db15e5372d790e1619a996f8b50a01777c3675c47d6450e18913b5cd40318b345e228f1e05ff4472843a80c125b4fa6e53f8680d877c9
7
+ data.tar.gz: 596b6547d3e1a1c9e2ead06c8de3964ce7fe1026a4ad58768042c3add808f80672e7f9ac74d9d8a6821f21401e10693cedf65ce4606f4b8fa9fe35816a6d3297
data/lib/tarot.rb CHANGED
@@ -26,11 +26,11 @@ module Tarot
26
26
  # Usa um bloco, normalmente definido na tarot_spec.rb, para popular as configurações de usuário.
27
27
  #
28
28
  # @example Exemplo
29
- # Config.build do |config|
30
- # config.session_expire_days = 13
31
- # config.url = 'https://metabase.mycompany.com'
32
- # config.database_aliases = {}
33
- # end
29
+ # Config.build do |config|
30
+ # config.session_expire_days = 13
31
+ # config.url = 'https://metabase.mycompany.com'
32
+ # config.database_aliases = {}
33
+ # end
34
34
  #
35
35
  # @yieldreturn [Hash] Bloco que recebe um Tarot::Config::Data e modifica seus valores.
36
36
  # @return [void]
@@ -52,7 +52,7 @@ module Tarot
52
52
  end
53
53
 
54
54
  @data.session_expire_days.freeze
55
- @data.url.freeze
55
+ @data.url = URI(@data.url).freeze
56
56
  @data.database_aliases.freeze
57
57
 
58
58
  @built = true
@@ -116,7 +116,7 @@ module Tarot
116
116
  # Grava os resultados de um bloco em um arquivo YAML com o mesmo nome passado pelo argumento filepath (porém terminando em .yaml), incluindo metadados de quando foi gerado, e do script que gerou o arquivo.
117
117
  #
118
118
  # @example Exemplo
119
- # exemplos/test.rb
119
+ # # exemplos/test.rb
120
120
  # consultation(__FILE__) do
121
121
  # db('minha db').query!('SELECT * FROM plans WHERE id = 3;')
122
122
  # end
@@ -181,9 +181,9 @@ module Tarot
181
181
  # @return [Array<Database>] Array de objetos Database.
182
182
  def databases
183
183
  unless @databases
184
- uri = URI.parse("#{Config.data.url}/api/database")
184
+ uri = Config.data.url + '/api/database'
185
185
  http = Net::HTTP.new(uri.hostname, uri.port)
186
- http.use_ssl = true
186
+ http.use_ssl = uri.scheme == 'https'
187
187
 
188
188
  request = Net::HTTP::Get.new(uri)
189
189
  request['Accept'] = 'application/json'
@@ -214,9 +214,9 @@ module Tarot
214
214
  # @param sql [String] Consulta SQL a ser executada.
215
215
  # @return [Object] Resultado da API contendo a resposta da consulta ou um JSON com os erros que ocorreram.
216
216
  def query(database, sql)
217
- uri = URI.parse("#{Config.data.url}/api/dataset/json")
217
+ uri = Config.data.url + '/api/dataset/json'
218
218
  http = Net::HTTP.new(uri.hostname, uri.port)
219
- http.use_ssl = true
219
+ http.use_ssl = uri.scheme == 'https'
220
220
 
221
221
  request = Net::HTTP::Post.new(uri,
222
222
  'Accept' => 'application/json',
@@ -267,9 +267,9 @@ module Tarot
267
267
  token = token_json['token']
268
268
 
269
269
  if token.nil?
270
- uri = URI("#{Config.data.url}/api/session")
270
+ uri = Config.data.url + '/api/session'
271
271
  http = Net::HTTP.new(uri.hostname, uri.port)
272
- http.use_ssl = true
272
+ http.use_ssl = uri.scheme == 'https'
273
273
 
274
274
  request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
275
275
  login = {}
@@ -284,7 +284,7 @@ module Tarot
284
284
  begin
285
285
  response = http.request(request)
286
286
  rescue OpenSSL::SSL::SSLError
287
- puts "#{Config.data.url} seems to be unreachable at the moment"
287
+ puts "#{Config.data.url.to_s} seems to be unreachable at the moment"
288
288
  end
289
289
 
290
290
  token = JSON.parse(response.body)['id']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metabase_tarot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hikari Luz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-22 00:00:00.000000000 Z
11
+ date: 2024-02-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Utility tool for connecting directly to Metabase via its API
14
14
  email: hikaridesuyoo@gmail.com