Class: PyramidScheme::IndexProvider::FileSystem

Inherits:
Base
  • Object
show all
Defined in:
lib/pyramid_scheme/index_provider/file_system.rb

Instance Attribute Summary

Attributes inherited from Base

#configuration, #copy_attempts

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#index_in_progress?, #initialize, maximum_copy_attempts, #retrieve_index

Constructor Details

This class inherits a constructor from PyramidScheme::IndexProvider::Base

Class Method Details

.required_optionsObject



5
6
7
8
9
10
11
12
# File 'lib/pyramid_scheme/index_provider/file_system.rb', line 5

def required_options
  [
    :server_source_path, 
    :server_destination_path,
    :client_source_path,
    :client_destination_path
  ]
end

Instance Method Details

#lockObject



19
20
21
# File 'lib/pyramid_scheme/index_provider/file_system.rb', line 19

def lock
  @lock ||= PyramidScheme::Lock::File.new
end

#process_indexObject



15
16
17
# File 'lib/pyramid_scheme/index_provider/file_system.rb', line 15

def process_index
  server_copy
end

#provide_client_with_indexObject



23
24
25
26
27
28
29
30
31
# File 'lib/pyramid_scheme/index_provider/file_system.rb', line 23

def provide_client_with_index
  Configuration::INDEX_FILE_EXTENSIONS.each do |ext|
    Dir[File.join(self.configuration[:client_source_path], "*#{ext}")].each do |f|
      new_filename = File.basename(f.gsub(/\./, ".new."))
      FileUtils.cp_r(f, 
        "#{self.configuration[:client_destination_path]}/#{new_filename}")
    end
  end
end