class ExcelToGo

Public Instance Methods

compile_code() click to toggle source
# File src/commands/excel_to_go.rb, line 82
def compile_code
  # Not needed
end
excel_lib() click to toggle source
# File src/commands/excel_to_go.rb, line 47
def excel_lib
  @excel_lib ||= IO.readlines(File.join(File.dirname(__FILE__),'..','compile','go','excel.go')).join
end
excel_lib_functions() click to toggle source
# File src/commands/excel_to_go.rb, line 55
def excel_lib_functions
  excel_lib[/import \(.*?\)(.*)/m,1]
end
excel_lib_imports() click to toggle source
# File src/commands/excel_to_go.rb, line 51
def excel_lib_imports
  excel_lib[/import \(.*?\)/m]
end
language() click to toggle source
# File src/commands/excel_to_go.rb, line 8
def language
  'go'
end
replace_values_with_constants() click to toggle source

Skip this

# File src/commands/excel_to_go.rb, line 13
def replace_values_with_constants    
end
run_tests() click to toggle source
# File src/commands/excel_to_go.rb, line 86
def run_tests
  return unless actually_run_tests
  log.info "Running the resulting tests"
  log.info `cd #{File.join(output_directory)}; go test`
end
write_code() click to toggle source

These actually create the code version of the excel

# File src/commands/excel_to_go.rb, line 17
def write_code
  write_out_excel_as_code
  write_out_test_as_code
end
write_out_excel_as_code() click to toggle source
# File src/commands/excel_to_go.rb, line 22
def write_out_excel_as_code
  log.info "Starting to write out code"

  o = output("#{output_name.downcase}.go")

  o.puts "// Compiled version of #{excel_file}"
  o.puts "package #{output_name.downcase}"
  o.puts
  o.puts excel_lib_imports
  o.puts

  c = CompileToGo.new
  c.settable = settable
  c.gettable = gettable
  c.rewrite @formulae, @worksheet_c_names, o
  o.puts

  o.puts excel_lib_functions
  o.puts 

  close(o)
  log.info "Finished writing code"

end
write_out_test_as_code() click to toggle source
# File src/commands/excel_to_go.rb, line 59
def write_out_test_as_code
  log.info "Starting to write out test"
  
  o = output("#{output_name.downcase}_test.go")

  o.puts "// Test of compiled version of #{excel_file}"
  o.puts "package #{output_name.downcase}"
  o.puts
  o.puts "import ("
  o.puts "    \"testing\""
  o.puts ")"
  o.puts

  c = CompileToGoTest.new
  c.settable = settable
  c.gettable = gettable
  c.rewrite @formulae, @worksheet_c_names, o
  o.puts

  close(o)
  log.info "Finished writing tests"
end