Class: Gitenv::Copy

Inherits:
Object
  • Object
show all
Defined in:
lib/gitenv/copy.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, file, options = {}) ⇒ Copy

Returns a new instance of Copy.



9
10
11
# File 'lib/gitenv/copy.rb', line 9

def initialize config, file, options = {}
  @config, @file, @options = config, file, options
end

Instance Method Details

#descriptionObject



28
29
30
# File 'lib/gitenv/copy.rb', line 28

def description
  "#{target} << #{source}"
end

#to_sObject



22
23
24
25
26
# File 'lib/gitenv/copy.rb', line 22

def to_s
  color, mark, msg = status
  justification = @options[:justify] ? ' ' * (@options[:justify] - description.length) : ''
  %/ #{Paint[mark, color]} #{Paint[target, :cyan]} << #{source}#{justification}#{Paint[msg, color]}/
end

#update!Object



13
14
15
16
17
18
19
20
# File 'lib/gitenv/copy.rb', line 13

def update!
  if File.exists?(target) && !File.exists?(target_copy)
    FileUtils.mv target, target_copy
  end
  if !File.exists?(target)
    FileUtils.copy source, target
  end
end