Class: LocalUploader
- Inherits:
-
CdnFu::Uploader
- Object
- CdnFu::Uploader
- LocalUploader
- Defined in:
- lib/cdn_fu/uploaders/local_uploader.rb
Instance Method Summary collapse
-
#upload(file_list) ⇒ Object
Here we just iterate through the files.
- #validate ⇒ Object
Methods inherited from CdnFu::Uploader
#attribute_validate, optional_attributes, required_attributes, #validate_and_upload
Instance Method Details
#upload(file_list) ⇒ Object
Here we just iterate through the files
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cdn_fu/uploaders/local_uploader.rb', line 24 def upload(file_list) FileUtils.mkdir_p(@path) if !File.exists?(@path) file_list.each do |file| path_to_copy = file.minified_path path_to_copy ||= file.local_path destination = File.join(@path,file.remote_path) dest_dir = File.dirname(destination) FileUtils.mkdir_p(dest_dir) if !File.exists?(dest_dir) FileUtils.cp path_to_copy,dest_dir end end |
#validate ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cdn_fu/uploaders/local_uploader.rb', line 6 def validate path = @path if !@path raise CdnFu::ConfigError, "Please specify a path for LocalUploader" end @path_obj = Pathname.new(@path) if !@path_obj.absolute? raise CdnFu::ConfigError, "Please specify an absolute path" end if File.exists?(@path) and !FileTest.directory?(@path) raise CdnFu::ConfigError, "LocalUploader path must be a directory" end end |