File: deb_version.rb

package info (click to toggle)
ruby-deb-version 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 96 kB
  • sloc: ruby: 95; sh: 4; makefile: 4
file content (25 lines) | stat: -rw-r--r-- 772 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require_relative "deb_version/version"
require_relative "deb_version/compare"

# Constants for the DebVersion class
class DebVersion
  class Error < StandardError; end
  # String of ASCII characters which are considered punctuation characters in the C locale:
  # Except for ~
  # Already sorted
  PUNCTUATION = "!\"\#$%&'()*+,-./:;<=>?@[]^_`{|}".chars
  DIGITS = ("0".."9").to_a

  # Sorted list of characters used by Debian Version sort.
  # see https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
  SORT_LIST = ["~", ""] + ("A".."Z").to_a + ("a".."z").to_a + PUNCTUATION

  mapping = {}
  SORT_LIST.each_with_index do |char, index|
    mapping[char] = index
  end
  # Set it to a constant
  ORDER_MAPPING = mapping
end