Module: OpenstudioStandards
- Defined in:
- lib/openstudio-standards.rb,
lib/openstudio-standards/version.rb
Constant Summary collapse
- VERSION =
'0.2.16'.freeze
Class Method Summary collapse
-
.get_run_env ⇒ Object
DLM: not sure where this code should go.
- .git_revision ⇒ Object
- .run_command(command) ⇒ Object
Class Method Details
.get_run_env ⇒ Object
DLM: not sure where this code should go
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/openstudio-standards.rb', line 488 def self.get_run_env # blank out bundler and gem path modifications, will be re-setup by new call new_env = {} new_env['BUNDLER_ORIG_MANPATH'] = nil new_env['BUNDLER_ORIG_PATH'] = nil new_env['BUNDLER_VERSION'] = nil new_env['BUNDLE_BIN_PATH'] = nil new_env['RUBYLIB'] = nil new_env['RUBYOPT'] = nil # DLM: preserve GEM_HOME and GEM_PATH set by current bundle because we are not supporting bundle # requires to ruby gems will work, will fail if we require a native gem new_env['GEM_PATH'] = nil new_env['GEM_HOME'] = nil # DLM: for now, ignore current bundle in case it has binary dependencies in it # bundle_gemfile = ENV['BUNDLE_GEMFILE'] # bundle_path = ENV['BUNDLE_PATH'] # if bundle_gemfile.nil? || bundle_path.nil? new_env['BUNDLE_GEMFILE'] = nil new_env['BUNDLE_PATH'] = nil new_env['BUNDLE_WITHOUT'] = nil # else # new_env['BUNDLE_GEMFILE'] = bundle_gemfile # new_env['BUNDLE_PATH'] = bundle_path # end return new_env end |
.git_revision ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/openstudio-standards/version.rb', line 2 def self.git_revision cmd = 'git' exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = "#{path}/#{cmd}#{ext}" if File.executable?(exe) revision = `"#{exe}" -C "#{__dir__}" rev-parse --short HEAD` return revision.strip! end end end return 'git-not-found-on-this-system' end |
.run_command(command) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/openstudio-standards.rb', line 518 def self.run_command(command) stdout_str, stderr_str, status = Open3.capture3(get_run_env, command) if status.success? OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.command', "Successfully ran command: '#{command}'") # puts "stdout: #{stdout_str}" # puts "stderr: #{stderr_str}" return true else OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "Error running command: '#{command}'") OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "stdout: #{stdout_str}") OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "stderr: #{stderr_str}") # Print the ENV for debugging final_env = [] env_changes = get_run_env ENV.each do |env_var, val| next if env_changes.key?(env_var) && env_changes[env_var].nil? final_env << "#{env_var} = #{val}" end OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "command's modified ENV: \n #{final_env.join("\n")}") # List the gems available to openstudio at this point cli_path = OpenStudio.getOpenStudioCLI cmd = "\"#{cli_path}\" gem_list" stdout_str_2, stderr_str_2, status_2 = Open3.capture3(get_run_env, cmd) OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "Gems available to openstudio cli according to (openstudio gem_list): \n #{stdout_str_2}") return false end end |