Class: Geoloader::Loaders::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/geoloader/loaders/loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, workspace, desc_path = nil) ⇒ Loader

Set the file path and workspace.

Parameters:

  • file_path (String)
  • workspace (String)
  • desc_path (String) (defaults to: nil)


40
41
42
43
44
45
46
47
48
# File 'lib/geoloader/loaders/loader.rb', line 40

def initialize(file_path, workspace, desc_path = nil)

  @file_path = file_path
  @desc_path = desc_path

  # If no workspace is provided, revert to the default.
  @workspace = (workspace or Geoloader.config.workspaces.production)

end

Class Method Details

.load_or_enqueue(file_path, options) ⇒ Object

Perform or enqueue an upload.

Parameters:

  • file_path (String)
  • options (Hash)


13
14
15
16
17
18
19
# File 'lib/geoloader/loaders/loader.rb', line 13

def self.load_or_enqueue(file_path, options)
  if options[:queue]
    Resque.enqueue(self, file_path, options[:workspace], options[:description])
  else
    self.perform(file_path, options[:workspace], options[:description])
  end
end

.perform(file_path, workspace, desc_path = nil) ⇒ Object

Perform an upload (used by Resque).

Parameters:

  • file_path (String)
  • workspace (String)
  • desc_path (String) (defaults to: nil)


28
29
30
31
# File 'lib/geoloader/loaders/loader.rb', line 28

def self.perform(file_path, workspace, desc_path = nil)
  new(file_path, workspace, desc_path).load
  puts "Loaded #{File.basename(file_path)}."
end