class Gitenv::Config
Attributes
actions[R]
repos[R]
Public Class Methods
new()
click to toggle source
# File lib/gitenv/config.rb, line 7 def initialize @context = Context.new self @repos = [] @actions = [] end
Public Instance Methods
all_files(options = {})
click to toggle source
# File lib/gitenv/config.rb, line 31 def all_files(options = {}) matcher :all_files, options end
copy(file, options = {})
click to toggle source
# File lib/gitenv/config.rb, line 25 def copy(file, options = {}) raise 'You must specify a repository or a source directory to copy from' unless @context.from Copy::Action.new(@context.dup, matcher(file), options).tap { |a| @actions << a } end
dot_files(options = {})
click to toggle source
# File lib/gitenv/config.rb, line 35 def dot_files(options = {}) matcher :dot_files, options end
ignores()
click to toggle source
# File lib/gitenv/config.rb, line 46 def ignores @context.ignores end
include(other_config_file, optional: false)
click to toggle source
# File lib/gitenv/config.rb, line 50 def include(other_config_file, optional: false) raise 'Only absolute paths can be included' unless Pathname.new(other_config_file).absolute? absolute_path = File.expand_path(other_config_file) unless File.exist?(absolute_path) raise "Cannot find file to include #{absolute_path}" unless optional return end contents = File.open(absolute_path, 'r').read instance_eval contents, absolute_path end
repo(path, &block)
click to toggle source
# File lib/gitenv/config.rb, line 13 def repo(path, &block) @repos << Repository.new(path) @context.from path, &block self end
symlink(file, options = {})
click to toggle source
# File lib/gitenv/config.rb, line 19 def symlink(file, options = {}) raise 'You must specify a repository or a source directory to symlink from' unless @context.from Symlink::Action.new(@context.dup, matcher(file), options).tap { |a| @actions << a } end
Private Instance Methods
matcher(file, options = {})
click to toggle source
# File lib/gitenv/config.rb, line 66 def matcher(file, options = {}) options[:ignores] ||= @context.ignores.dup if file.is_a? FilesMatcher file elsif file == :all_files AllFiles.new options elsif file == :dot_files DotFiles.new options else OneFile.new file, options end end