Module: Cgem::Config
- Included in:
- Cgem
- Defined in:
- lib/cgem.rb
Instance Method Summary collapse
- #configured_info ⇒ Object
- #default_sources_path ⇒ Object
- #dot_sources_path ⇒ Object
- #env_sources_path ⇒ Object
- #gem_sources ⇒ Object
- #root ⇒ Object
- #sources_path ⇒ Object
- #user_home ⇒ Object
Instance Method Details
#configured_info ⇒ Object
15 16 17 |
# File 'lib/cgem.rb', line 15 def configured_info YAML.load(File.read(sources_path)) end |
#default_sources_path ⇒ Object
36 37 38 |
# File 'lib/cgem.rb', line 36 def default_sources_path File.join(root, 'default.yml') end |
#dot_sources_path ⇒ Object
32 33 34 |
# File 'lib/cgem.rb', line 32 def dot_sources_path File.join(user_home, '.cgem.yml') end |
#env_sources_path ⇒ Object
24 25 26 |
# File 'lib/cgem.rb', line 24 def env_sources_path ENV['CGEM_SOURCES_PATH'] end |
#gem_sources ⇒ Object
11 12 13 |
# File 'lib/cgem.rb', line 11 def gem_sources configured_info['gem_sources'] rescue {} end |
#root ⇒ Object
7 8 9 |
# File 'lib/cgem.rb', line 7 def root __dir__ end |
#sources_path ⇒ Object
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_home ⇒ Object
28 29 30 |
# File 'lib/cgem.rb', line 28 def user_home File.('~') end |