2014-01-20 21:24:22 +00:00
|
|
|
require 'csv'
|
2016-03-20 09:24:23 +00:00
|
|
|
class Api::V1::RepositoryPackagePresenter
|
2014-01-20 21:24:22 +00:00
|
|
|
CSV_HEADERS = {
|
|
|
|
project_owner: 'Project owner',
|
|
|
|
project_name: 'Project name',
|
|
|
|
package_name: 'Package name',
|
|
|
|
epoch: 'Epoch',
|
|
|
|
version: 'Version',
|
|
|
|
release: 'Release',
|
|
|
|
maintainer_uname: 'Maintainer uname',
|
2016-03-20 09:24:23 +00:00
|
|
|
maintainer_email: 'Maintainer email'
|
2014-01-20 21:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
attr_reader :package
|
|
|
|
delegate *%i(project name epoch version release assignee build_list), to: :package
|
|
|
|
|
|
|
|
def initialize(package)
|
|
|
|
@package = package
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_csv_row
|
|
|
|
CSV::Row.new(
|
|
|
|
CSV_HEADERS.keys,
|
|
|
|
[
|
|
|
|
project.owner_uname,
|
|
|
|
project.name,
|
|
|
|
name,
|
|
|
|
epoch,
|
|
|
|
version,
|
|
|
|
release,
|
|
|
|
assignee.uname,
|
2016-03-20 09:24:23 +00:00
|
|
|
assignee.email
|
2014-01-20 21:24:22 +00:00
|
|
|
]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.csv_header
|
|
|
|
# Using ruby's built-in CSV::Row class
|
|
|
|
# true - means its a header
|
|
|
|
CSV::Row.new CSV_HEADERS.keys, CSV_HEADERS.values, true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|