Module: Towel::Environment
- Defined in:
- lib/towel/environment.rb
Overview
Helpers to collect the environment-specific details for invocations.
Constant Summary collapse
- REVISION_ENV =
Environment variable that, if set, defines the source control management revision that is reported to Towel. See ‘Invocation.revision` in towel.proto for more details.
"TOWEL_REVISION".freeze
- REDACT_ENV =
Environment variable that, if set, defines what other environment variables should be redacted.
"TOWEL_REDACT".freeze
- REDACTED =
Value that is substituted for environment variables that have been redacted.
"REDACTED".freeze
Class Method Summary collapse
-
.argv ⇒ Object
The arguments used to launch this process.
-
.env_vars ⇒ Object
The environment variables set for this process.
-
.hostname ⇒ Object
The hostname of this machine.
-
.platform ⇒ Object
The current platform that Towel is running on.
-
.revision ⇒ Object
The version control system (VCS) revision for the code that is running.
-
.user ⇒ Object
The OS user that this process is running as.
-
.working_dir ⇒ Object
The current working directory.
Class Method Details
.argv ⇒ Object
The arguments used to launch this process.
43 44 45 |
# File 'lib/towel/environment.rb', line 43 def self.argv [$0].concat(ARGV) end |
.env_vars ⇒ Object
The environment variables set for this process.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/towel/environment.rb', line 48 def self.env_vars redacted = ENV.fetch(REDACT_ENV, "").split(",").map(&:strip) ENV.to_h do |name, value| if redacted.include?(name) [name, REDACTED] else [name, value] end end end |
.hostname ⇒ Object
The hostname of this machine.
28 29 30 |
# File 'lib/towel/environment.rb', line 28 def self.hostname Socket.gethostname end |
.platform ⇒ Object
The current platform that Towel is running on.
18 19 20 21 22 23 24 25 |
# File 'lib/towel/environment.rb', line 18 def self.platform platform = Towel::V1alpha::Platform.new uname = Etc.uname platform.os = uname[:sysname] platform.os_version = uname[:release] platform.arch = uname[:machine] return platform end |
.revision ⇒ Object
The version control system (VCS) revision for the code that is running.
60 61 62 |
# File 'lib/towel/environment.rb', line 60 def self.revision ENV.fetch(REVISION_ENV, "") end |
.user ⇒ Object
The OS user that this process is running as.
33 34 35 |
# File 'lib/towel/environment.rb', line 33 def self.user Etc.getlogin end |
.working_dir ⇒ Object
The current working directory.
38 39 40 |
# File 'lib/towel/environment.rb', line 38 def self.working_dir Dir.getwd end |