Class: Plunger::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/plunger/config.rb

Class Method Summary collapse

Class Method Details

.dataObject



26
27
28
# File 'lib/plunger/config.rb', line 26

def data
  @data ||= self.load
end

.emailObject



30
31
32
# File 'lib/plunger/config.rb', line 30

def email
  data['username'] << '@' << data['domain']
end

.exists?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/plunger/config.rb', line 4

def exists?
  File.exists?(path)
end

.loadObject



12
13
14
# File 'lib/plunger/config.rb', line 12

def load
  Gem.configuration.load_file(path)
end

.pathObject



8
9
10
# File 'lib/plunger/config.rb', line 8

def path
  @path ||= File.join(Gem.user_home, '.gem', 'plunger')
end

.saveObject



16
17
18
19
20
21
22
23
24
# File 'lib/plunger/config.rb', line 16

def save
  dirname = File.dirname(path)

  Dir.mkdir(dirname) unless File.exists?(dirname)

  File.open(path, 'w') do |f|
    f.write data.to_yaml
  end
end