Module: Grepfruit
- Defined in:
- lib/grepfruit.rb,
lib/grepfruit/cli.rb,
lib/grepfruit/search.rb,
lib/grepfruit/version.rb,
lib/grepfruit/cli_search.rb,
lib/grepfruit/cli_decorator.rb,
lib/grepfruit/ractor_compat.rb,
lib/grepfruit/search_results.rb,
lib/grepfruit/programmatic_search.rb
Defined Under Namespace
Modules: CliDecorator, Commands, RactorCompat Classes: CLI, CliSearch, ProgrammaticSearch, Search, SearchResults
Constant Summary collapse
- VERSION =
"4.0.1".freeze
Class Method Summary collapse
Class Method Details
.search(regex:, path: ".", exclude: [], include: [], truncate: nil, search_hidden: false, jobs: nil, count: false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/grepfruit.rb', line 9 def self.search(regex:, path: ".", exclude: [], include: [], truncate: nil, search_hidden: false, jobs: nil, count: false) raise ArgumentError, "regex is required" unless regex.is_a?(Regexp) raise ArgumentError, "path must be a string" unless path.is_a?(String) raise ArgumentError, "exclude must be an array" unless exclude.is_a?(Array) raise ArgumentError, "include must be an array" unless include.is_a?(Array) raise ArgumentError, "truncate must be a positive integer" if truncate && (!truncate.is_a?(Integer) || truncate <= 0) raise ArgumentError, "search_hidden must be a boolean" unless [true, false].include?(search_hidden) raise ArgumentError, "count must be a boolean" unless [true, false].include?(count) raise ArgumentError, "jobs must be at least 1" if jobs && (!jobs.is_a?(Integer) || jobs < 1) ProgrammaticSearch.new( path: path, regex: regex, exclude: exclude, include: include, truncate: truncate, search_hidden: search_hidden, jobs: jobs, json: false, count: count ).execute end |