Class: Pione::Package::DirectoryPackageReader
- Inherits:
-
PackageReader
- Object
- PackageReader
- Pione::Package::DirectoryPackageReader
- Defined in:
- lib/pione/package/package-reader.rb
Overview
DirectoryPackageReader reads package structure from directory based package.
Instance Method Summary collapse
-
#initialize(location) ⇒ DirectoryPackageReader
constructor
A new instance of DirectoryPackageReader.
- #make_local_location ⇒ Object
- #read ⇒ Object
Methods inherited from PackageReader
Constructor Details
#initialize(location) ⇒ DirectoryPackageReader
Returns a new instance of DirectoryPackageReader.
99 100 101 |
# File 'lib/pione/package/package-reader.rb', line 99 def initialize(location) @location = location end |
Instance Method Details
#make_local_location ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/pione/package/package-reader.rb', line 113 def make_local_location # make temporary directory local_location = Location[Temppath.create] # pione-package.json info = PackageInfo.read((@location + "pione-package.json").read) (@location + "pione-package.json").copy(local_location + "pione-package.json") # copy files (info.documents + info.bins + info.etcs).each do |path| (@location + path).copy(local_location + path) end # scenarios info.scenarios.each do |path| scenario_info = ScenarioInfo.read((@location + path + "pione-scenario.json").read) (@location + path + "pione-scenario.json").copy(local_location + path + "pione-scenario.json") (@location + path + "Scenario.pione").copy(local_location + path + "Scenario.pione") (scenario_info.inputs + scenario_info.outputs).each do |_path| (@location + path + _path).copy(local_location + path + _path) end end return local_location rescue Location::LocationError => e raise InvalidPackage.new("package \"%s\" is invalid: %s" % [@location.address, e.]) end |
#read ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/pione/package/package-reader.rb', line 103 def read # copy to local local_location = make_local_location # cache digest = PackageCache.cache(local_location) PackageHandler.new(PackageCache.directory_cache(digest), digest: digest) end |