Class: Dscli::Storage
- Inherits:
-
Object
- Object
- Dscli::Storage
- Defined in:
- lib/dscli/storage.rb
Instance Method Summary collapse
- #get_auth ⇒ Object
-
#initialize ⇒ Storage
constructor
A new instance of Storage.
- #set_auth(auth) ⇒ Object
Constructor Details
#initialize ⇒ Storage
Returns a new instance of Storage.
6 7 8 9 10 11 12 13 |
# File 'lib/dscli/storage.rb', line 6 def initialize if !File.exist?(File.('~') + '/.datasiftcli') @configfile = File.new(File.('~') + '/.datasiftcli', 'w') @configfile.close else @configfile = File.('~') + '/.datasiftcli' end end |
Instance Method Details
#get_auth ⇒ Object
24 25 26 |
# File 'lib/dscli/storage.rb', line 24 def get_auth config = YAML.load(File.read(@configfile)) end |
#set_auth(auth) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/dscli/storage.rb', line 15 def set_auth(auth) config = File.read(@configfile) if config == "" File.open(@configfile, "w") { |f| f.write(Yajl::Encoder.encode(auth) + "\n") } end end |