14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/synvert/core/utils.rb', line 14
def load_snippet(snippet_name)
if is_valid_url?(snippet_name)
uri = URI.parse(format_url(snippet_name))
return uri.open.read if remote_snippet_exists?(uri)
raise SnippetNotFoundError.new("#{snippet_name} nout found")
elsif is_valid_file?(snippet_name)
return File.read(snippet_name)
else
snippet_path = snippet_expand_path(snippet_name)
return File.read(snippet_path) if File.exist?(snippet_path)
snippet_uri = URI.parse(format_url(remote_snippet_url(snippet_name)))
return snippet_uri.open.read if remote_snippet_exists?(snippet_uri)
raise SnippetNotFoundError.new("#{snippet_name} nout found")
end
end
|