Sha256: c692f06d374626d0c1fb1984268eb6e790705cfd1aa2685583cc48accf7e8929

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'bundler'

module GoodData::Command
  class Runners

    def self.run_ruby_locally(brick_dir, options={})
      pid = options[:project]
      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[:params] || {}

      GoodData.connection.connect!
      sst = GoodData.connection.cookies[:cookies]["GDCAuthSST"]
      pwd = Pathname.new(Dir.pwd)
      logger_stream = STDOUT
      
      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\
        require 'bundler/setup'
        eval(File.read(\"main.rb\")).call({
          :GDC_SST => \"#{sst}\",
          :GDC_PROJECT_ID => \"#{pid}\",
          :GDC_PROTOCOL => \"#{scheme}\",
          :GDC_SERVER => \"#{hostname}\"
        }.merge(#{params}))
      end
script_body

      Bundler.with_clean_env do
        system("ruby", "-e", script_body)  
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre6 lib/gooddata/commands/runners.rb
gooddata-0.6.0.pre5 lib/gooddata/commands/runners.rb
gooddata-0.6.0.pre4 lib/gooddata/commands/runners.rb
gooddata-0.6.0.pre3 lib/gooddata/commands/runners.rb