gooddata-bricks 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 909157ae49e16430568d32477998b87c36b08235
4
- data.tar.gz: ae58ed11a11753cd720189711002023192ab99a3
3
+ metadata.gz: aac70370e48daace3df8c5ad82328118ceae8c67
4
+ data.tar.gz: b0b7f0a86b6b8fa2aa1ddc239d853e70209c7cfe
5
5
  SHA512:
6
- metadata.gz: 68ec19cefd7a236623e7579a94d16d4bb30656e6ed4a4196aa7fc300c5f131982e88935936dd7d9b3891ea5fb75d02a57f88ebd1f29266a496aeea9aef5ceb10
7
- data.tar.gz: 21bb4e4a62be4de59129dd50f4852905782f34abc97291b18ff94c7b246713d6974078ded5da1916be9e380f2a7003417b330ded65aba2be49a79bb7c5db71f0
6
+ metadata.gz: e0462a2f3999a9d4f184c93664516710cb96b4af5be6b25d97a624c5ea1e1c267ec70e198200060e4b3e82d81d02cd22a044285c703653a501e6f68e24cc7be7
7
+ data.tar.gz: 19d62829588c08d11db351165ba973f54a7b81947deddeac3356aacbaba2f04ce162908bdef113a4177d1b5dd444c231d8c707abd28a942d623f614935fac298
@@ -15,3 +15,6 @@ CyclomaticComplexity:
15
15
 
16
16
  PerceivedComplexity:
17
17
  Enabled: false
18
+
19
+ ClassLength:
20
+ Enabled: false
@@ -16,6 +16,7 @@ module GoodData
16
16
  protocol_name = 'CLIENT_GDC_PROTOCOL'
17
17
  server_name = 'CLIENT_GDC_HOSTNAME'
18
18
  project_id = params['GDC_PROJECT_ID']
19
+ verify_ssl = params['GDC_VERIFY_SSL'] == 'false' || params['GDC_VERIFY_SSL'] == false ? false : true
19
20
 
20
21
  server = if params[protocol_name] && params[server_name]
21
22
  "#{params[protocol_name]}://#{params[server_name]}"
@@ -24,10 +25,10 @@ module GoodData
24
25
  client = if params['GDC_USERNAME'].nil? || params['GDC_PASSWORD'].nil?
25
26
  puts "Connecting with SST to server #{server}"
26
27
  raise 'SST (SuperSecureToken) not present in params' if params[token_name].nil?
27
- GoodData.connect(sst_token: params[token_name], server: server)
28
+ GoodData.connect(sst_token: params[token_name], server: server, verify_ssl: verify_ssl)
28
29
  else
29
30
  puts "Connecting as #{params['GDC_USERNAME']} to server #{server}"
30
- GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], server: server)
31
+ GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], server: server, verify_ssl: verify_ssl)
31
32
  end
32
33
  project = client.projects(project_id)
33
34
  GoodData.project = project
@@ -6,6 +6,6 @@
6
6
 
7
7
  module GoodData
8
8
  module Bricks
9
- VERSION = '0.3.0'.freeze
9
+ VERSION = '0.4.0'.freeze
10
10
  end
11
11
  end
@@ -13,6 +13,17 @@ module GoodData
13
13
  class DataSource
14
14
  attr_reader :realized
15
15
 
16
+ class << self
17
+ def interpolate_sql_params(query, params)
18
+ keys = query.scan(/\$\{([^\{]+)\}/).flatten
19
+ keys.reduce(query) do |a, e|
20
+ key = e
21
+ raise "Param #{key} is not present in schedule params yet it is expected to be interpolated in the query" unless params.key?(key)
22
+ a.gsub("${#{key}}", params[key])
23
+ end
24
+ end
25
+ end
26
+
16
27
  def initialize(opts = {})
17
28
  opts = opts.is_a?(String) ? { type: :staging, path: opts } : opts
18
29
  opts = GoodData::Helpers.symbolize_keys(opts)
@@ -45,7 +56,7 @@ module GoodData
45
56
  private
46
57
 
47
58
  def realize_query(params)
48
- query = @options[:query]
59
+ query = DataSource.interpolate_sql_params(@options[:query], params)
49
60
  dwh = params['ads_client']
50
61
  raise "Data Source needs a client to ads to be able to query the storage but 'ads_client' is empty." unless dwh
51
62
  filename = Digest::SHA256.new.hexdigest(query)
@@ -53,7 +64,6 @@ module GoodData
53
64
  CSV.open(filename, 'w') do |csv|
54
65
  header_written = false
55
66
  header = nil
56
-
57
67
  dwh.execute_select(query) do |row|
58
68
  unless header_written
59
69
  header_written = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata-bricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Svarovsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler