Module: Cgem::Gemrc

Included in:
Cgem
Defined in:
lib/cgem.rb

Instance Method Summary collapse

Instance Method Details

#dot_gemrcObject



48
49
50
# File 'lib/cgem.rb', line 48

def dot_gemrc
  File.join(user_home, '.gemrc')
end

#gemrc_sourcesObject



61
62
63
64
65
# File 'lib/cgem.rb', line 61

def gemrc_sources
  return unless File.exist?(dot_gemrc)
  settings = YAML.load(File.read(dot_gemrc))
  settings[:sources]
end

#set_gemrc_sources(source) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/cgem.rb', line 52

def set_gemrc_sources(source)
  settings = {}
  if File.exist?(dot_gemrc)
    settings = YAML.load(File.read(dot_gemrc))
  end
  settings[:sources] = ["#{source.chomp('/')}/"]
  File.write(dot_gemrc, settings.to_yaml)
end