Module: TavernaPlayer::Concerns::Models::RunPort

Extended by:
ActiveSupport::Concern
Includes:
Utils, Zip
Included in:
RunPort
Defined in:
lib/taverna_player/concerns/models/run_port.rb

Instance Method Summary collapse

Methods included from Zip

#read_file_from_zip

Methods included from Utils

#list_depth, #recurse_into_lists

Instance Method Details

#display_nameObject

included



112
113
114
# File 'lib/taverna_player/concerns/models/run_port.rb', line 112

def display_name
  name.gsub('_', ' ')
end

#filenameObject



116
117
118
119
# File 'lib/taverna_player/concerns/models/run_port.rb', line 116

def filename
  port_file = depth == 0 ? name : "#{name}.zip"
  "#{run.name}-#{port_file}"
end

#path(*indices) ⇒ Object



168
169
170
171
172
# File 'lib/taverna_player/concerns/models/run_port.rb', line 168

def path(*indices)
  index = [*indices].flatten
  path = index.empty? ? "" : "/" + index.join("/")
  file_url_via_run + path
end

#value(*indices) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/taverna_player/concerns/models/run_port.rb', line 150

def value(*indices)
  file_path = file.path
  if depth == 0
    if file_path.blank?
      self[:value]
    else
      value_is_text? ? File.read(file_path) : File.binread(file_path)
    end
  else
    index = [*indices].flatten
    index.empty? ? File.binread(file_path) : deep_value(index)
  end
end

#value=(v) ⇒ Object



164
165
166
# File 'lib/taverna_player/concerns/models/run_port.rb', line 164

def value=(v)
  self[:value] = v.force_encoding("BINARY")
end

#value_is_error?(*indices) ⇒ Boolean



134
135
136
# File 'lib/taverna_player/concerns/models/run_port.rb', line 134

def value_is_error?(*indices)
  value_type(*indices) == "application/x-error"
end

#value_is_text?(*indices) ⇒ Boolean



129
130
131
132
# File 'lib/taverna_player/concerns/models/run_port.rb', line 129

def value_is_text?(*indices)
  type = value_type(*indices)
  type.starts_with?("text")
end

#value_previewObject



146
147
148
# File 'lib/taverna_player/concerns/models/run_port.rb', line 146

def value_preview
  self[:value]
end

#value_size(*indices) ⇒ Object



138
139
140
# File 'lib/taverna_player/concerns/models/run_port.rb', line 138

def value_size(*indices)
  (:size, *indices)
end

#value_size=(size) ⇒ Object



142
143
144
# File 'lib/taverna_player/concerns/models/run_port.rb', line 142

def value_size=(size)
  (:size, size)
end

#value_type(*indices) ⇒ Object



121
122
123
# File 'lib/taverna_player/concerns/models/run_port.rb', line 121

def value_type(*indices)
  (:type, *indices) || "text/plain"
end

#value_type=(type) ⇒ Object



125
126
127
# File 'lib/taverna_player/concerns/models/run_port.rb', line 125

def value_type=(type)
  (:type, type)
end