Class: Seedster::FileManager
- Inherits:
-
Object
- Object
- Seedster::FileManager
- Defined in:
- lib/seedster/file_manager.rb
Constant Summary collapse
- SEEDSTER =
'seedster'- TMP_DIR =
'tmp'- DATA_DUMPS_DIR =
'data_dumps'- SEED_FILE_DIR =
'seedster_data_dumps'
Instance Attribute Summary collapse
-
#app_root ⇒ Object
readonly
Expects Pathname ruby-doc.org/stdlib-2.5.1/libdoc/pathname/rdoc/Pathname.html.
Class Method Summary collapse
Instance Method Summary collapse
- #consolidated_dump_file_name ⇒ Object
- #create_dump_dir ⇒ Object
- #create_seed_file_dir ⇒ Object
- #dump_dir ⇒ Object
- #get_filename(table_name:) ⇒ Object
-
#initialize(app_root:) ⇒ FileManager
constructor
A new instance of FileManager.
- #seed_file_dir ⇒ Object
Constructor Details
#initialize(app_root:) ⇒ FileManager
Returns a new instance of FileManager.
27 28 29 |
# File 'lib/seedster/file_manager.rb', line 27 def initialize(app_root:) @app_root = app_root end |
Instance Attribute Details
#app_root ⇒ Object (readonly)
Expects Pathname ruby-doc.org/stdlib-2.5.1/libdoc/pathname/rdoc/Pathname.html
25 26 27 |
# File 'lib/seedster/file_manager.rb', line 25 def app_root @app_root end |
Class Method Details
.dump_file_name ⇒ Object
60 61 62 |
# File 'lib/seedster/file_manager.rb', line 60 def dump_file_name "#{SEEDSTER}-dump-latest.tar.gz" end |
Instance Method Details
#consolidated_dump_file_name ⇒ Object
55 56 57 |
# File 'lib/seedster/file_manager.rb', line 55 def consolidated_dump_file_name app_root.join(dump_dir, self.class.dump_file_name) end |
#create_dump_dir ⇒ Object
45 46 47 48 |
# File 'lib/seedster/file_manager.rb', line 45 def create_dump_dir puts "Creating directory: '#{dump_dir}'" FileUtils.mkdir_p(dump_dir) end |
#create_seed_file_dir ⇒ Object
50 51 52 53 |
# File 'lib/seedster/file_manager.rb', line 50 def create_seed_file_dir puts "Creating directory: '#{seed_file_dir}'" FileUtils.mkdir_p(seed_file_dir) end |
#dump_dir ⇒ Object
31 32 33 34 35 |
# File 'lib/seedster/file_manager.rb', line 31 def dump_dir # Capistrano note: # set up as a linked_dir in config/deploy.rb app_root.join(TMP_DIR, DATA_DUMPS_DIR) end |
#get_filename(table_name:) ⇒ Object
41 42 43 |
# File 'lib/seedster/file_manager.rb', line 41 def get_filename(table_name:) File.join(seed_file_dir, "#{SEEDSTER}-#{table_name}.csv") end |
#seed_file_dir ⇒ Object
37 38 39 |
# File 'lib/seedster/file_manager.rb', line 37 def seed_file_dir app_root.join(TMP_DIR, SEED_FILE_DIR) end |