Class: CslCli::Tokenstore
- Inherits:
-
Object
- Object
- CslCli::Tokenstore
- Defined in:
- lib/csl_cli/tokenstore.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(path) ⇒ Tokenstore
constructor
A new instance of Tokenstore.
- #load ⇒ Object
- #store(token) ⇒ Object
Constructor Details
#initialize(path) ⇒ Tokenstore
11 12 13 14 |
# File 'lib/csl_cli/tokenstore.rb', line 11 def initialize(path) @path = path @tokenfile = File.join(@path, '.csl_token') end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/csl_cli/tokenstore.rb', line 9 def path @path end |
Instance Method Details
#clear ⇒ Object
31 32 33 34 |
# File 'lib/csl_cli/tokenstore.rb', line 31 def clear File.delete(@tokenfile) if File.exist?(@tokenfile) return true end |
#load ⇒ Object
16 17 18 19 20 21 |
# File 'lib/csl_cli/tokenstore.rb', line 16 def load file = File.open(@tokenfile, 'rb') @saved_token = file.read() file.close return @saved_token end |
#store(token) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/csl_cli/tokenstore.rb', line 23 def store(token) file = File.open(@tokenfile, 'w') file.write(token) file.close File.chmod(0600, @tokenfile) return true end |