Sha256: bed6d7fae5432db800a84c8aa48f36c3f2c10b4e0c8311338da56ff8ddcc7938

Contents?: true

Size: 879 Bytes

Versions: 2

Compression:

Stored size: 879 Bytes

Contents

module PolyglotIos
  module IO
    class Token

      @@in_memory_token = nil
    
      POLYGLOT_TOKEN_KEY = "POLYGLOT_TOKEN".freeze
      
      class << self
  
        def write(token)
          if @@in_memory_token.nil?
            out = <<-HELLO

#{POLYGLOT_TOKEN_KEY}=#{token}

To stay logged in, add the Polyglot token to your local environment (.zshrc, .bashrc...).
    zsh:
        echo '\\nexport #{POLYGLOT_TOKEN_KEY}=#{token}' >> ~/.zshrc
        source ~/.zshrc
    bash:
        echo '\\nexport #{POLYGLOT_TOKEN_KEY}=#{token}' >> ~/.bashrc
        source ~/.bashrc
HELLO
            puts out
          end
          @@in_memory_token = token
        end
    
        def read
          if !@@in_memory_token.nil?
            return @@in_memory_token
          else
            return ENV[POLYGLOT_TOKEN_KEY]
          end
        end
      end
    end
  end
end
  

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ios_polyglot_cli-2.4.0 lib/ios_polyglot_cli/io/token.rb
ios_polyglot_cli-2.3.0 lib/ios_polyglot_cli/io/token.rb