Skip to content

Commit

Permalink
adding types and updating the logger
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Aug 12, 2024
1 parent 0c507d7 commit e6f8abe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/octokit/connection.cr
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,12 @@ module Octokit
# pages.fetch_all
# pages.last? # => Bool
# ```
def last?
def last? : Bool
@current_page == @total_pages
end

# Checks if the paginator is empty.
def empty?
def empty? : Bool
@records.empty?
end

Expand Down
19 changes: 10 additions & 9 deletions src/octokit/default.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Octokit
end

# Default access token from ENV
def access_token
def access_token : String?
ENV["OCTOKIT_ACCESS_TOKEN"]?
end

Expand Down Expand Up @@ -76,7 +76,7 @@ module Octokit
end

# Default options for `Halite::Options`
def connection_options
def connection_options : Halite::Options
Halite::Options.new(
headers: {
accept: default_media_type,
Expand All @@ -90,7 +90,7 @@ module Octokit
end

# Default GitHub username for Basic Auth from ENV
def login
def login : String?
ENV["OCTOKIT_LOGIN"]?
end

Expand All @@ -100,12 +100,12 @@ module Octokit
end

# Default GitHub password for Basic Auth from ENV
def password
def password : String?
ENV["OCTOKIT_PASSWORD"]?
end

# Default pagination page size from ENV
def per_page
def per_page : Int32?
page_size = ENV["OCTOKIT_PER_PAGE"]?
page_size.to_i if page_size
end
Expand All @@ -117,26 +117,27 @@ module Octokit
end

# Default SSL verify mode from ENV
def ssl_verify_mode
def ssl_verify_mode : Int32
# 0 is OpenSSL::SSL::NONE
# 1 is OpenSSL::SSL::PEER
# the standard default for SSL is PEER which requires a server certificate check on the client
ENV.fetch("OCTOKIT_SSL_VERIFY_MODE", "1").to_i
end

# Default User-Agent header string from ENV or `USER_AGENT`
def user_agent
def user_agent : String
ENV["OCTOKIT_USER_AGENT"]? || USER_AGENT
end

# Default web endpoint from ENV or `WEB_ENDPOINT`
def web_endpoint
def web_endpoint : String
ENV["OCTOKIT_WEB_ENDPOINT"]? || WEB_ENDPOINT
end

# Default logger
def logger
Log.setup(:warn)
log_level = ENV["OCTOKIT_LOG_LEVEL"]?.to_s.upcase || "INFO".to_s.upcase
Log.setup(log_level)
::Log.for(self)
end
end
Expand Down

0 comments on commit e6f8abe

Please sign in to comment.