class Archlinux::PacmanConf
Attributes
config[RW]
pacman_conf[RW]
Public Class Methods
create(v, config: Archlinux.config)
click to toggle source
# File lib/aur/devtools.rb, line 5 def self.create(v, config: Archlinux.config) v.is_a?(self) ? v : self.new(v, config: config) #pass empty keywords so that a Hash is seen as an argument and not a list of keywords end
new(conf="/etc/pacman.conf", config: Archlinux.config, **keys)
click to toggle source
# File lib/aur/devtools.rb, line 12 def initialize(conf="/etc/pacman.conf", config: Archlinux.config, **keys) @config=config if conf.is_a?(String) or conf.is_a?(Pathname) conf=parse(conf, **keys) end @pacman_conf=conf end
parse(content)
click to toggle source
# File lib/aur/devtools.rb, line 20 def self.parse(content) list=%i(HoldPkg IgnorePkg IgnoreGroup NoUpgrade NoExtract SigLevel LocalFileSigLevel RemoteFileSigLevel Usage Server) mode=:options config={options: {}, repos: {}} content=content.each_line if content.is_a?(String) content.each do |l| if (m=l.match(/^\[([\w-]+)\]$/)) mode=m[1] if mode == "options" mode=:options else config[:repos][mode]||={} end else key, value=l.split(' = ', 2) key=key.to_sym h = mode==:options ? config[:options] : config[:repos][mode] if list.include?(key) h[key]||=[] h[key] << value else h[key]=value end end end config end
Public Instance Methods
non_official_repos()
click to toggle source
# File lib/aur/devtools.rb, line 62 def non_official_repos repos=@pacman_conf[:repos] repos.slice(*(repos.keys - %w(core extra community multilib testing community-testing multilib-testing))) end
parse(file, raw: false, args: nil)
click to toggle source
# File lib/aur/devtools.rb, line 48 def parse(file, raw: false, args: nil) unless args if raw args=[:'pacconf', "--raw", "--config=#{file}"] else args=[:'pacman-conf', "--config=#{file}"] end end output=@config.launch(*args) do |*args| SH.run_simple(*args, chomp: :lines) end self.class.parse(output) end
tempfile()
click to toggle source
# File lib/aur/devtools.rb, line 89 def tempfile SH::VirtualFile.new("pacman.conf", to_s) end
to_s()
click to toggle source
# File lib/aur/devtools.rb, line 67 def to_s r=[] print_values=lambda do |h, section| r<<"[#{section}]" if section h.each do |k,v| case v when nil r << k when Array v.each { |vv| r << "#{k} = #{vv}" } else r << "#{k} = #{v}" end end end print_values.call(@pacman_conf[:options], "options") @pacman_conf[:repos].each do |section, props| print_values.call(props, section) end r.join("\n")+"\n" end