Class: Geoloader::Loaders::Loader
- Inherits:
-
Object
- Object
- Geoloader::Loaders::Loader
- Defined in:
- lib/geoloader/loaders/loader.rb
Direct Known Subclasses
Geonetwork, GeotiffGeoserver, GeotiffSolr, ShapefileGeoserver, ShapefileSolr
Class Method Summary collapse
-
.load_or_enqueue(file_path, options) ⇒ Object
Perform or enqueue an upload.
-
.perform(file_path, workspace, desc_path = nil) ⇒ Object
Perform an upload (used by Resque).
Instance Method Summary collapse
-
#initialize(file_path, workspace, desc_path = nil) ⇒ Loader
constructor
Set the file path and workspace.
Constructor Details
#initialize(file_path, workspace, desc_path = nil) ⇒ Loader
Set the file path and workspace.
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.
13 14 15 16 17 18 19 |
# File 'lib/geoloader/loaders/loader.rb', line 13 def self.load_or_enqueue(file_path, ) if [:queue] Resque.enqueue(self, file_path, [:workspace], [:description]) else self.perform(file_path, [:workspace], [:description]) end end |
.perform(file_path, workspace, desc_path = nil) ⇒ Object
Perform an upload (used by Resque).
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 |