Update to Rails 7.2
This commit is contained in:
parent
932a43daac
commit
25672aabb0
31 changed files with 836 additions and 435 deletions
|
|
@ -14,13 +14,12 @@ require 'pp'
|
|||
# Next it loads the Packages lists (prefers bz2, falls back to
|
||||
# .gz or even the uncompressed version).
|
||||
module DebImporter
|
||||
|
||||
# Defines a Debian release
|
||||
class Release
|
||||
attr_reader :architectures, :components, :description, :codename, :origin, :version, :files
|
||||
|
||||
# Load and parse a Release file of an APT repository
|
||||
def initialize(dist_url) # rubocop:disable Metrics/MethodLength
|
||||
def initialize(dist_url)
|
||||
@dist_url = dist_url
|
||||
release_url = "#{dist_url}/Release"
|
||||
Rails.logger.debug "Loading Release file from #{release_url}"
|
||||
|
|
@ -42,11 +41,9 @@ module DebImporter
|
|||
def i18n(component, language)
|
||||
url = "#{@dist_url}/#{component}/i18n/Translation-#{language}"
|
||||
file = find_and_open_compressed_url(url)
|
||||
if file
|
||||
return get_paragraphs(file)
|
||||
else
|
||||
return []
|
||||
end
|
||||
return get_paragraphs(file) if file
|
||||
|
||||
[]
|
||||
end
|
||||
|
||||
# Look for the file or URL in various compressed formats
|
||||
|
|
@ -66,14 +63,14 @@ module DebImporter
|
|||
file2 = nil
|
||||
|
||||
# Decompress file depending on its filename suffix
|
||||
case suffix
|
||||
when '.bz2'
|
||||
file2 = Bzip2::FFI::Reader.read(file)
|
||||
when '.gz'
|
||||
file2 = Zlib::GzipReader.new(file)
|
||||
else # plain text
|
||||
file2 = file
|
||||
end
|
||||
file2 = case suffix
|
||||
when '.bz2'
|
||||
Bzip2::FFI::Reader.read(file)
|
||||
when '.gz'
|
||||
Zlib::GzipReader.new(file)
|
||||
else # plain text
|
||||
file
|
||||
end
|
||||
Rails.logger.debug "File containing translations is: #{url}"
|
||||
|
||||
# Return an enumerator that iterates over lines of the file
|
||||
|
|
@ -112,7 +109,7 @@ module DebImporter
|
|||
when /^(\S+?):$/ # "Key:" (start of multi-line entry without value in line)
|
||||
fields[name.to_sym] = value unless value.empty?
|
||||
name = $1
|
||||
value = ""
|
||||
value = ''
|
||||
when /^\s(.+)/ # " Indented multi-line value"
|
||||
# Add a newline for multi-line entries ("Key: Value\n Foo\n Bar")
|
||||
value += "\n" unless value.empty?
|
||||
|
|
@ -138,7 +135,7 @@ module DebImporter
|
|||
gathered_lines = [] # collects all lines belonging to a field
|
||||
|
||||
data.each_line do |line|
|
||||
#Rails.logger.debug("___" + line)
|
||||
# Rails.logger.debug("___" + line)
|
||||
if line.chomp.empty? # empty line found that seperates paragraphs
|
||||
if gathered_lines.any? # any lines gathered so far?
|
||||
# Rails.logger.debug('>>>>>>>>>>>>>>>>>>>>>> Gathered lines:')
|
||||
|
|
@ -156,7 +153,7 @@ module DebImporter
|
|||
enum.yield get_fields(gathered_lines) if gathered_lines.any?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Represents the version of a Debian package
|
||||
class Version
|
||||
attr_reader :epoch, :upstream, :revision, :version_string
|
||||
|
|
@ -165,10 +162,10 @@ module DebImporter
|
|||
@version_string = version_string
|
||||
# Split into "[epoch:]upstream[-revision]"
|
||||
# See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
|
||||
unless /^((?<epoch>\d+)\:)?(?<upstream>.+?)(\-(?<revision>.+))?$/ =~ version_string
|
||||
unless /^((?<epoch>\d+):)?(?<upstream>.+?)(-(?<revision>.+))?$/ =~ version_string
|
||||
raise ArgumentError, "Cannot parse version string: #{version_string}"
|
||||
end
|
||||
|
||||
|
||||
@epoch = epoch || '0'
|
||||
@upstream = upstream
|
||||
@revision = revision if revision
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue