Module: Cgem::Config

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

Instance Method Summary collapse

Instance Method Details

#configured_infoObject



15
16
17
# File 'lib/cgem.rb', line 15

def configured_info
  YAML.load(File.read(sources_path))
end

#default_sources_pathObject



36
37
38
# File 'lib/cgem.rb', line 36

def default_sources_path
  File.join(root, 'default.yml')
end

#dot_sources_pathObject



32
33
34
# File 'lib/cgem.rb', line 32

def dot_sources_path
  File.join(user_home, '.cgem.yml')
end

#env_sources_pathObject



24
25
26
# File 'lib/cgem.rb', line 24

def env_sources_path
  ENV['CGEM_SOURCES_PATH']
end

#gem_sourcesObject



11
12
13
# File 'lib/cgem.rb', line 11

def gem_sources
  configured_info['gem_sources'] rescue {}
end

#rootObject



7
8
9
# File 'lib/cgem.rb', line 7

def root
  __dir__
end

#sources_pathObject



19
20
21
22
# File 'lib/cgem.rb', line 19

def sources_path
  paths = [ env_sources_path, dot_sources_path, default_sources_path]
  paths.compact.find { |p| File.exists?(p) }
end

#user_homeObject



28
29
30
# File 'lib/cgem.rb', line 28

def user_home
  File.expand_path('~')
end