Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 46ee3d54 authored by Jonathan Riddell's avatar Jonathan Riddell 🏄

more options

parent 10967cd2
...@@ -23,16 +23,31 @@ ...@@ -23,16 +23,31 @@
require 'optparse' require 'optparse'
require_relative 'lib/appstream-metainfo-release-update' require_relative 'lib/appstream-metainfo-release-update'
@date = "today"
@release_to_show = 0
parser = do |opts| parser = do |opts|
opts.banner = <<-EOS opts.banner = <<-EOS
Usage: appstream-metainfo-release-update '' Usage: appstream-metainfo-release-update ''
opts.on("-v", "--version VERSION",
"version to add") do |vers|
@version << vers
opts.on("-d", "--datestring DATE_STRING",
"date to use 'today' 'next Thursday' etc") do |date_string|
@date << date_string
opts.on("-r", "--releases_to_show RELEASES_TO_SHOW",
"how many releases to include in file") do |releases_to_show|
@releases_to_show = releases_to_show || 0
end end
parser.parse! parser.parse!
abort if ARGV.empty? abort if ARGV.empty?
file_name = ARGV[0] file_name = ARGV[0]
updater = updater =, @version, @date, @releases_to_show)
updater.open_file updater.open_file
updater.save_file updater.save_file
...@@ -27,15 +27,19 @@ class MetaInfoUpdater ...@@ -27,15 +27,19 @@ class MetaInfoUpdater
attr_accessor :filename attr_accessor :filename
attr_accessor :doc attr_accessor :doc
attr_accessor :testing attr_accessor :testing
attr_accessor :version
attr_accessor :date_string
attr_accessor :releases_to_show
def initialize(filename, testing = false) def initialize(filename, version, date_string="today", releases_to_show=0)
@filename = filename @filename = filename
@testing = testing @version = version
@date_string = date_string
@releases_to_show = releases_to_show
end end
def open_file def open_file
puts "Filename #{@filename}" abort "No such file" if not File.exists?(@filename)
# TODO check file exists etc
@doc = { |f| Nokogiri::XML(f, &:noblanks) } @doc = { |f| Nokogiri::XML(f, &:noblanks) }
component = @doc.at_css("component") component = @doc.at_css("component")
releases = component.add_child("<releases><release version='1.0' date='today'/></releases>") releases = component.add_child("<releases><release version='1.0' date='today'/></releases>")
require 'minitest/autorun' require 'minitest/autorun'
require_relative '../lib/appstream-metainfo-release-update' require_relative '../lib/appstream-metainfo-release-update'
class MetaInfoUpdaterTest < MiniTest::Unit::TestCase class MetaInfoUpdaterTest < MiniTest::Test
def test_new_release def test_new_release
updater ="data/no-releases.appdata.xml", true) updater ="data/no-releases.appdata.xml", "1.0")
updater.testing = true
updater.open_file updater.open_file
updater.save_file updater.save_file
# open the __FILE__
# do the thing
# compare the file
assert_equal("data/no-releases.appdata.xml.testout"),"data/no-releases.appdata.xml.good")) assert_equal("data/no-releases.appdata.xml.testout"),"data/no-releases.appdata.xml.good"))
end end
end end
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