Module: Terjira::Client::AuthOptionBuilder
- Included in:
- Base
- Defined in:
- lib/terjira/client/auth_option_builder.rb
Constant Summary collapse
- AUTH_CACHE_KEY =
'auth'.freeze
Instance Method Summary collapse
- #auth_file_cache ⇒ Object
- #build_auth_options(cache_key = AUTH_CACHE_KEY) ⇒ Object
- #build_auth_options_by_cached(cache_key = AUTH_CACHE_KEY) ⇒ Object
- #build_auth_options_by_tty ⇒ Object
- #expire_auth_options(cache_key = AUTH_CACHE_KEY) ⇒ Object
Instance Method Details
#auth_file_cache ⇒ Object
37 38 39 |
# File 'lib/terjira/client/auth_option_builder.rb', line 37 def auth_file_cache @auth_file_cache ||= Terjira::FileCache.new('profile') end |
#build_auth_options(cache_key = AUTH_CACHE_KEY) ⇒ Object
9 10 11 12 13 |
# File 'lib/terjira/client/auth_option_builder.rb', line 9 def (cache_key = AUTH_CACHE_KEY) auth_file_cache.fetch cache_key do end end |
#build_auth_options_by_cached(cache_key = AUTH_CACHE_KEY) ⇒ Object
15 16 17 |
# File 'lib/terjira/client/auth_option_builder.rb', line 15 def (cache_key = AUTH_CACHE_KEY) auth_file_cache.get(cache_key) end |
#build_auth_options_by_tty ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/terjira/client/auth_option_builder.rb', line 23 def puts 'Login will be required...' prompt = TTY::Prompt.new result = prompt.collect do key(:site).ask('Site:', required: true) key(:context_path).ask('Context path:', default: '') key(:username).ask('Username:', required: true) key(:password).mask('Password:', required: true) end result[:auth_type] = :basic result end |
#expire_auth_options(cache_key = AUTH_CACHE_KEY) ⇒ Object
19 20 21 |
# File 'lib/terjira/client/auth_option_builder.rb', line 19 def (cache_key = AUTH_CACHE_KEY) auth_file_cache.delete(cache_key) end |