Sha256: 0b030a381396ef4305f5151c32b57d68326cfbe7786b67815acf03e23d8b9a99

Contents?: true

Size: 1.15 KB

Versions: 10

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require_relative "base"

module Neetob
  class CLI
    module Github
      class Search < Base
        attr_accessor :repos, :key_to_search, :search_file_path, :sandbox

        def initialize(repos, key_to_search, search_file_path, sandbox = false)
          super()
          @repos = repos
          @key_to_search = key_to_search
          @search_file_path = search_file_path
          @sandbox = sandbox
        end

        def run
          matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
          matching_repos.each do |repo|
            begin
              ui.info("\n Searching in \"#{repo}/#{search_file_path}\" for \"#{key_to_search}\"\n")
              content = Base64.decode64(client.contents(repo, path: search_file_path).content)
              ui.error("Keyword not found") and next unless content.include? key_to_search

              content.each_line do |line|
                ui.success(line) if line.include?(key_to_search)
              end
            rescue StandardError => e
              ExceptionHandler.new(e).process
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
neetob-0.4.1 lib/neetob/cli/github/search.rb
neetob-0.4.0 lib/neetob/cli/github/search.rb
neetob-0.3.2 lib/neetob/cli/github/search.rb
neetob-0.3.1 lib/neetob/cli/github/search.rb
neetob-0.3.0 lib/neetob/cli/github/search.rb
neetob-0.2.7 lib/neetob/cli/github/search.rb
neetob-0.2.6 lib/neetob/cli/github/search.rb
neetob-0.2.5 lib/neetob/cli/github/search.rb
neetob-0.2.4 lib/neetob/cli/github/search.rb
neetob-0.2.3 lib/neetob/cli/github/search.rb