Class: GoodData::Helpers::DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata/helpers/data_helper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ DataSource

Returns a new instance of DataSource.



27
28
29
30
31
32
33
# File 'lib/gooddata/helpers/data_helper.rb', line 27

def initialize(opts = {})
  opts = opts.is_a?(String) ? { type: :staging, path: opts } : opts
  opts = GoodData::Helpers.symbolize_keys(opts)
  @source = opts[:type]
  @options = opts
  @realized = false
end

Instance Attribute Details

#realizedObject (readonly)

Returns the value of attribute realized.



14
15
16
# File 'lib/gooddata/helpers/data_helper.rb', line 14

def realized
  @realized
end

Class Method Details

.interpolate_sql_params(query, params) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/gooddata/helpers/data_helper.rb', line 17

def interpolate_sql_params(query, params)
  keys = query.scan(/\$\{([^\{]+)\}/).flatten
  keys.reduce(query) do |a, e|
    key = e
    raise "Param #{key} is not present in schedule params yet it is expected to be interpolated in the query" unless params.key?(key)
    a.gsub("${#{key}}", params[key])
  end
end

Instance Method Details

#realize(params = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gooddata/helpers/data_helper.rb', line 35

def realize(params = {})
  @realized = true
  source = @source && @source.to_s
  case source
  when 'ads'
    realize_query(params)
  when 'staging'
    realize_staging(params)
  when 'web'
    realize_link
  when 's3'
    realize_s3(params)
  when 'redshift', 'snowflake', 'bigquery', 'postgresql', 'mssql', 'mysql'
    raise GoodData::InvalidEnvError, "DataSource does not support type \"#{source}\" on the platform #{RUBY_PLATFORM}" unless RUBY_PLATFORM =~ /java/
    require_relative '../cloud_resources/cloud_resources'
    realize_cloud_resource(source, params)
  when 'blobStorage'
    require_relative '../cloud_resources/blobstorage/blobstorage_client'
    blob_storage_client = GoodData::BlobStorageClient.new(params)
    blob_storage_client.realize_blob(@options[:file], params)
  else
    raise "DataSource does not support type \"#{source}\""
  end
end

#realized?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/gooddata/helpers/data_helper.rb', line 60

def realized?
  @realized == true
end