Class: Secrets::Parser
- Inherits:
-
Object
- Object
- Secrets::Parser
- Defined in:
- lib/secrets_parser/parser.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- SECRETS_FILE_SUFFIX =
'.json.encrypted'.freeze
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(file_to_parse, field_to_parse) ⇒ Object
- #set_config {|@config| ... } ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
25 26 27 28 |
# File 'lib/secrets_parser/parser.rb', line 25 def initialize @config = Configuration.new @secret_variables = {} end |
Instance Method Details
#parse(file_to_parse, field_to_parse) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/secrets_parser/parser.rb', line 36 def parse(file_to_parse, field_to_parse) @config.s3 = S3.new(@config.s3_client, @config.kms_client, @config.logger) app_json = JSON.parse(IO.read(file_to_parse)) app_variables = app_json[field_to_parse] logger.info "Parsing #{field_to_parse} section of #{file_to_parse}" app_json[field_to_parse] = parse_secrets_from app_variables app_json end |
#set_config {|@config| ... } ⇒ Object
30 31 32 33 34 |
# File 'lib/secrets_parser/parser.rb', line 30 def set_config yield(@config) @config.logger ||= Logger.new(File::NULL) self end |