Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves logic from os_env from initialize phase to runtime phase #2072

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/resources/os_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class OsEnv < Inspec.resource(1)
attr_reader :content
def initialize(env = nil)
@osenv = env
@content = nil
@content = value_for(env) unless env.nil?
end

def split
Expand All @@ -35,7 +33,12 @@ def split
path_separator = inspec.os.windows? ? ';' : ':'
# -1 is required to catch cases like dir1::dir2:
# where we have a trailing :
@content.nil? ? [] : @content.split(path_separator, -1)
content.nil? ? [] : content.split(path_separator, -1)
end

def content
return @content if defined?(@content)
@content = value_for(@osenv) unless @osenv.nil?
end

def to_s
Expand All @@ -49,9 +52,6 @@ def to_s
private

def value_for(env)
# do mock handling
return nil if inspec.os.name.nil?

command = if inspec.os.windows?
"${Env:#{env}}"
else
Expand Down