Module: DMG

Extended by:
DMG
Included in:
DMG
Defined in:
lib/dmg.rb,
lib/dmg/pkg.rb,
lib/dmg/errors.rb,
lib/dmg/source.rb

Defined Under Namespace

Classes: CLI, DMGError, PackageNotFound, Pkg, Source

Instance Method Summary collapse

Instance Method Details

#combined_pkgs_fileObject



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

def combined_pkgs_file
  File.join(config_dir, 'pkgs.yml')
end

#config_dirObject



10
11
12
# File 'lib/dmg.rb', line 10

def config_dir
  File.join(home_dir, '.dmg')
end

#create_dmg_directory_if_neededObject



32
33
34
35
36
# File 'lib/dmg.rb', line 32

def create_dmg_directory_if_needed
  unless File.directory?(config_dir)
    Dir::mkdir(config_dir)
  end
end

#default_configurationObject



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

def default_configuration
  ['https://github.com/pcreux/dmg-pkgs/raw/master/pkgs.yml']
end

#download_sourcesObject



44
45
46
# File 'lib/dmg.rb', line 44

def download_sources
  DMG::Source.download_and_combine
end

#generate_default_source_file_if_neededObject



38
39
40
41
42
# File 'lib/dmg.rb', line 38

def generate_default_source_file_if_needed
  unless File.exists? sources_file
    File.open(sources_file, 'w') { |f| f.write default_configuration.to_yaml }
  end
end

#home_dirObject



6
7
8
# File 'lib/dmg.rb', line 6

def home_dir
  ENV['DMG_HOME'] || ENV['HOME']
end

#setup!Object



26
27
28
29
30
# File 'lib/dmg.rb', line 26

def setup!
  create_dmg_directory_if_needed
  generate_default_source_file_if_needed
  download_sources
end

#sources_fileObject



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

def sources_file
  File.join(config_dir, 'sources.yml')
end