Class: Lipaste::Config
- Inherits:
-
Object
- Object
- Lipaste::Config
- Defined in:
- lib/lipaste/config.rb
Constant Summary collapse
- FILE_NAME =
".lipaste"
Class Method Summary collapse
- ._create_config(username, password) ⇒ Object
- .create_config ⇒ Object
- .destroy ⇒ Object
- .exists? ⇒ Boolean
- .get_path ⇒ Object
- .read ⇒ Object
Class Method Details
._create_config(username, password) ⇒ Object
40 41 42 43 |
# File 'lib/lipaste/config.rb', line 40 def self._create_config(username, password) data = {username: username, password: password} File.write get_path, data.to_yaml end |
.create_config ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lipaste/config.rb', line 27 def self.create_config puts "Your credentials will only be stored locally on your computer." print "Username: " username = $stdin.gets.chomp print "Password (text will be hidden): " `stty -echo` password = $stdin.gets.chomp `stty echo` _create_config username, password end |
.destroy ⇒ Object
23 24 25 |
# File 'lib/lipaste/config.rb', line 23 def self.destroy File.delete get_path if exists? end |
.exists? ⇒ Boolean
19 20 21 |
# File 'lib/lipaste/config.rb', line 19 def self.exists? File.exists? get_path end |
.get_path ⇒ Object
14 15 16 17 |
# File 'lib/lipaste/config.rb', line 14 def self.get_path home = File. "~" File.join home, FILE_NAME end |
.read ⇒ Object
7 8 9 10 11 12 |
# File 'lib/lipaste/config.rb', line 7 def self.read return nil unless exists? content = File.read get_path YAML.load content end |