Class: Dutiful::ApplicationFile
- Inherits:
-
Object
- Object
- Dutiful::ApplicationFile
- Defined in:
- lib/dutiful/application_file.rb
Instance Attribute Summary collapse
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #backup_path ⇒ Object
- #backup_timestamp ⇒ Object
- #exist? ⇒ Boolean
- #has_backup? ⇒ Boolean
-
#initialize(path) ⇒ ApplicationFile
constructor
A new instance of ApplicationFile.
- #synced? ⇒ Boolean
- #timestamp ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ ApplicationFile
Returns a new instance of ApplicationFile.
4 5 6 7 |
# File 'lib/dutiful/application_file.rb', line 4 def initialize(path) @path = path @full_path = File. "~/#{path}" end |
Instance Attribute Details
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
2 3 4 |
# File 'lib/dutiful/application_file.rb', line 2 def full_path @full_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
2 3 4 |
# File 'lib/dutiful/application_file.rb', line 2 def path @path end |
Instance Method Details
#backup_path ⇒ Object
9 10 11 |
# File 'lib/dutiful/application_file.rb', line 9 def backup_path Dutiful::Config.storage.path path end |
#backup_timestamp ⇒ Object
13 14 15 |
# File 'lib/dutiful/application_file.rb', line 13 def File.mtime backup_path if has_backup? end |
#exist? ⇒ Boolean
21 22 23 |
# File 'lib/dutiful/application_file.rb', line 21 def exist? File.exist? full_path end |
#has_backup? ⇒ Boolean
25 26 27 |
# File 'lib/dutiful/application_file.rb', line 25 def has_backup? Dutiful::Config.storage.exist? self end |
#synced? ⇒ Boolean
29 30 31 |
# File 'lib/dutiful/application_file.rb', line 29 def synced? has_backup? && Dutiful::Config.storage.synced?(self) end |
#timestamp ⇒ Object
17 18 19 |
# File 'lib/dutiful/application_file.rb', line 17 def File.mtime full_path if exist? end |
#to_s ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dutiful/application_file.rb', line 33 def to_s if exist? return "#{path} ✔".green if synced? if has_backup? return "#{path} (modified)".yellow else return "#{path} (pending backup)".yellow end end "#{path} (pending restore)".yellow if has_backup? end |