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:49 UTC

[23/50] [abbrv] incubator-taverna-databundle-viewer git commit: Refactor file_path for data_bundle

Refactor file_path for data_bundle


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/19c091c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/tree/19c091c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/diff/19c091c5

Branch: refs/heads/master
Commit: 19c091c51bb87bf2c0a1973cec9f6f348b2f9c1b
Parents: 0286013
Author: Denis Karyakin <sa...@gmail.com>
Authored: Tue Aug 18 00:53:49 2015 +0300
Committer: Denis Karyakin <sa...@gmail.com>
Committed: Tue Aug 18 00:53:49 2015 +0300

----------------------------------------------------------------------
 app/decorators/data_bundle_decorator.rb | 6 +++---
 app/models/data_bundle.rb               | 6 +++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/19c091c5/app/decorators/data_bundle_decorator.rb
----------------------------------------------------------------------
diff --git a/app/decorators/data_bundle_decorator.rb b/app/decorators/data_bundle_decorator.rb
index 635ce71..c9eb6a8 100644
--- a/app/decorators/data_bundle_decorator.rb
+++ b/app/decorators/data_bundle_decorator.rb
@@ -34,7 +34,7 @@ class DataBundleDecorator < Draper::Decorator
 
   def manifest
     if @manifest.nil?
-      file = File.new("#{object.file.root}/#{object.file.store_dir}/#{DataBundle::EXTRACTED_PATH}/.ro/manifest.json", 'r')
+      file = File.new("#{object.file_path}.ro/manifest.json", 'r')
       @manifest = JSON.parse(file.read)
     end
 
@@ -43,9 +43,9 @@ class DataBundleDecorator < Draper::Decorator
 
   def workflow
     if @workflow.nil?
-      manifest = Nokogiri::XML(File.open("#{object.file.root}/#{object.file.store_dir}/#{DataBundle::EXTRACTED_PATH}/#{DataBundle::EXTRACTED_WORKFLOW_PATH}/META-INF/manifest.xml"))
+      manifest = Nokogiri::XML(File.open("#{object.file_path}#{DataBundle::EXTRACTED_WORKFLOW_PATH}/META-INF/manifest.xml"))
       t2flow_name = manifest.xpath('//manifest:file-entry[@manifest:media-type="application/vnd.taverna.t2flow+xml"][@manifest:size]').first['manifest:full-path']
-      file = File.open("#{object.file.root}/#{object.file.store_dir}/#{DataBundle::EXTRACTED_PATH}/#{DataBundle::EXTRACTED_WORKFLOW_PATH}/#{t2flow_name}")
+      file = File.open("#{object.file_path}#{DataBundle::EXTRACTED_WORKFLOW_PATH}/#{t2flow_name}")
       @workflow = T2Flow::Parser.new.parse(file)
     end
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/19c091c5/app/models/data_bundle.rb
----------------------------------------------------------------------
diff --git a/app/models/data_bundle.rb b/app/models/data_bundle.rb
index a6db10f..13455a6 100644
--- a/app/models/data_bundle.rb
+++ b/app/models/data_bundle.rb
@@ -25,6 +25,10 @@ class DataBundle < ActiveRecord::Base
 
   validates :user_id, presence: true
 
-  EXTRACTED_PATH = 'extracted_source'
+  EXTRACTED_DIRECTORY = 'extracted_source'
   EXTRACTED_WORKFLOW_PATH = 'workflow_source'
+
+  def file_path
+    "#{file.root}/#{file.store_dir}/#{EXTRACTED_DIRECTORY}/"
+  end
 end