Sha256: 89f418971b297bd6b287a48cc61e55c74b55a77881b788db3b83ef23817b1931

Contents?: true

Size: 1.58 KB

Versions: 29

Compression:

Stored size: 1.58 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 'pathname'

module GoodData
  module Command
    class Runners
      def self.run_ruby_locally(brick_dir, options = {})
        pid = options[:project_id]
        fail 'You have to specify a project ID' if pid.nil?
        fail 'You have to specify directory of the brick run' if brick_dir.nil?
        fail 'You specified file as a birck run directory. You have to specify directory.' if File.exist?(brick_dir) && !File.directory?(brick_dir)

        params = options[:expanded_params] || {}

        client = GoodData.connect(options[:username], options[:password])
        sst = client.connection.sst_token
        pwd = Pathname.new(Dir.pwd)

        server_uri = URI(options[:server]) unless options[:server].nil?
        scheme = server_uri.nil? ? '' : server_uri.scheme
        hostname = server_uri.nil? ? '' : server_uri.host

        script_body = <<-script_body
        require 'fileutils'
        FileUtils::cd(\"#{pwd + brick_dir}\") do\

          $SCRIPT_PARAMS = {
            "GDC_SST" => \"#{sst}\",
            "GDC_PROJECT_ID" => \"#{pid}\",
            "GDC_PROTOCOL" => \"#{scheme}\",
            "GDC_HOSTNAME" => \"#{hostname}\",
            "GDC_LOGGER_FILE" => STDOUT,
            "GDC_ENV_LOCAL" => true
          }.merge(#{params})
          require './main.rb'
        end
        script_body
        system('ruby', '-e', script_body)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

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