Class: GoodData::Bricks::FsProjectDownloadMiddleware
- Inherits:
-
Middleware
- Object
- Middleware
- GoodData::Bricks::FsProjectDownloadMiddleware
- Defined in:
- lib/gooddata/bricks/middleware/fs_download_middleware.rb
Instance Attribute Summary
Attributes inherited from Middleware
Instance Method Summary collapse
Methods inherited from Middleware
Methods included from Utils
Constructor Details
This class inherits a constructor from GoodData::Bricks::Middleware
Instance Method Details
#call(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gooddata/bricks/middleware/fs_download_middleware.rb', line 12 def call(params) params = params.to_hash (params['gdc_files_to_download'] || []).each do |source| case source[:type].to_s when 'ads' CSV.open(source[:to], 'w') do |csv| header_written = false header = nil dwh = params['ads_client'] dwh.execute_select(source[:query]) do |row| unless header_written header_written = true header = row.keys csv << header end csv << row.values_at(*header) end end when 'staging' webdav_uri = GoodData.project_webdav_path dav = Net::DAV.new(webdav_uri, curl: false) dav.verify_server = false dav.credentials(params['GDC_USERNAME'], params['GDC_PASSWORD']) dav.find(path, recursive: true, suppress_errors: true) do |item| GoodData.logger.info('Checking: ' + item.url.to_s) name = (item.uri - webdav_uri).to_s File.open(name, 'w') do |f| f << item.content end end end end @app.call(params) end |