<commit_before>require 'resource_feeder/common'
class RssFeed < ApplicationRecord
  include ResourceFeeder
  validates_presence_of     :name
  validates_uniqueness_of   :name

  attr_accessor :options

  acts_as_miq_taggable
  include_concern 'ImportExport'

  YML_DIR = File.join(File.expand_path(Rails.root), "product", "alerts", "rss")

  def url(host = nil)
    proto = VMDB::Config.new("vmdb").config[:webservices][:consume_protocol]
    host_url = host.nil? ? "#{proto}://localhost:3000" : "#{proto}://" + host
    "#{host_url}#{link}"
  end

  def generate(host = nil, local = false, proto = nil)
    proto ||= VMDB::Config.new("vmdb").config[:webservices][:consume_protocol]
    host_url = host.nil? ? "#{proto}://localhost:3000" : "#{proto}://" + host

    options = {
      :feed => {
        :title       => title.to_s,
        :link        => "#{host_url}#{link}",
        :description => description.to_s
      },
      :item => {
        :title       => proc { |rec| RssFeed.eval_item_attr(self.options[:item_title], rec) },
        :description => proc { |rec| RssFeed.eval_item_attr(self.options[:item_description], rec) },
        :link        => proc { |rec| host_url + RssFeed.eval_item_attr(self.options[:item_link], rec) },
        :pub_date    => [:created_at, :created_on, :updated_at, :updated_on]
      }
    }

    feed = Rss.rss_feed_for(find_items, options)
    local ? feed : {:text => feed, :content_type => Mime[:rss]}
  end
<commit_msg>use ::Settings in 'rss_feed.rb'<commit_after>require 'resource_feeder/common'
class RssFeed < ApplicationRecord
  include ResourceFeeder
  validates_presence_of     :name
  validates_uniqueness_of   :name

  attr_accessor :options

  acts_as_miq_taggable
  include_concern 'ImportExport'

  YML_DIR = File.join(File.expand_path(Rails.root), "product", "alerts", "rss")

  def url(host = nil)
    proto = ::Settings.webservices.consume_protocol
    host_url = host.nil? ? "#{proto}://localhost:3000" : "#{proto}://" + host
    "#{host_url}#{link}"
  end

  def generate(host = nil, local = false, proto = nil)
    proto ||= ::Settings.webservices.consume_protocol
    host_url = host.nil? ? "#{proto}://localhost:3000" : "#{proto}://" + host

    options = {
      :feed => {
        :title       => title.to_s,
        :link        => "#{host_url}#{link}",
        :description => description.to_s
      },
      :item => {
        :title       => proc { |rec| RssFeed.eval_item_attr(self.options[:item_title], rec) },
        :description => proc { |rec| RssFeed.eval_item_attr(self.options[:item_description], rec) },
        :link        => proc { |rec| host_url + RssFeed.eval_item_attr(self.options[:item_link], rec) },
        :pub_date    => [:created_at, :created_on, :updated_at, :updated_on]
      }
    }

    feed = Rss.rss_feed_for(find_items, options)
    local ? feed : {:text => feed, :content_type => Mime[:rss]}
  end

{'fraction_non_alphanumeric': 0.16012396694214875, 'fraction_numerical': 0.005509641873278237, 'mean_word_length': 3.2657856093979443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3587449', 'n_tokens_mistral': 1023, 'n_tokens_neox': 1000, 'n_words': 177}