Sha256: c09546d67f3a8923ad809cb56b6be6e68ca8d3c1da1c7efb3ec83fd439b14a72

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module GoodData::Command
  class Runners

    def self.run_ruby(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 ran" if brick_dir.nil?

      params = if options[:params]
        JSON.parse(File.read(options[:params]), :symbolize_names => true)
      else
        {}
      end

      GoodData.connection.connect!
      sst = GoodData.connection.cookies[:cookies]["GDCAuthSST"]
      
      logger_stream = STDOUT
script_body = <<-script_body
      require 'fileutils'
      FileUtils::cd(\"#{brick_dir}\") do\
        require 'bundler/setup'
        eval(File.read(\"main.rb\")).call({
          :gdc_sst => \"#{sst}\",
          :gdc_project => \"#{pid}\"
        }.merge(#{params}))
      end
script_body


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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre2 lib/gooddata/commands/runners.rb