Class: PolyglotIos::IO::Token
- Inherits:
-
Object
- Object
- PolyglotIos::IO::Token
- Defined in:
- lib/ios_polyglot_cli/io/token.rb
Constant Summary collapse
- POLYGLOT_TOKEN_KEY =
"POLYGLOT_TOKEN".freeze
- @@in_memory_token =
nil
Class Method Summary collapse
Class Method Details
.read ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/ios_polyglot_cli/io/token.rb', line 30 def read if !@@in_memory_token.nil? return @@in_memory_token else return ENV[POLYGLOT_TOKEN_KEY] end end |
.write(token) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ios_polyglot_cli/io/token.rb', line 11 def write(token) if @@in_memory_token.nil? out = "\n\#{POLYGLOT_TOKEN_KEY}=\#{token}\n\nTo stay logged in, add the Polyglot token to your local environment (.zshrc, .bashrc...).\n zsh:\necho '\\\\nexport \#{POLYGLOT_TOKEN_KEY}=\#{token}' >> ~/.zshrc\nsource ~/.zshrc\n bash:\necho '\\\\nexport \#{POLYGLOT_TOKEN_KEY}=\#{token}' >> ~/.bashrc\nsource ~/.bashrc\n" puts out end @@in_memory_token = token end |