Module: OpenstudioStandards
- Defined in:
- lib/openstudio-standards.rb,
lib/openstudio-standards/version.rb
Constant Summary collapse
- VERSION =
'0.2.11'.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
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/openstudio-standards.rb', line 402 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
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/openstudio-standards.rb', line 432 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 |