Sha256: ec368fce6962a8b965f11f2afe5e2027b817a05eed264d88216cec83f142d18c

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

#
# Copyright 2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

module Actions
  module Pulp
    module Repository
      module Presenters
        class IsoPresenter < AbstractSyncPresenter
          def progress
            total_bytes == 0 ? 0.01 : finished_bytes.to_f / total_bytes
          end

          private

          def humanized_details
            ret = []
            ret << _("Cancelled.") if cancelled?
            ret << _("New ISOs: %s") % num_isos
            ret.join("\n")
          end

          def num_isos
            task_progress_details && task_progress_details['num_isos'] || 0
          end

          def total_bytes
            task_progress_details && task_progress_details['total_bytes'] || 0
          end

          def finished_bytes
            task_progress_details && task_progress_details['finished_bytes'] || 0
          end

          def task_progress_details
            task_progress && task_progress['iso_importer']
          end

          def task_progress
            sync_task['progress_report']
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 app/lib/actions/pulp/repository/presenters/iso_presenter.rb