Method: OMF::Web::FileContentRepository#_get_path

Defined in:
lib/omf-web/content/file_repository.rb

#_get_path(content_descr) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/omf-web/content/file_repository.rb', line 65

def _get_path(content_descr)
  if content_descr.is_a? String
    path = content_descr.to_s
    if path.start_with? 'file:'
      path = path.split(':')[2]
    end
  elsif content_descr.is_a? Hash
    descr = content_descr
    if (url = descr[:url])
      path = url.split(':')[2] # git:repo_name:path
    else
      path = descr[:path]
    end
    unless path
      raise "Missing 'path' or 'url' in content description (#{descr.inspect})"
    end
    path = path.to_s
  else
    raise "Unsupported type '#{content_descr.class}'"
  end
  unless path
    raise "Can't find path information in '#{content_descr.inspect}'"
  end
  return path
end