Skip to content

Refactor parts into multipart post namespace#65

Merged
ioquatix merged 4 commits intomasterfrom
refactor_parts_into_multipart_post_namespace
Oct 29, 2019
Merged

Refactor parts into multipart post namespace#65
ioquatix merged 4 commits intomasterfrom
refactor_parts_into_multipart_post_namespace

Conversation

@patrickdavey
Copy link
Contributor

This is part of a refactoring series to move the top level modules (polluting the global namespace) to be nested under the MultipartPost namespace.

This PR moves the Parts module only. If this approach is acceptable, I'll work on the rest.

Thanks!

With current version of rspec with rspec_status file is generated when
the tests are run, ignoring in version control.
@patrickdavey patrickdavey requested a review from ioquatix October 10, 2019 06:38
@ioquatix
Copy link
Member

Thanks for this!

I think because of the name of this gem, the convention should be multipart/post/parts.rb and the namespace should be Multipart::Post::Parts.

What do you think?

Otherwise, we should rename the gem multipart_post but I think that boat has long since sailed.

@patrickdavey
Copy link
Contributor Author

Ah, ok, Yip I can totally do that. I went with MultipartPost because that's what the lib/mutlipart_post.rb was using

Just so as I'm clear, the structure will become:
lib/multipart_post.rb -> lib/multipart/post.rb, and I'll extract the version out of that into lib/multipart/post/version.rb

Want me to close this PR and open a new one? Or just force-push to this?

This changes the namespace for the gem from MultipartPost into
Multipart::Post to match the actual name of the gem.

This also extracts out of the global namespace the Parts module to live
instead under Multipart::Post::Parts
@patrickdavey patrickdavey force-pushed the refactor_parts_into_multipart_post_namespace branch from 484d14c to 0791589 Compare October 10, 2019 07:18
@ioquatix
Copy link
Member

Force push is fine. Response to other points coming shortly.

@ioquatix
Copy link
Member

Just so as I'm clear, the structure will become:
lib/multipart_post.rb -> lib/multipart/post.rb

Yes, just make subdirectories to match modules.

I also think the deeply nested Parts module could perhaps be simplified, but I'll leave that up to you to think about. Feel free to make a proposal before doing it if you want feedback.

and I'll extract the version out of that into lib/multipart/post/version.rb

Yes, perfect.

@ioquatix
Copy link
Member

What we can probably do for compatibility is have the old multipart_post.rb with a bunch of aliases/constants to match the old layout, along with a deprecation warning, e.g.

Parts = Multipart::Post::Parts

Just moves the CompositeReadIO out into the Multipart::Post namespace.
This is the last of the top level namespace polluting modules moved out.
The tests are all passing (however, I can't comment on how complete the test coverage is)
@patrickdavey
Copy link
Contributor Author

Sorry that paused for a while, work has been somewhat busy for a bit :)

Anyway, let me know if you're happy with the current version. This PR should probably be closed & reopened / renamed at some point, as it's no longer about Parts (which was all I signed up for ;) ) heh. I've now removed (I think) all of the top-level polluting files out under the Multipart::Post namespace.

I'm not planning on refactoring/reworking the code itself, however, happy to try work in those deprecations. That's not something I've done before, so, I'll setup the aliases/constants [as you suggested(https://github.com//pull/65#issuecomment-540436358) and then probably do what's suggested on stack overflow (though that is more for methods than Constants... maybe there's another sneaky way?)

@ioquatix ioquatix merged commit bfadd4f into master Oct 29, 2019
@ioquatix
Copy link
Member

LGTM. Make further modifications on a new PR.

@ioquatix
Copy link
Member

Please add your name to copyright in readme.

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.

2 participants