Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ruby 2 7 io method #4302

Merged
merged 5 commits into from
May 7, 2021
Merged

Ruby 2 7 io method #4302

merged 5 commits into from
May 7, 2021

Conversation

tijcolem
Copy link
Collaborator

@tijcolem tijcolem commented Apr 22, 2021

Fix #4301

This resolves the issue as outline in #4301. This will need to happen once we upgrade to ruby 3.0 so it's proably better we get this in sooner than trying to silence them. As of now, ruby 2.7.2 that in used in the cli just outputs a deprecation warning (although this is annoying and verbose) and our original code works fine.

Here was a simple test that demonstrates the new usage.

FILE WRITES USING MIXED ARGS and KEYWORDS

f = File.open("log1.txt", "w" )
f.write("Go Avs")
f.close()

f = File.open("log2.txt", "w" )
f.write("Go Blackhwaks")
f.close()

f = File.open("log3.txt", mode: 'wb:UTF-16LE')
f.write("Go Bruins")
f.close()

f = File.open("log4.txt", 'w', encoding: 'iso-8859-1')
f.write("Go Blues")
f.close()

f = File.open("log5.txt", "w", cr_newline: true )
f.write("Go Wild")
f.close()

f = File.open("log6.txt",'w:iso-8859-1', cr_newline: true )
f.write("Go Leafs")
f.close()

FILE READS USING MIXED ARGS and KEYWORDS

f = File.open("log1.txt", "r" )
puts f.readlines
f.close()

f = File.open("log2.txt", "r" )
puts f.readlines
f.close()

f = File.open("log3.txt", mode: 'rb:UTF-16LE')
puts f.readlines
f.close()

f = File.open("log4.txt", 'r', encoding: 'iso-8859-1')
puts f.readlines
f.close()

f = File.open("log5.txt", "r", cr_newline: true )
puts f.readlines
f.close()

f = File.open("log6.txt",'r:iso-8859-1', cr_newline: true )
puts f.readlines
f.close()

OBSERVED OUTPUTS

WRITES

self.open(name, *args), name = /dev/null, args = ["w"], options = {}
self.open(name, *args), name = log1.txt, args = ["w"], options = {}
self.open(name, *args), name = log2.txt, args = ["w"], options = {}
self.open(name, *args), name = log3.txt, args = [], options = {:mode=>"wb:UTF-16LE"}
self.open(name, *args), name = log4.txt, args = ["w"], options = {:encoding=>"iso-8859-1"}
self.open(name, *args), name = log5.txt, args = ["w"], options = {:cr_newline=>true}
self.open(name, *args), name = log6.txt, args = ["w:iso-8859-1"], options = {:cr_newline=>true}

READS

self.open(name, *args), name = log1.txt, args = ["r"], options = {}
Go Avs
self.open(name, *args), name = log2.txt, args = ["r"], options = {}
Go Blackhwaks
self.open(name, *args), name = log3.txt, args = [], options = {:mode=>"rb:UTF-16LE"}
Go Bruins
self.open(name, *args), name = log4.txt, args = ["r"], options = {:encoding=>"iso-8859-1"}
Go Blues
self.open(name, *args), name = log5.txt, args = ["r"], options = {:cr_newline=>true}
Go Wild
self.open(name, *args), name = log6.txt, args = ["r:iso-8859-1"], options = {:cr_newline=>true}
Go Leafs

@shorowit
Copy link
Contributor

Thank you @tijcolem!

Copy link
Collaborator

@jmarrec jmarrec left a comment

Choose a reason for hiding this comment

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

looks good to me.

@jmarrec
Copy link
Collaborator

jmarrec commented Apr 26, 2021

cppcheck failure has nothing to do with this PR:

[src/utilities/geometry/Intersection.cpp:92]:(warning),[constStatement],Found suspicious operator '>'

@tijcolem tijcolem self-assigned this Apr 29, 2021
@tijcolem tijcolem added component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Minor Bug labels Apr 29, 2021
@tijcolem tijcolem added this to the OpenStudio SDK 3.2.1 milestone May 7, 2021
@tijcolem tijcolem merged commit d979f5b into develop May 7, 2021
@tijcolem tijcolem deleted the ruby_2_7_io_method branch May 7, 2021 14:41
shorowit added a commit to NREL/OpenStudio-HPXML that referenced this pull request May 7, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Minor Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecation Warning of last argument as keyword parameters
4 participants