Class: Sanctum::GetConfig::DefaultOptions
- Inherits:
-
Object
- Object
- Sanctum::GetConfig::DefaultOptions
- Defined in:
- lib/sanctum/get_config/options.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
Instance Method Summary collapse
- #config_file_search ⇒ Object
- #get_vault_token ⇒ Object
-
#initialize(config_file = nil) ⇒ DefaultOptions
constructor
A new instance of DefaultOptions.
- #run ⇒ Object
Constructor Details
#initialize(config_file = nil) ⇒ DefaultOptions
Returns a new instance of DefaultOptions.
9 10 11 |
# File 'lib/sanctum/get_config/options.rb', line 9 def initialize(config_file=nil) @config_file = config_file end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
7 8 9 |
# File 'lib/sanctum/get_config/options.rb', line 7 def config_file @config_file end |
Instance Method Details
#config_file_search ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sanctum/get_config/options.rb', line 21 def config_file_search path = Pathname.new(Dir.pwd) path.ascend do |p| if File.file?("#{p}/sanctum.yaml") return "#{p}/sanctum.yaml" else next end end end |
#get_vault_token ⇒ Object
32 33 34 35 36 37 |
# File 'lib/sanctum/get_config/options.rb', line 32 def get_vault_token token_file = "#{Dir.home}/.vault-token" if File.file?("#{token_file}") && File.readable?("#{token_file}") File.read("#{token_file}") end end |
#run ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sanctum/get_config/options.rb', line 13 def run { config_file: config_file.nil? ? config_file_search : config_file, sanctum: { force: false, color: true }, vault: { url: "https://127.0.0.1:8200", token: get_vault_token } } end |