Class: MiddleSquid::CLI
- Inherits:
-
Thor
- Object
- Thor
- MiddleSquid::CLI
- Defined in:
- lib/middle_squid/cli.rb
Instance Method Summary collapse
-
#index(*directories) ⇒ Object
Populates the database from one or more blacklists.
-
#start ⇒ Object
Runs the given configuration file.
-
#version ⇒ Object
Shows MiddleSquid’s version and copyright notice.
Instance Method Details
#index(*directories) ⇒ Object
Builder#database must be called in your configuration script in order to initialize the database.
Populates the database from one or more blacklists.
Flags:
- -a, --append, --no-append
-
Whether to keep the entries already in the database.
- --domains, --no-domains
-
Whether to index domain lists.
Enabled by default.
- --full, --no-full
-
Whether to index all blacklist categories. By default MiddleSquid will only read the categories registered using Builder#blacklist in the configuration script.
Enable if you want to reuse the same database in multiple configurations set to use different blacklist categories and you need to index everything.
- -q, --quiet, --no-quiet
-
Whether to disable status output.
- --urls, --no-urls
-
Whether to index url lists.
Enabled by default.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/middle_squid/cli.rb', line 75 def index(*directories) config_file = File. [:'config-file'] directories.map! {|rel| File. rel } builder = Builder.from_file config_file entries = [] entries << :url if [:urls] entries << :domain if [:domains] indexer = MiddleSquid::Indexer.new indexer.blacklists = builder.blacklists indexer.append = [:append] indexer.entries = entries indexer.full_index = [:full] indexer.quiet = [:quiet] indexer.index directories end |
#start ⇒ Object
Runs the given configuration file.
17 18 19 20 21 22 23 |
# File 'lib/middle_squid/cli.rb', line 17 def start config_file = File. [:'config-file'] builder = Builder.from_file config_file MiddleSquid::Runner.new builder end |
#version ⇒ Object
Shows MiddleSquid’s version and copyright notice.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/middle_squid/cli.rb', line 101 def version puts "MiddleSquid #{MiddleSquid::VERSION}" puts <<GPL Copyright (C) 2014 by Christian Fillion This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. GPL end |