Commit 0689344c authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

apkbuild-gem-resolver: augeas object as class member

parent 3764ff5a
...@@ -13,25 +13,26 @@ class Package ...@@ -13,25 +13,26 @@ class Package
@@packages = {} @@packages = {}
def self.initialize testing def self.initialize testing
Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD) do |aug| @@augeas = Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD)
dir = Dir.pwd dir = Dir.pwd
aug.transform(:lens => 'Shellvars.lns', :incl => dir + '/*/ruby*/APKBUILD') @@augeas.transform(
aug.load :lens => 'Shellvars.lns', :incl => dir + '/*/ruby*/APKBUILD'
)
apath = '/files' + dir @@augeas.load
fail if aug.match("/augeas#{apath}//error").length > 0
apath = '/files' + dir
repos = ['main'] fail if @@augeas.match("/augeas#{apath}//error").length > 0
repos << 'testing' if testing
for repo in repos repos = ['main']
for pkg in aug.match "#{apath}/#{repo}/*" repos << 'testing' if testing
Aport.new(aug, pkg) unless pkg.end_with? '/ruby' for repo in repos
end for pkg in @@augeas.match "#{apath}/#{repo}/*"
Aport.new(pkg) unless pkg.end_with? '/ruby'
end end
Subpackage.initialize aug.get("#{apath}/main/ruby/APKBUILD/pkgver")
end end
Subpackage.initialize @@augeas.get("#{apath}/main/ruby/APKBUILD/pkgver")
@@packages.each_value do |pkg| @@packages.each_value do |pkg|
pkg.depends do |dep| pkg.depends do |dep|
dep.add_user pkg dep.add_user pkg
...@@ -81,11 +82,11 @@ class Package ...@@ -81,11 +82,11 @@ class Package
end end
class Aport < Package class Aport < Package
def initialize aug, path def initialize path
name = path.split('/')[-1] name = path.split('/')[-1]
get = proc{ |param| get = proc{ |param|
res = aug.get(path + '/APKBUILD/' + param) res = @@augeas.get(path + '/APKBUILD/' + param)
raise param + ' not defined for ' + name unless res raise param + ' not defined for ' + name unless res
res res
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment