Sha256: 782317e74f32323f761918d072af9e1b3ce72fe5fe6bcd14ff24c07ddf37a0f4

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'censor_bear/version'
require 'censor_bear/engine'
require 'censor_bear/censor'
require 'censor_bear/configuration'

require 'hamlit'
require 'pagy'

module CensorBear
  class NotPassedException < StandardError; end

  class << self
    def config
      return @config if defined?(@config)

      @config = Configuration.new
      @config.user_class = 'User'
      @config.current_user_method = 'current_user'
      @config.user_name_method = 'name'
      @config.import_file_path = "#{Rails.root}/tmp/dest_sensitives.txt"
      @config.format_from_file_path = "#{Rails.root}/tmp/from_sensitives.txt"
      @config.format_dest_file_path = "#{Rails.root}/tmp/dest_sensitives.txt"
      @config
    end

    def configure
      yield(config)
    end

    def check_text(content, type = 'ugc')
      Censor.new(content, type).check_text
    end

    def check_search(content)
      Censor.new(content, "ugc").check_search
    end

    def info(content, scenario, action, stage, options = {})
      filtered_content = options[:filtered_content] || nil
      mod_words = options[:mod_words] || []

      CensorBear::Log.create(
        original_content: content,
        scenario: scenario,
        action: action,
        stage: stage,
        filtered_content: filtered_content,
        mod_words: mod_words
      )
    end

    def action_options
      I18n.t('censor_log.action').map { |k, v| [v, k.to_s] }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
censor_bear-0.1.6 lib/censor_bear.rb
censor_bear-0.1.5 lib/censor_bear.rb