Class: Mxrb::OfficialMarketplace::Credentials
- Inherits:
-
Object
- Object
- Mxrb::OfficialMarketplace::Credentials
- Defined in:
- lib/mxrb/official_marketplace.rb
Overview
Resolves a user-owned PAT file. Embedding the PAT remains an explicit, backwards-compatible opt-in for users who prefer MXRB-managed storage.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #configure_pat_file(source) ⇒ Object
-
#initialize(path: nil, pat_file: ) ⇒ Credentials
constructor
A new instance of Credentials.
- #pat ⇒ Object
- #save_pat(token) ⇒ Object
Constructor Details
#initialize(path: nil, pat_file: ) ⇒ Credentials
Returns a new instance of Credentials.
119 120 121 122 123 124 |
# File 'lib/mxrb/official_marketplace.rb', line 119 def initialize(path: nil, pat_file: ENV['MXRB_MENDIX_PAT_FILE']) base = ENV['XDG_CONFIG_HOME'].to_s base = File.join(Dir.home, '.config') if base.empty? @path = path || File.join(base, 'mxrb', 'credentials') @pat_file = (pat_file) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
117 118 119 |
# File 'lib/mxrb/official_marketplace.rb', line 117 def path @path end |
Instance Method Details
#configure_pat_file(source) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/mxrb/official_marketplace.rb', line 126 def configure_pat_file(source) @pat_file = (source) raise MarketplaceError, 'Mendix PAT file path must not be empty' unless @pat_file read_pat_file(@pat_file) write_config('mendix_pat_file' => @pat_file) end |
#pat ⇒ Object
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/mxrb/official_marketplace.rb', line 142 def pat return read_pat_file(@pat_file) if @pat_file return unless File.file?(@path) config = read_config source = (config['mendix_pat_file']) return read_pat_file(source) if source config['mendix_pat'] end |
#save_pat(token) ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/mxrb/official_marketplace.rb', line 134 def save_pat(token) value = token.to_s.strip raise MarketplaceError, 'Mendix PAT must not be empty' if value.empty? @pat_file = nil write_config('mendix_pat' => value) end |