<commit_before>require 'uri'

class RepositoryPostReceiveUrl < ActiveRecord::Base
  unloadable

  STATUS_ACTIVE   = true
  STATUS_INACTIVE = false

  attr_accessible :url, :mode, :active, :use_triggers, :triggers, :split_payloads

  ## Relations
  belongs_to :repository

  ## Validations
  validates :repository_id, :presence => true

  ## Only allow HTTP(s) format
  validates :url, :presence   => true,
                  :uniqueness => { :case_sensitive => false, :scope => :repository_id },
                  :format     => { :with => URI::regexp(%w(http https)) }

  validates :mode, :presence => true, :inclusion => { :in => [:github, :get] }

  validates_associated :repository

  ## Serializations
  serialize :triggers, Array

  ## Scopes
  scope :active,   -> { where active: STATUS_ACTIVE }
  scope :inactive, -> { where active: STATUS_INACTIVE }

  ## Callbacks
  before_validation :strip_whitespace

  include GitoliteHooksHelper


  def to_s
    return "#{repository.project.identifier}-#{url}"
  end


  def mode
    read_attribute(:mode).to_sym
  end


  def mode= (value)
    write_attribute(:mode, value.to_s)
  end


  def needs_push(payloads)
    return false if payloads.empty?<commit_msg>Remove useless method<commit_after>require 'uri'

class RepositoryPostReceiveUrl < ActiveRecord::Base
  unloadable

  STATUS_ACTIVE   = true
  STATUS_INACTIVE = false

  attr_accessible :url, :mode, :active, :use_triggers, :triggers, :split_payloads

  ## Relations
  belongs_to :repository

  ## Validations
  validates :repository_id, :presence => true

  ## Only allow HTTP(s) format
  validates :url, :presence   => true,
                  :uniqueness => { :case_sensitive => false, :scope => :repository_id },
                  :format     => { :with => URI::regexp(%w(http https)) }

  validates :mode, :presence => true, :inclusion => { :in => [:github, :get] }

  validates_associated :repository

  ## Serializations
  serialize :triggers, Array

  ## Scopes
  scope :active,   -> { where active: STATUS_ACTIVE }
  scope :inactive, -> { where active: STATUS_INACTIVE }

  ## Callbacks
  before_validation :strip_whitespace

  include GitoliteHooksHelper


  def mode
    read_attribute(:mode).to_sym
  end


  def mode= (value)
    write_attribute(:mode, value.to_s)
  end


  def needs_push(payloads)
    return false if payloads.empty?
{'fraction_non_alphanumeric': 0.11417657045840407, 'fraction_numerical': 0.0, 'mean_word_length': 3.541425818882466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6707200', 'n_tokens_mistral': 784, 'n_tokens_neox': 738, 'n_words': 182}