Sha256: 9b00942be7d54b83497808112c389c9e9613f823d25033fe2787ba28844c50e2
Contents?: true
Size: 950 Bytes
Versions: 3
Compression:
Stored size: 950 Bytes
Contents
# frozen_string_literal: true require 'active_support/duration' module KubernetesDeploy ## # This class is a less strict extension of ActiveSupport::Duration::ISO8601Parser. # In addition to full ISO8601 durations, it can parse unprefixed ISO8601 time components (e.g. '1H'). # It is also case-insensitive. # For example, this class considers the values "1H", "1h" and "PT1H" to be valid and equivalent. class DurationParser class ParsingError < ArgumentError; end def initialize(value) @iso8601_str = value.to_s.strip.upcase end def parse! ActiveSupport::Duration.parse("PT#{@iso8601_str}") # By default assume it is just a time component rescue ActiveSupport::Duration::ISO8601Parser::ParsingError begin ActiveSupport::Duration.parse(@iso8601_str) rescue ActiveSupport::Duration::ISO8601Parser::ParsingError => e raise ParsingError, e.message end end end end
Version data entries
3 entries across 3 versions & 1 rubygems