Class: Nero::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/nero/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environ:, dir: nil, all_optional: false) ⇒ Context

Returns a new instance of Context.



7
8
9
10
11
12
13
# File 'lib/nero/context.rb', line 7

def initialize(environ:, dir: nil, all_optional: false)
  @environ = environ
  @dir = dir || File.realpath(".")
  @all_optional = all_optional
  @errors = []
  @warnings = Set.new
end

Instance Attribute Details

#dir ⇒ Object (readonly)

Returns the value of attribute dir.



5
6
7
# File 'lib/nero/context.rb', line 5

def dir
  @dir
end

#environ ⇒ Object (readonly)

Returns the value of attribute environ.



5
6
7
# File 'lib/nero/context.rb', line 5

def environ
  @environ
end

#errors ⇒ Object (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/nero/context.rb', line 5

def errors
  @errors
end

#warnings ⇒ Object (readonly)

Returns the value of attribute warnings.



5
6
7
# File 'lib/nero/context.rb', line 5

def warnings
  @warnings
end

Instance Method Details

#add_error(message) ⇒ Object



19
20
21
# File 'lib/nero/context.rb', line 19

def add_error(message)
  @errors << Error.new(message)
end

#add_warning(message) ⇒ Object



23
24
25
# File 'lib/nero/context.rb', line 23

def add_warning(message)
  @warnings << message
end

#all_optional? ⇒ Boolean

True when missing values (env vars, credentials) resolve to nil instead of being an error. See Parser#initialize (all_optional:).

Returns:

  • (Boolean)


17
# File 'lib/nero/context.rb', line 17

def all_optional? = @all_optional

#deprecate(msg, use: nil, removed_in: "1.0") ⇒ Object



27
28
29
# File 'lib/nero/context.rb', line 27

def deprecate(msg, use: nil, removed_in: "1.0")
  add_warning "DEPRECATION WARNING: #{msg} and will be removed in #{removed_in} (use #{use})"
end