Sha256: c9c6904e533041b70b22360278b22da05da568c9cb8ee62a00e8d3459f088151

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'thor'
require 'yaml'

module Plagiarism
  class Cli < Thor
    include Thor::Actions
    CONFIG_PATH = '~/.plagiarism.yml'

    desc 'init', 'Create file for plagiarism to load config'
    method_option :path, aliases: '-p', desc: 'where put the config', type: :string, default: CONFIG_PATH
    def init
      create_file options[:path], <<-STRING
strategies: "duck, yahoo"
whitelists: "www.ring.md, blog.ring.md"
bing_key: xxx
google_key: xxx
google_cx: xxx
      STRING
    end

    desc 'unique', 'Check the unique content from search engines'
    method_option :content, aliases: '-c', desc: 'content which need to checked', type: :string, required: true
    method_option :path, aliases: '-p', desc: 'where put the config', type: :string, default: CONFIG_PATH
    def unique
      config = YAML.load_file(File.expand_path options[:path])
      Config.strategies = config['strategies'].split(',').map &:strip
      Config.whitelists = config['whitelists'].split(',').map &:strip
      Config.bing_key = config['bing_key']
      Config.google_key = config['google_key']
      Config.google_cx = config['google_cx']

      puts Plagiarism.unique? options[:content]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plagiarism2-0.0.5 lib/plagiarism/cli.rb