Module: Boson::Save

Included in:
Boson
Defined in:
lib/boson/save.rb

Instance Method Summary collapse

Instance Method Details

#configObject



8
9
10
# File 'lib/boson/save.rb', line 8

def config
  repo.config
end

#config=(val) ⇒ Object



12
13
14
# File 'lib/boson/save.rb', line 12

def config=(val)
  repo.config = val
end

#global_repoObject

Optional global repository at /etc/boson



37
38
39
# File 'lib/boson/save.rb', line 37

def global_repo
  File.exists?('/etc/boson') ? Repo.new('/etc/boson') : nil
end

#local_repoObject

An optional local repository which defaults to ./lib/boson or ./.boson.



22
23
24
25
26
27
28
29
# File 'lib/boson/save.rb', line 22

def local_repo
  @local_repo ||= begin
    ignored_dirs = (config[:ignore_directories] || []).map {|e| File.expand_path(e) }
    dir = ["lib/boson", ".boson"].find {|e| File.directory?(e) &&
        File.expand_path(e) != repo.dir && !ignored_dirs.include?(File.expand_path('.')) }
    Repo.new(dir) if dir
  end
end

#repoObject

The main required repository which defaults to ~/.boson.



17
18
19
# File 'lib/boson/save.rb', line 17

def repo
  @repo ||= Repo.new("#{ENV['BOSON_HOME'] || Dir.home}/.boson")
end

#reposObject

The array of loaded repositories containing the main repo and possible local and global repos



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

def repos
  @repos ||= [repo, local_repo, global_repo].compact
end