Sha256: a77f104368545f12b59b73dad58893ea0ec2f78e54bf7c2dac8b056252cb24e0

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 Bytes

Contents

require 'plagiarism/strategries/engine'
require 'plagiarism/strategries/google'
require 'plagiarism/strategries/free_google'
require 'plagiarism/strategries/bing'
require 'plagiarism/strategries/duck'
require 'plagiarism/strategries/yahoo'

module Plagiarism
  module Strategy
    extend self

    def get(name = :free_google)
      Strategies.const_get(name.to_s.split('_').map(&:capitalize).join(''))
    end

    def unique?(content, params)
      Config.strategies.all? do |strategy|
        klass = get(strategy)
        klass.new(content, params).unique?
      end
    end

    def match(content, params)
      Config.strategies.find do |strategy|
        klass = get(strategy)
        link = klass.new(content, params).match
        link and return (link == true ? '' : link)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
plagiarism2-0.0.10 lib/plagiarism/strategy.rb
plagiarism2-0.0.9 lib/plagiarism/strategy.rb
plagiarism2-0.0.8 lib/plagiarism/strategy.rb
plagiarism2-0.0.7 lib/plagiarism/strategy.rb
plagiarism2-0.0.6 lib/plagiarism/strategy.rb