Class: Uploader::Service

Inherits:
Object show all
Includes:
Helpers
Defined in:
lib/uploader/service.rb

Direct Known Subclasses

FileSystemService, FtpService, S3Service

Constant Summary collapse

@@services =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Service

Returns a new instance of Service.



13
14
15
# File 'lib/uploader/service.rb', line 13

def initialize(config)
  @config = config
end

Class Method Details

.is_registered?(service) ⇒ Boolean

Returns whether this service appears in the Service class’s registry.

Returns:

  • (Boolean)


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

def self.is_registered?(service)
  @@services.keys.include?(service)
end

.register(kwds = {}) ⇒ Object

Registers the Service in the registry, so clients of the service can access it by name.



52
53
54
# File 'lib/uploader/service.rb', line 52

def self.register(kwds={})
  @@services.update(kwds)
end

.servicesObject



42
43
44
# File 'lib/uploader/service.rb', line 42

def self.services
  @@services
end

Instance Method Details

#close!Object

Closes the service connection, if required.



33
34
# File 'lib/uploader/service.rb', line 33

def close!
end

#connect!Object

Called to connect to remote services like FTP and S3.



18
19
# File 'lib/uploader/service.rb', line 18

def connect!
end

#initialized?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/uploader/service.rb', line 36

def initialized?
  false
end

#upload(remote_path, contents) ⇒ Object

Perform the upload operation to this service.

Parameters:

  • remote_path (Path)

    The relative path to upload. This is prefixed by “remote_root_path” set in the uploader Config. You can set remote_root_path to “” if you want complete control over the path.

  • contents (File, String)

    The contents to upload into the remote file destination.

Returns:

  • nothing



29
30
# File 'lib/uploader/service.rb', line 29

def upload(remote_path, contents)
end