Class: Geoloader::Assets::Asset
- Inherits:
-
Object
- Object
- Geoloader::Assets::Asset
- Defined in:
- lib/geoloader/assets/asset.rb
Instance Attribute Summary collapse
-
#file_base ⇒ Object
readonly
Returns the value of attribute file_base.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Instance Method Summary collapse
-
#initialize(file_path, workspace, desc_path) ⇒ Asset
constructor
Set the basename and workspace-prefixed uuid, parse the description.
-
#stage ⇒ Object
Create working copies, yield to a block, remove the copies.
Constructor Details
#initialize(file_path, workspace, desc_path) ⇒ Asset
Set the basename and workspace-prefixed uuid, parse the description.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/geoloader/assets/asset.rb', line 18 def initialize(file_path, workspace, desc_path) @file_path = File.(file_path) @workspace = workspace # File name, with and without extension. @file_base = File.basename(@file_path, ".*") @file_name = File.basename(@file_path) # Parse the markdown metadata. @description = Description.new(desc_path) # Set a workspace-prefixed uuid. @uuid = "#{@workspace}_#{@file_base}" end |
Instance Attribute Details
#file_base ⇒ Object (readonly)
Returns the value of attribute file_base.
9 10 11 |
# File 'lib/geoloader/assets/asset.rb', line 9 def file_base @file_base end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
9 10 11 |
# File 'lib/geoloader/assets/asset.rb', line 9 def file_name @file_name end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
9 10 11 |
# File 'lib/geoloader/assets/asset.rb', line 9 def file_path @file_path end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
9 10 11 |
# File 'lib/geoloader/assets/asset.rb', line 9 def uuid @uuid end |
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
9 10 11 |
# File 'lib/geoloader/assets/asset.rb', line 9 def workspace @workspace end |
Instance Method Details
#stage ⇒ Object
Create working copies, yield to a block, remove the copies.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/geoloader/assets/asset.rb', line 38 def stage @tempdir = Dir.mktmpdir begin # Copy the assets into the temp dir. files = Dir.glob("#{File.dirname(@file_path)}/#{@file_base}.*") FileUtils.cp(files, @tempdir) # Change into the temp dir. FileUtils.cd(@tempdir) do yield end ensure # Delete the copies. FileUtils.remove_entry @tempdir end end |