Class: Trout::ManagedFile
- Inherits:
-
Object
- Object
- Trout::ManagedFile
- Defined in:
- lib/trout/managed_file.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#git_url ⇒ Object
Returns the value of attribute git_url.
-
#latest_version ⇒ Object
Returns the value of attribute latest_version.
-
#source_root ⇒ Object
Returns the value of attribute source_root.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #checkout ⇒ Object
-
#initialize(attributes) ⇒ ManagedFile
constructor
A new instance of ManagedFile.
- #to_hash ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(attributes) ⇒ ManagedFile
Returns a new instance of ManagedFile.
7 8 9 10 11 12 |
# File 'lib/trout/managed_file.rb', line 7 def initialize(attributes) self.filename = attributes[:filename] self.git_url = attributes[:git_url] self.version = attributes[:version] self.source_root = attributes[:source_root] || '/' end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/trout/managed_file.rb', line 5 def filename @filename end |
#git_url ⇒ Object
Returns the value of attribute git_url.
5 6 7 |
# File 'lib/trout/managed_file.rb', line 5 def git_url @git_url end |
#latest_version ⇒ Object
Returns the value of attribute latest_version.
5 6 7 |
# File 'lib/trout/managed_file.rb', line 5 def latest_version @latest_version end |
#source_root ⇒ Object
Returns the value of attribute source_root.
5 6 7 |
# File 'lib/trout/managed_file.rb', line 5 def source_root @source_root end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/trout/managed_file.rb', line 5 def version @version end |
Instance Method Details
#checkout ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/trout/managed_file.rb', line 14 def checkout clone_repository copy_to_destination puts "Checked out #{filename} from #{git_url}." ensure cleanup end |
#to_hash ⇒ Object
34 35 36 37 38 39 |
# File 'lib/trout/managed_file.rb', line 34 def to_hash { :filename => filename, :git_url => git_url, :version => version, :source_root => source_root } end |
#update ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/trout/managed_file.rb', line 22 def update clone_repository if up_to_date? puts "#{filename} already up to date." else merge_to_destination puts "Merged changes to #{filename}." end ensure cleanup end |