Skip to content
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

Refactor make code more idiomatic #18

Conversation

gonzalo-bulnes
Copy link
Contributor

@gonzalo-bulnes gonzalo-bulnes commented Jul 27, 2016

As a Ruby developer
In order to make the gem maintenance easier
I want its code to be as simple as possible
And as idiomatic as possible

See #13
Fixes #9

Since the contribution is substantial, and following the usage
instructions described in https://www.gnu.org/licenses/gpl-howto.html
These lists of files are not modified often, and the Git versions
are cryptic enough to allow useless files to be added to the gem.
The entry points for the gem are:
- the executable, which depends on the FileLoader and Server
- the include in the hooks files, which I suggest taking care of later

I think that the executable should probably not know about the internal
organization of the gem, but it's mostly matter of appreciation (YMMV).
The FileLoader.unique_paths is not part of its API and should not
be used by other classes/modules.
Asserting on the objects class is not used much in Ruby, and
in this case it was used in case 'hooks' were nil.
Instead, 'hooks' could default to an empty array (which conveys
more meaning that nil) and it would always responds to "#each".

The solution only builds on top of the existing duplication,
but that's a different problem.
Minor use parens around arguments in method definitions and
non-trivial method calls.
Minor refactor use Array#inject to group statements
Minor use parens in multi-arguments method calls
@gonzalo-bulnes gonzalo-bulnes merged commit 3e19d75 into apiaryio:master Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant