Class: EasyML::Support::SyncedDirectory
- Inherits:
-
Object
- Object
- EasyML::Support::SyncedDirectory
- Includes:
- GlueGun::DSL
- Defined in:
- lib/easy_ml/support/synced_directory.rb
Instance Method Summary collapse
- #age(format: "human") ⇒ Object
- #files ⇒ Object
- #last_updated_at ⇒ Object
- #stale? ⇒ Boolean
- #sync ⇒ Object
- #synced? ⇒ Boolean
Instance Method Details
#age(format: "human") ⇒ Object
27 28 29 |
# File 'lib/easy_ml/support/synced_directory.rb', line 27 def age(format: "human") Age.age(last_updated_at, EST.now, format: format) end |
#files ⇒ Object
23 24 25 |
# File 'lib/easy_ml/support/synced_directory.rb', line 23 def files Dir.glob(File.join(root_dir, File.join(s3_prefix, "*.csv"))) end |
#last_updated_at ⇒ Object
41 42 43 44 45 |
# File 'lib/easy_ml/support/synced_directory.rb', line 41 def last_updated_at return nil if files.empty? files.map { |file| File.mtime(file) }.max.in_time_zone(EST) end |
#stale? ⇒ Boolean
31 32 33 |
# File 'lib/easy_ml/support/synced_directory.rb', line 31 def stale? !synced? end |
#sync ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/easy_ml/support/synced_directory.rb', line 14 def sync return false if synced? mk_dir clean_dir! download true end |
#synced? ⇒ Boolean
35 36 37 38 39 |
# File 'lib/easy_ml/support/synced_directory.rb', line 35 def synced? return @synced unless @synced.nil? @synced = calculate_synced end |