-
Notifications
You must be signed in to change notification settings - Fork 43
Make things a bit more OO #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
class GitHubPages | ||
class HealthCheck | ||
if File.exists?(File.expand_path ".env", File.dirname(__FILE__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd vendor a .env
inside of lib/
?
attr_reader :host | ||
|
||
def initialize(host) | ||
@host = host_from_uri(host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to defensively check the input here:
raise ArgumentError, "Expected string, got #{host.class}" unless host.is_a? String
I see a lot of undefined method for NilClass:nil
in our future without it :)
|
||
def initialize(name_with_owner, access_token: nil) | ||
unless name_with_owner =~ REPO_REGEX | ||
raise GitHubPages::HealthCheck::Errors::InvalidRepositoryError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the rest of the class, this should either be Errors::InvalidRepositoryError
, or all the others should have GitHubPages::HealthCheck::
😄
@parkr believe this should be ready for one more 👀, when you're ready. I believe I implemented everything you mentioned, plus tests, and simplified the |
> check.valid? | ||
=> false | ||
> check.valid! | ||
=> GitHubPages::HealthCheck::InvalidCNAME | ||
=> GitHubPages::HealthCheck::Errors::InvalidCNAMEError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this return the class or raise an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raises. What's the best way to note that?
Can we also ship #37? |
This pull request started out as an attempt to add a
Repository
class, that could accept a repository name and retrieve the repository's CNAME, but expanded to abstract much of the check logic out of a single giant class, into more object-oriented classes. Specifically:Domain
classRepository
classSite
class to encompassDomain
andRepository
checkscheck!
,valid?
andreason
logic to aCheckable
classErrors
class to autoload all errorsGitHubPages
andHealthCheck
modules, not classesStill to do: