Class: EndOfLife::Repository::Search
- Inherits:
-
Object
- Object
- EndOfLife::Repository::Search
- Defined in:
- lib/end_of_life/repository/search.rb,
lib/end_of_life/repository/search/query.rb
Constant Summary collapse
- Query =
Data.define(:options) do def to_s query = [:product].search_query query += if [:repository] " repo:#{options[:repository]}" elsif [:organizations] [:organizations].map { |org| " org:#{org}" }.join else " user:#{options[:user]}" end if [:visibility] query += " is:#{options[:visibility]}" end if [:excludes] words_to_exclude = [:excludes].map { |word| "NOT #{word} " }.join query += " #{words_to_exclude} in:name" end query end end
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Search
constructor
A new instance of Search.
- #result ⇒ Object
Constructor Details
#initialize(options) ⇒ Search
Returns a new instance of Search.
8 9 10 |
# File 'lib/end_of_life/repository/search.rb', line 8 def initialize() = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/end_of_life/repository/search.rb', line 6 def end |
Instance Method Details
#result ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/end_of_life/repository/search.rb', line 12 def result github_client.bind do |github| github.auto_paginate = true [:user] ||= github.user.login query = Query.new().to_s items = github.search_repositories(query, {sort: :updated}).items Success( items.filter_map do |repo| next if repo.archived && [:skip_archived] Repository.new( full_name: repo.full_name, url: repo.html_url, github_client: github ) end ) rescue => e Failure("Unexpected error: #{e}") end end |