Sha256: e25e063d1c4dacd3108f12b62c3f0bf72c98906b35087ca2cee6c1108663807d

Contents?: true

Size: 1.56 KB

Versions: 29

Compression:

Stored size: 1.56 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require_relative 'base_middleware'

module GoodData
  module Bricks
    class FsProjectDownloadMiddleware < Bricks::Middleware
      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|
              puts '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
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
gooddata-edge-0.6.27.edge lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.49 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.48 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.47 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.46 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.45 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.44 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.43 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.42 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.41 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.40 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.39 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.38 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.37 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.36 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.35 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.34 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.33 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.32 lib/gooddata/bricks/middleware/fs_download_middleware.rb
gooddata-0.6.31 lib/gooddata/bricks/middleware/fs_download_middleware.rb