[yast-commit] <rest-service> master : background_status.rb has been moved to the base package
ref: refs/heads/master commit 0063ee1b0deaac7579b0452c1afeb09f7d261e40 Author: Ladislav Slezak <lslezak@novell.com> Date: Tue Dec 15 15:19:27 2009 +0100 background_status.rb has been moved to the base package so it can be used in other plugins (the status plugin currently) --- plugins/patches/app/models/background_status.rb | 56 ----------------------- webservice/lib/background_status.rb | 56 +++++++++++++++++++++++ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/plugins/patches/app/models/background_status.rb b/plugins/patches/app/models/background_status.rb deleted file mode 100644 index b7f7127..0000000 --- a/plugins/patches/app/models/background_status.rb +++ /dev/null @@ -1,56 +0,0 @@ -# This class collects progress data of a background process - -class BackgroundStatus - - attr_reader :status, - :progress, - :subprogress - - def initialize(stat = 'unknown', progress = 0, subprogress = nil, &block) - @status = stat - @progress = progress - @subprogress = subprogress - @callback = block_given? ? block : nil - end - - def status=(status) - if @status != status - @status = status - trigger_callback - end - end - - def progress=(p) - if @progress != p - @progress = p - trigger_callback - end - end - - def subprogress=(s) - if @subprogress != s - @subprogress = s - trigger_callback - end - end - - def to_xml(options = {}) - xml = options[:builder] ||= Builder::XmlMarkup.new(options) - xml.instruct! unless options[:skip_instruct] - - xml.tag! :background_status do - xml.tag!(:status, @status) - xml.tag!(:progress, @progress.to_i, {:type => "integer"} ) - xml.tag!(:subprogress, @subprogress.to_i, {:type => "integer"}) - end - end - - private - - def trigger_callback - if @callback - @callback.call - end - end - -end diff --git a/webservice/lib/background_status.rb b/webservice/lib/background_status.rb new file mode 100644 index 0000000..b7f7127 --- /dev/null +++ b/webservice/lib/background_status.rb @@ -0,0 +1,56 @@ +# This class collects progress data of a background process + +class BackgroundStatus + + attr_reader :status, + :progress, + :subprogress + + def initialize(stat = 'unknown', progress = 0, subprogress = nil, &block) + @status = stat + @progress = progress + @subprogress = subprogress + @callback = block_given? ? block : nil + end + + def status=(status) + if @status != status + @status = status + trigger_callback + end + end + + def progress=(p) + if @progress != p + @progress = p + trigger_callback + end + end + + def subprogress=(s) + if @subprogress != s + @subprogress = s + trigger_callback + end + end + + def to_xml(options = {}) + xml = options[:builder] ||= Builder::XmlMarkup.new(options) + xml.instruct! unless options[:skip_instruct] + + xml.tag! :background_status do + xml.tag!(:status, @status) + xml.tag!(:progress, @progress.to_i, {:type => "integer"} ) + xml.tag!(:subprogress, @subprogress.to_i, {:type => "integer"}) + end + end + + private + + def trigger_callback + if @callback + @callback.call + end + end + +end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
Ladislav Slezak