Class: EndOfLife::Repository
- Inherits:
-
Object
- Object
- EndOfLife::Repository
- Defined in:
- lib/end_of_life/repository.rb
Instance Attribute Summary collapse
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
Class Method Summary collapse
Instance Method Summary collapse
- #eol_ruby?(at: Date.today) ⇒ Boolean
-
#initialize(full_name:, url:, github_client:) ⇒ Repository
constructor
A new instance of Repository.
- #ruby_version ⇒ Object
Constructor Details
#initialize(full_name:, url:, github_client:) ⇒ Repository
Returns a new instance of Repository.
61 62 63 64 65 |
# File 'lib/end_of_life/repository.rb', line 61 def initialize(full_name:, url:, github_client:) @full_name = full_name @url = url @github_client = github_client end |
Instance Attribute Details
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
59 60 61 |
# File 'lib/end_of_life/repository.rb', line 59 def full_name @full_name end |
Class Method Details
.fetch(options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/end_of_life/repository.rb', line 6 def fetch() github_client.bind do |github| github.auto_paginate = true [:user] ||= github.user.login query = search_query_for() items = github.search_repositories(query).items Success( items.map do |repo| Repository.new( full_name: repo.full_name, url: repo.html_url, github_client: github ) end ) rescue => e Failure("Unexpected error: #{e}") end end |
.github_client ⇒ Object
28 29 30 31 32 |
# File 'lib/end_of_life/repository.rb', line 28 def github_client Maybe(ENV["GITHUB_TOKEN"]) .fmap { |token| Octokit::Client.new(access_token: token) } .or { Failure("Please set GITHUB_TOKEN environment variable") } end |
.search_query_for(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/end_of_life/repository.rb', line 34 def search_query_for() query = "language:ruby" query += if [:repository] " repo:#{[:repository]}" elsif [:organizations] [:organizations].map { |org| " org:#{org}" }.join else " user:#{[:user]}" end if [:visibility] query += " is:#{[:visibility]}" end if [:excludes] words_to_exclude = [:excludes].map { |word| "NOT #{word} " }.join query += " #{words_to_exclude} in:name" end query end |
Instance Method Details
#eol_ruby?(at: Date.today) ⇒ Boolean
67 68 69 |
# File 'lib/end_of_life/repository.rb', line 67 def eol_ruby?(at: Date.today) ruby_version&.eol?(at: at) end |
#ruby_version ⇒ Object
71 72 73 74 75 |
# File 'lib/end_of_life/repository.rb', line 71 def ruby_version return @ruby_version if defined?(@ruby_version) @ruby_version = ruby_versions.min end |