Method: Puppet::Interface::FullDocs#munge_copyright_year
- Defined in:
- lib/puppet/interface/documentation.rb
#munge_copyright_year(input) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/puppet/interface/documentation.rb', line 307 def munge_copyright_year(input) case input when Range then input when Integer then if input < 1970 then fault = "before 1970" elsif input > (future = Time.now.year + 2) then fault = "after #{future}" end if fault then # TRANSLATORS 'copyright' is an attribute name and should not be translated raise ArgumentError, _("copyright with a year %{value} is very strange; did you accidentally add or subtract two years?") % { value: fault } end input when String then input.strip.split(/,/).map do |part| part = part.strip if part =~ /^\d+$/ part.to_i else found = part.split(/-/) if found unless found.length == 2 and found.all? { |x| x.strip =~ /^\d+$/ } # TRANSLATORS 'copyright' is an attribute name and should not be translated raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect } end Range.new(found[0].to_i, found[1].to_i) else # TRANSLATORS 'copyright' is an attribute name and should not be translated raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect } end end end when Array then result = [] input.each do |item| item = munge_copyright_year item if item.is_a? Array result.concat item else result << item end end result else # TRANSLATORS 'copyright' is an attribute name and should not be translated raise ArgumentError, _("%{value} is not a good copyright year, set, or range") % { value: input.inspect } end end |