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
- #sources_paths ⇒ Object
- #user_home ⇒ Object
Instance Method Details
#configured_info ⇒ Object
18 19 20 |
# File 'lib/cgem.rb', line 18 def configured_info YAML.load(File.read(sources_path), aliases: true) end |
#default_sources_path ⇒ Object
42 43 44 |
# File 'lib/cgem.rb', line 42 def default_sources_path File.join(root, 'default.yml') end |
#dot_sources_path ⇒ Object
38 39 40 |
# File 'lib/cgem.rb', line 38 def dot_sources_path File.join(user_home, '.cgem.yml') end |
#env_sources_path ⇒ Object
30 31 32 |
# File 'lib/cgem.rb', line 30 def env_sources_path ENV['CGEM_SOURCES_PATH'] end |
#gem_sources ⇒ Object
13 14 15 16 |
# File 'lib/cgem.rb', line 13 def gem_sources configured_info['gem_sources'] #rescue {} end |
#root ⇒ Object
9 10 11 |
# File 'lib/cgem.rb', line 9 def root __dir__ end |
#sources_path ⇒ Object
22 23 24 |
# File 'lib/cgem.rb', line 22 def sources_path sources_paths.find { |p| File.exist?(p) } end |
#sources_paths ⇒ Object
26 27 28 |
# File 'lib/cgem.rb', line 26 def sources_paths [env_sources_path, dot_sources_path, default_sources_path].compact end |
#user_home ⇒ Object
34 35 36 |
# File 'lib/cgem.rb', line 34 def user_home File.('~') end |