Module: Cgem::Config

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

Instance Method Summary collapse

Instance Method Details

#configured_infoObject



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

def configured_info
  YAML.load(File.read(sources_path), aliases: true)
end

#default_sources_pathObject



42
43
44
# File 'lib/cgem.rb', line 42

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

#dot_sources_pathObject



38
39
40
# File 'lib/cgem.rb', line 38

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

#env_sources_pathObject



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

def env_sources_path
  ENV['CGEM_SOURCES_PATH']
end

#gem_sourcesObject



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

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

#rootObject



9
10
11
# File 'lib/cgem.rb', line 9

def root
  __dir__
end

#sources_pathObject



22
23
24
# File 'lib/cgem.rb', line 22

def sources_path
  sources_paths.find { |p| File.exist?(p) }
end

#sources_pathsObject



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

def sources_paths
  [env_sources_path, dot_sources_path, default_sources_path].compact
end

#user_homeObject



34
35
36
# File 'lib/cgem.rb', line 34

def user_home
  File.expand_path('~')
end