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

[Issue #47] CLI naming clash when run under Bundler #48

Merged
merged 1 commit into from
Apr 5, 2014
Merged

[Issue #47] CLI naming clash when run under Bundler #48

merged 1 commit into from
Apr 5, 2014

Conversation

zph
Copy link
Contributor

@zph zph commented Apr 5, 2014

Fixes a load_path naming clash [#47] when bin/approvals is run under Bundler.

Looks like it's picking up a different CLI lib from Thor instead of the
Approvals::CLI.

Verified by renaming cli.rb to something else & updating the require
statement to avoid naming clash.

Fixes a load_path naming clash when `bin/approvals` is run under
Bundler.

Looks like it's picking up a different `CLI` lib from Thor instead of
the `Approvals::CLI`.

Verified by renaming `cli.rb` to something else & updating the `require`
statement to avoid naming clash.
@zph
Copy link
Contributor Author

zph commented Apr 5, 2014

Feel free to choose a different name for the file, but expanding it out to commandline.rb worked in my development env.

Also, 👍 for this gem. Saved me a fair bit of effort w/ a hairy logic-filled Rails view refactor.

@markijbema
Copy link
Contributor

Thanks for noticing :)

This PR seems to shift the problem though. If someone has a commandline gem, this will break, right? I think the proper way would be to require 'approvals/cli' or 'approvals/commandline'. Since that's scoped within approvals it won't collide with anything (except perhaps hypothetical approval-plugins)

@markijbema
Copy link
Contributor

Heh, cool. You discovered this gem to solve almost exactly the same usecase as I had to solve when I discovered it :)

@zph
Copy link
Contributor Author

zph commented Apr 5, 2014

@markijbema This is true (re shifting problem). In retrospect, it was a this is 1am, this works rather than going through git history to see why it changed between v0.0.12 and v0.0.13.

I'll submit an updated PR :)

@zph
Copy link
Contributor Author

zph commented Apr 5, 2014

2b0527a by @kytrinyx is where this was changed (ie mv lib/approvals/utilities/cli.rb lib/cli.rb).

@kytrinyx, what do you think of keeping cli.rb in a scoped location? It will help when approvals is operated under Bundler.

@kytrinyx
Copy link
Contributor

kytrinyx commented Apr 5, 2014

Yeah, we should probably namespace it, but I want it to not live underneath the lib/approvals directory. Here's my thinking:

Everything under lib/approvals is the domain/business logic. For any UI (for example we might add a tiny sinatra app that lets you look at diffs in a browser), each UI would be a top-level file+dir within lib/, so maybe:

.
└── lib
    ├── app
    │   └── views-or-something.rb
    ├── app.rb
    ├── approvals
    │   ├── logic.rb
    │   └── stuff.rb
    ├── cli
    │   └── cli-specific-logic.rb
    └── cli.rb

kytrinyx added a commit that referenced this pull request Apr 5, 2014
…undler

[Issue #47] CLI naming clash when run under Bundler
@kytrinyx kytrinyx merged commit 06900c7 into approvals:master Apr 5, 2014
@kytrinyx
Copy link
Contributor

kytrinyx commented Apr 5, 2014

Thanks for fixing this! ❤️

@kytrinyx
Copy link
Contributor

kytrinyx commented Apr 5, 2014

I've released v0.0.14

@zph zph deleted the issue_47/fix_cli_naming_clash_under_bundler branch April 5, 2014 19:56
@zph
Copy link
Contributor Author

zph commented Apr 5, 2014

😻 thanks for the super helpful gem!

@markijbema
Copy link
Contributor

But isn't everything in lib/ 'global' over all gems? I was under the assumption that after loading a gem, everything there is requir-able. Therefore, lib/approvals is the only place where you can put files without conflicting with other gems. All this to the best of my understanding of ruby gems, please correct me if I'm wrong.

@kytrinyx
Copy link
Contributor

kytrinyx commented Apr 6, 2014

It hadn't occurred to me, but when thinking about it, you're probably right.

@zph
Copy link
Contributor Author

zph commented Apr 7, 2014

Based on what I saw w/ Bundler, it looks like anything in 'lib/*' is in the global path namespace.

So to make sure to namespace reliably, it ought to be under lib/approvals/...

I'll submit 2nd PR that puts it in lib/approvals/cli/ for convenience. It can be part of the next tag release 👍.

@kytrinyx
Copy link
Contributor

kytrinyx commented Apr 7, 2014

The cli/cli.rb isn't very intuitive to me. In Ruby I expect to see this:

/something.rb
/something/interesting.rb
/something/unusual.rb

Where there's a top-level .rb file, and if there are related files, then they are in a sub-directory.

How about just lib/approvals/cli.rb?

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.

3 participants