Class: Trout::ManagedFile

Inherits:
Object
  • Object
show all
Defined in:
lib/trout/managed_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ ManagedFile

Returns a new instance of ManagedFile.



8
9
10
# File 'lib/trout/managed_file.rb', line 8

def initialize(filename)
  @filename = filename
end

Instance Attribute Details

#checked_out_urlObject (readonly)

Returns the value of attribute checked_out_url.



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

def checked_out_url
  @checked_out_url
end

#filenameObject (readonly)

Returns the value of attribute filename.



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

def filename
  @filename
end

Instance Method Details

#copy_from(git_url) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/trout/managed_file.rb', line 12

def copy_from(git_url)
  checkout(git_url)
  copy_to_destination
  write_url_and_version
  puts "Checked out #{filename} from #{git_url}."
ensure
  cleanup
end

#updateObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/trout/managed_file.rb', line 21

def update
  checkout(previous_git_url)
  if up_to_date?
    puts "#{filename} already up to date."
  else
    merge_to_destination
    write_url_and_version
    puts "Merged changes to #{filename}."
  end
ensure
  cleanup
end