You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by al...@apache.org on 2015/08/24 13:41:39 UTC
[13/50] [abbrv] incubator-taverna-databundle-viewer git commit:
Update load manifest in decorator. Use meta programmings for describe methods
inputs, outputs, intermediates
Update load manifest in decorator. Use meta programmings for describe methods inputs, outputs, intermediates
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/commit/3fd1d6a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/tree/3fd1d6a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/diff/3fd1d6a0
Branch: refs/heads/master
Commit: 3fd1d6a0e7ff83ebb2846c468198aab70ea83deb
Parents: 974abbc
Author: Denis Karyakin <sa...@gmail.com>
Authored: Mon Aug 10 23:48:01 2015 +0300
Committer: Denis Karyakin <sa...@gmail.com>
Committed: Mon Aug 10 23:48:01 2015 +0300
----------------------------------------------------------------------
app/decorators/data_bundle_decorator.rb | 36 +++++++++++-----------------
1 file changed, 14 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/3fd1d6a0/app/decorators/data_bundle_decorator.rb
----------------------------------------------------------------------
diff --git a/app/decorators/data_bundle_decorator.rb b/app/decorators/data_bundle_decorator.rb
index 2e1f745..90359d3 100644
--- a/app/decorators/data_bundle_decorator.rb
+++ b/app/decorators/data_bundle_decorator.rb
@@ -20,32 +20,24 @@
class DataBundleDecorator < Draper::Decorator
delegate_all
- def manifest
- if @manifest.nil?
- tmp_file = Tempfile.new('bundle', Rails.root.join('tmp'), encoding: 'ascii-8bit')
- tmp_file.write(open(object.file.url).read)
- @bundle_file = ROBundle::File.open(tmp_file.path)
- @manifest = JSON.parse(@bundle_file.find_entry('.ro/manifest.json').get_input_stream.read)
- end
-
- @manifest
- end
+ FILE_TYPES = {
+ inputs: '/inputs/',
+ intermediates: '/intermediates/',
+ outputs: '/outputs/'
+ }
- def inputs
- inputs = manifest['aggregates'].select { |files| files['folder'] == '/inputs/' }.first
- if inputs.nil?
- ''
- else
- @bundle_file.find_entry(inputs['file'].sub(/^\//, '')).get_input_stream.read
+ FILE_TYPES.each do |type_key, type_name|
+ define_method :"#{type_key}" do
+ manifest['aggregates'].select { |files| files['folder'].start_with?(type_name) }
end
end
- def outputs
- outputs = manifest['aggregates'].select { |files| files['folder'] == '/outputs/' }.first
- if outputs.nil?
- ''
- else
- @bundle_file.find_entry(outputs['file'].sub(/^\//, '')).get_input_stream.read
+ def manifest
+ if @manifest.nil?
+ file = File.new("#{object.file.root}/#{object.file.store_dir}/#{DataBundle::EXTRACTED_PATH}/.ro/manifest.json", 'r')
+ @manifest = JSON.parse(file.read)
end
+
+ @manifest
end
end