Class: Uffizzi::Token
- Inherits:
-
Object
- Object
- Uffizzi::Token
- Defined in:
- lib/uffizzi/token.rb
Constant Summary collapse
- TOKEN_PATH =
"#{Dir.home}/.config/uffizzi/token"
Class Method Summary collapse
Class Method Details
.delete ⇒ Object
15 16 17 |
# File 'lib/uffizzi/token.rb', line 15 def delete File.truncate(token_path, 0) if exists? end |
.exists? ⇒ Boolean
19 20 21 |
# File 'lib/uffizzi/token.rb', line 19 def exists? File.exist?(token_path) && !read.nil? end |
.read ⇒ Object
23 24 25 26 27 28 |
# File 'lib/uffizzi/token.rb', line 23 def read content = File.read(token_path) content.presence rescue Errno::ENOENT nil end |
.token_path ⇒ Object
11 12 13 |
# File 'lib/uffizzi/token.rb', line 11 def token_path TOKEN_PATH end |
.write(token) ⇒ Object
30 31 32 33 34 |
# File 'lib/uffizzi/token.rb', line 30 def write(token) return nil unless token.is_a?(String) Uffizzi::FileHelper.write_with_lock(token_path, token) end |