Sha256: 6ce7c3253b90f84a010c61c4730244d6748b48ac0cad1d41a4e06c6e7fe76e59

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

#
# Copyright (c) 2014 Red Hat Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 3 (GPLv3). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
# along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
#

require 'digest'

module Scaptimony
  module ArfReportsHelper
    def self.create_arf(asset, params, arf_bzip)
      # TODO:RAILS-4.0: This should become policy = Policy.find_or_create_by!(name: params[:policy])
      policy = Policy.first_or_create!(:name => params[:policy])
      digest = Digest::SHA256.hexdigest arf_bzip
      # TODO:RAILS-4.0: This should become arf_report = ArfReport.find_or_create_by! ...
      arf_report = ArfReport.where(:asset_id => asset.id, :policy_id => policy.id, :date => params[:date], :digest => digest).first_or_create!
      arf_report.store!(arf_bzip)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scaptimony-0.1.0 lib/scaptimony/arf_reports_helper.rb