Class: Pho::FileManagement::FileManager
- Inherits:
-
AbstractFileManager
- Object
- AbstractFileManager
- Pho::FileManagement::FileManager
- Defined in:
- lib/pho/file_manager.rb
Overview
Manages a collection of files in a directory structure, uploading them to the contentbox of a platform store
Allows the base directory of the upload to be specified, giving some flexibility on how the files are published via the contentbox. By default the files will be rooted in /items/ but by specifying the base parameter in the construct, this can be altered to, e.g. /items/foo
Constant Summary
Constants inherited from AbstractFileManager
AbstractFileManager::FAIL, AbstractFileManager::OK, AbstractFileManager::TRACKING_DIR
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Attributes inherited from AbstractFileManager
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(store, dir, base = nil, ok_suffix = OK, fail_suffix = FAIL) ⇒ FileManager
constructor
A new instance of FileManager.
-
#list(recursive = false) ⇒ Object
List files being managed, i.e.
Methods inherited from AbstractFileManager
#changed?, #changed_files, #failures, #get_fail_file_for, #get_ok_file_for, #new_files, #reset, #retry_failures, #store_changes, #stored?, #stored_files, #successes, #summary
Constructor Details
#initialize(store, dir, base = nil, ok_suffix = OK, fail_suffix = FAIL) ⇒ FileManager
Returns a new instance of FileManager.
18 19 20 21 |
# File 'lib/pho/file_manager.rb', line 18 def initialize(store, dir, base = nil, ok_suffix=OK, fail_suffix=FAIL) super(store, dir, ok_suffix, fail_suffix) @base = base end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
16 17 18 |
# File 'lib/pho/file_manager.rb', line 16 def base @base end |
Class Method Details
.name_for_file(dir, file, base = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/pho/file_manager.rb', line 33 def FileManager.name_for_file(dir, file, base=nil) uri = file.path.gsub(dir, "") uri = "#{base}#{uri}" if base != nil return uri end |
Instance Method Details
#list(recursive = false) ⇒ Object
List files being managed, i.e. everything not .ok or .fail
24 25 26 27 28 29 30 31 |
# File 'lib/pho/file_manager.rb', line 24 def list(recursive=false) if recursive pattern = "**/*.*" else pattern = "*.*" end return Dir.glob( File.join(@dir, pattern) ) end |