module ROBundle::Util

A module with lots of utility functions.

Public Class Methods

clean_json(json_hash) → Hash click to toggle source

Remove empty strings and nils from a json hash structure.

   # File lib/ro-bundle/util.rb
19 def self.clean_json(structure)
20   structure.dup.delete_if do |_, v|
21     v.nil? || (v.respond_to?(:empty?) && v.empty?)
22   end
23 end
is_absolute_uri?(uri) → true or false click to toggle source

Is the supplied URI absolute? An absolute URI is a valid URI that starts with a scheme, such as http, https or urn.

   # File lib/ro-bundle/util.rb
39 def self.is_absolute_uri?(uri)
40   uri = URI.parse(uri) unless uri.is_a?(URI)
41   !uri.scheme.nil?
42 rescue URI::InvalidURIError
43   false
44 end
parse_time(time) → Time click to toggle source

Parse a time string into a Time object. Does not try to parse nil.

   # File lib/ro-bundle/util.rb
29 def self.parse_time(time)
30   return if time.nil?
31   Time.parse(time)
32 end
strip_leading_slash(string) click to toggle source

Return the supplied string with a leading slash removed.

   # File lib/ro-bundle/util.rb
50 def self.strip_leading_slash(string)
51   return if string.nil?
52   string.sub(/^\//, "")
53 end