Class: EnvLint::DotEnvFile
- Inherits:
-
Object
- Object
- EnvLint::DotEnvFile
- Defined in:
- lib/env_lint/dot_env_file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
- #find_variable(name) ⇒ Object
-
#initialize(name, variables) ⇒ DotEnvFile
constructor
A new instance of DotEnvFile.
- #verify_no_missing(variable_names) ⇒ Object
- #verify_no_unknown(variable_names) ⇒ Object
Constructor Details
#initialize(name, variables) ⇒ DotEnvFile
Returns a new instance of DotEnvFile.
5 6 7 8 9 10 11 12 |
# File 'lib/env_lint/dot_env_file.rb', line 5 def initialize(name, variables) @name = name @variables = variables @variables_by_name = variables.each_with_object({}) do |variable, hash| hash[variable.name] = variable end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/env_lint/dot_env_file.rb', line 3 def name @name end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
3 4 5 |
# File 'lib/env_lint/dot_env_file.rb', line 3 def variables @variables end |
Class Method Details
.from_file(file_name) ⇒ Object
30 31 32 |
# File 'lib/env_lint/dot_env_file.rb', line 30 def self.from_file(file_name) new(file_name, DotEnvParser.new.parse(File.read(file_name))) end |
Instance Method Details
#find_variable(name) ⇒ Object
14 15 16 |
# File 'lib/env_lint/dot_env_file.rb', line 14 def find_variable(name) @variables_by_name[name] end |
#verify_no_missing(variable_names) ⇒ Object
18 19 20 21 22 |
# File 'lib/env_lint/dot_env_file.rb', line 18 def verify_no_missing(variable_names) find_missing(variable_names).tap do |missing_variables| raise(MissingVariables.new(self, missing_variables)) if missing_variables.any? end end |
#verify_no_unknown(variable_names) ⇒ Object
24 25 26 27 28 |
# File 'lib/env_lint/dot_env_file.rb', line 24 def verify_no_unknown(variable_names) find_unknown(variable_names).tap do |unknown_names| raise(UnknownVariables.new(self, unknown_names)) if unknown_names.any? end end |