Skip to content

added support for tilde-initial paths #309

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

Closed
wants to merge 1 commit into from
Closed

added support for tilde-initial paths #309

wants to merge 1 commit into from

Conversation

masukomi
Copy link
Contributor

@masukomi masukomi commented Dec 30, 2019

I.e. specifying the home directory by starting the
path with a tilde.

Additionally added extra info to the error message
when a shard.yml file isn't found.

This fixes Issue #308

All tests pass. No new tests added to cover this because there don't appear to be ANY tests for this class.

@straight-shoota
Copy link
Member

Please use Path#expand/File#expand_path to implement this.

@ysbaddaden
Copy link
Contributor

Please not that #308 may not be considered a bug.

@masukomi
Copy link
Contributor Author

Please use Path#expand/File#expand_path to implement this. - @straight-shoota

That was my first attempted solution. Technically i just replaced the calls to local_path with expand_local_path (better to use existing functionality) because it just does File.expand_path)

BUT doing that converted ~/workspace/bayes_classifier to /Users/masukomi/workspace/scuttlebutt/weekly_ssb_summarization/~/workspace/bayes_classifier

there are 2 problems with this:

/Users/masukomi/workspace/scuttlebutt/weekly_ssb_summarization/ is the directory i was in when i Ran it and has NOTHING to do with where it should be finding the path.

The ~ is still there.

using Path[local_path].expand(home: true).to_s seems to work.... (committed, rebased, pushed) BUT I'm seeing some other issues that i wasn't seeing before. I think it's just other stuff on my system that's unrelated. I would feel more confident if there were tests on this class.

I.e. specifying the home directory by starting the
path with a tilde.

Additionally added extra info to the error message
when a shard.yml file isn't found.
@masukomi
Copy link
Contributor Author

additional issues resolved. corrected. rebased pushed.

it just needed to be expanded in spec?(version) too

Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use Path. We don't need it and it leads ro duplicate behavior. Also we must fail ASAP with a proper message if the expanded path isn't a directory.

Just use expanded_local_path, and fix it so it expands ~. Thanks.

I.e. File.expand_path(local_path, home: true).tap do

Comment on lines -61 to +62
dependency["path"].to_s
path = dependency["path"].to_s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't be changed.


if File.exists?(spec_path)
File.read(spec_path)
else
raise Error.new("Missing #{SPEC_FILENAME.inspect} for #{dependency.name.inspect}")
raise Error.new("Missing #{SPEC_FILENAME.inspect} for #{dependency.name.inspect}\n Expected it at #{spec_path}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for newlines.

Copy link
Contributor

@ysbaddaden ysbaddaden Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact changing the message isn't needed when using expanded_local_path that will report that the directory doesn't exist.

@ysbaddaden
Copy link
Contributor

Note that I have nothing against Path, I just want the bugfix to be as minimal as possible :)

@straight-shoota
Copy link
Member

This PR has been superseeded by #538 and #541

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.

4 participants