Sha256: 448a4ee9a312189cf3827a57e6f1853d96aa38295da567b51213c100448c840c
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# -*- encoding: utf-8 -*- require 'cgi' module MultiForecast module ConversionRule def uri_escape(string) # + => '%20' is to avoid GF (Kossy?) bug # . => '%2E' because a/./b is recognized as a/b as URL CGI.escape(string).gsub('+', '%20').gsub('.', '%2E') if string end def uri_unescape(string) CGI.unescape(string) if string end def service_name(path) return path.split('/')[0] if path.count('/') == 2 'multiforecast' end def section_name(path) return path.split('/')[1] if path.count('/') == 2 uri_escape(File.dirname(path)) end def graph_name(path) File.basename(path) end def path(service_name, section_name, graph_name) return "#{service_name}/#{section_name}/#{graph_name}" unless service_name == "multiforecast" dirname = uri_unescape(section_name) basename = graph_name dirname == "." ? basename : "#{dirname}/#{basename}" end def id(path) @mapping.each do |base_path, base_uri| return base_path if path.index(base_path) == 0 end return @mapping.keys.first end def ids(path) @mapping.map do |base_path, base_uri| base_path if path.index(base_path) == 0 end.compact end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
multiforecast-client-0.62.0.3 | lib/multiforecast/conversion_rule.rb |