-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add File/Dir formatters for mswin platform #48
Conversation
c5198ac
to
897075e
Compare
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.
This looks good to me! Thank you for opening this and I apologize for not reviewing it earlier.
Please resolve the conflicts when you have a chance and we can merge this in 😊
colorize(ls.empty? ? file.inspect : "#{file.inspect}\n#{ls.chop}", :file) | ||
end | ||
|
||
def info |
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.
Maybe you can provide two different implementations of #info
according to RUBY_PLATFORM
?
Like this:
if RUBY_PLATFORM.include?('mswin')
def info
# ...
end
else
def info
# ...
end
end
@@ -3,6 +3,7 @@ | |||
require 'shellwords' | |||
|
|||
require_relative 'base_formatter' | |||
require_relative 'mswin_helper' if RUBY_PLATFORM.include?('mswin') |
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.
Maybe it makes sense to use the platform tester from RubyGems: Gem.win_platform?
The mswin platform is Ruby build with the Visual Studio C++ compiler. Unlike msys2 or cygwin builds, it knows no unix features.
Without this patch, typing
URI.open 'https://www.google.com'
in irb throws an error, for AmazingPrint tries to shell out to ls(1) to get info about a tmp file & there is no ls executable on Windows.This PL emulates powershell Get-ChildItem cmdlet output, e.g.:
I added :unix & :mswin tags to several rspec examples, thus you can run rspec under Linux as before without noticing Windows-specific tests.