Class: EnhanceRepo::RpmMd::SuseInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/enhance_repo/rpm_md/suse_info.rb

Overview

represents SUSE extensions to repository metadata (not associated with packages)

See: en.opensuse.org/Standards/Rpm_Metadata#SUSE_repository_info_.28suseinfo.xml.29

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#metadata_filename, #name, #should_compress?

Methods included from Logger

#log

Constructor Details

#initialize(dir) ⇒ SuseInfo

Returns a new instance of SuseInfo.



48
49
50
51
52
53
# File 'lib/enhance_repo/rpm_md/suse_info.rb', line 48

def initialize(dir)
  @dir = dir
  @expire = nil
  @keywords = Set.new
  @products = Set.new
end

Instance Attribute Details

#expireObject

expiration time the generated value is still calculated from repomd.xml resources



44
45
46
# File 'lib/enhance_repo/rpm_md/suse_info.rb', line 44

def expire
  @expire
end

#keywordsObject

Returns the value of attribute keywords.



46
47
48
# File 'lib/enhance_repo/rpm_md/suse_info.rb', line 46

def keywords
  @keywords
end

#productsObject

Returns the value of attribute products.



45
46
47
# File 'lib/enhance_repo/rpm_md/suse_info.rb', line 45

def products
  @products
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/enhance_repo/rpm_md/suse_info.rb', line 55

def empty?
  @expire.nil? && @products.empty? && @keywords.empty?
end

#write(file) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/enhance_repo/rpm_md/suse_info.rb', line 59

def write(file)
  builder = Builder::XmlMarkup.new(target: file, indent: 2)
  builder.instruct!
  builder.suseinfo do
    # add expire tag
    b.expire(@expire.to_i.to_s) unless @expire.nil?

    unless @keywords.empty?
      b.keywords do
        @keywords.each do |k|
          b.k(k)
        end
      end
    end

    unless @products.empty?
      b.products do
        @products.each do |p|
          b.id(p)
        end
      end
    end
  end
end