Class: Cranium::TestFramework::World
- Inherits:
 - 
      Object
      
        
- Object
 - Cranium::TestFramework::World
 
 
- Defined in:
 - lib/cranium/test_framework/world.rb
 
Constant Summary collapse
- DEFINITION_FILE =
 "definition.rb"
Instance Attribute Summary collapse
- 
  
    
      #error_output  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute error_output.
 - 
  
    
      #output  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute output.
 - 
  
    
      #result_code  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute result_code.
 
Instance Method Summary collapse
- #database_sequence(sequence_name) ⇒ Object
 - #database_table(table_name) ⇒ Object
 - #execute_definition ⇒ Object
 - 
  
    
      #initialize(working_directory, greenplum_connection)  ⇒ World 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of World.
 - #save_definition(definition) ⇒ Object
 - #script_output ⇒ Object
 - #upload_directory ⇒ Object
 
Constructor Details
#initialize(working_directory, greenplum_connection) ⇒ World
Returns a new instance of World.
      11 12 13 14  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 11 def initialize(working_directory, greenplum_connection) @greenplum_connection = greenplum_connection @directory = working_directory end  | 
  
Instance Attribute Details
#error_output ⇒ Object (readonly)
Returns the value of attribute error_output.
      7 8 9  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 7 def error_output @error_output end  | 
  
#output ⇒ Object (readonly)
Returns the value of attribute output.
      7 8 9  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 7 def output @output end  | 
  
#result_code ⇒ Object (readonly)
Returns the value of attribute result_code.
      7 8 9  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 7 def result_code @result_code end  | 
  
Instance Method Details
#database_sequence(sequence_name) ⇒ Object
      64 65 66  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 64 def database_sequence(sequence_name) Cranium::TestFramework::DatabaseSequence.new sequence_name, @greenplum_connection end  | 
  
#database_table(table_name) ⇒ Object
      59 60 61  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 59 def database_table(table_name) Cranium::TestFramework::DatabaseTable.new table_name.to_sym, @greenplum_connection end  | 
  
#execute_definition ⇒ Object
      44 45 46 47  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 44 def execute_definition @output, @error_output, status = Open3.capture3("bundle exec bin/cranium --cranium-load #{@directory}/#{DEFINITION_FILE}") @result_code = status.exitstatus end  | 
  
#save_definition(definition) ⇒ Object
      24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 24 def save_definition(definition) config = <<~config_string require 'logger' require 'date' Cranium.configure do |config| config.greenplum_connection_string = "#{Cranium.configuration.greenplum_connection_string}" config.gpfdist_url = "#{Cranium.configuration.gpfdist_url}" config.gpfdist_home_directory = "#{Cranium.configuration.gpfdist_home_directory}" config.upload_directory = "#{Cranium.configuration.upload_directory}" config.loggers << Logger.new("log/application.log") end config_string upload_directory.save_file DEFINITION_FILE, config + definition end  | 
  
#script_output ⇒ Object
      51 52 53 54 55  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 51 def script_output "Output: #{@output}\n"\ "Error: #{@error_output}\n"\ "Exit status: #{@result_code}\n" end  | 
  
#upload_directory ⇒ Object
      18 19 20  | 
    
      # File 'lib/cranium/test_framework/world.rb', line 18 def upload_directory @upload_directory ||= Cranium::TestFramework::UploadDirectory.new @directory end  |