Module: RemoteFiles

Defined in:
lib/remote_files/file_store.rb,
lib/remote_files.rb,
lib/remote_files/file.rb,
lib/remote_files/version.rb,
lib/remote_files/fog_store.rb,
lib/remote_files/mock_store.rb,
lib/remote_files/resque_job.rb,
lib/remote_files/memory_store.rb,
lib/remote_files/configuration.rb,
lib/remote_files/abstract_store.rb

Overview

This is good for use in tests. Be sure to call #clear! before each test run.

Defined Under Namespace

Classes: AbstractStore, Configuration, Error, File, FileStore, FogStore, MemoryStore, NotFoundError, ResqueJob

Constant Summary collapse

CONFIGURATIONS =
Hash.new do |configs, name|
  name = name.to_sym
  configs[name] = Configuration.new(name)
end
VERSION =
'3.7.0'
MockStore =
MemoryStore

Class Method Summary collapse

Class Method Details

.add_store(store_identifier, options = {}, &block) ⇒ Object



43
44
45
# File 'lib/remote_files.rb', line 43

def self.add_store(store_identifier, options = {}, &block)
  default_configuration.add_store(store_identifier, options, &block)
end

.configure(name, hash = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/remote_files.rb', line 24

def self.configure(name, hash = {})
  if name.is_a?(Hash)
    hash = name
    name = :default
  end

  CONFIGURATIONS[name.to_sym].from_hash(hash)
end

.default_configurationObject



20
21
22
# File 'lib/remote_files.rb', line 20

def self.default_configuration
  CONFIGURATIONS[:default]
end

.delete_file(file = nil, &block) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/remote_files.rb', line 73

def self.delete_file(file = nil, &block)
  if file
    if @delete_file
      @delete_file.call(file)
    else
      file.delete_now!
    end
  elsif block_given?
    @delete_file = block
  else
    raise "invalid call to RemoteFiles.delete_file"
  end
end

.loggerObject



37
38
39
40
41
# File 'lib/remote_files.rb', line 37

def self.logger
  return @logger if defined?(@logger)

  @logger ||= defined?(Rails) ? Rails.logger : nil
end

.logger=(logger) ⇒ Object



33
34
35
# File 'lib/remote_files.rb', line 33

def self.logger=(logger)
  @logger = logger
end

.lookup_store(store_identifier) ⇒ Object



51
52
53
# File 'lib/remote_files.rb', line 51

def self.lookup_store(store_identifier)
  default_configuration.lookup_store(store_identifier)
end

.primary_storeObject



55
56
57
# File 'lib/remote_files.rb', line 55

def self.primary_store
  default_configuration.primary_store
end

.storesObject



47
48
49
# File 'lib/remote_files.rb', line 47

def self.stores
  default_configuration.stores
end

.synchronize_stores(file = nil, &block) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/remote_files.rb', line 59

def self.synchronize_stores(file = nil, &block)
  if file
    if @synchronize_stores
      @synchronize_stores.call(file)
    else
      file.synchronize!
    end
  elsif block_given?
    @synchronize_stores = block
  else
    raise "invalid call to RemoteFiles.synchronize_stores"
  end
end