-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
provide methods to query which OS is running. Use FFI::Platform methods #290
provide methods to query which OS is running. Use FFI::Platform methods #290
Conversation
I've now added RSpec methods so that we can test -- and change -- the current operating system, ruby_platform, and ruby_engine. The current os is gotten from FFI::Platform; these test mock FFI::Platform with a class_double. These spec also use stub_constant for RUBY_ENGINE and RUBY_PLATFORM -- so those can be changed, too. |
FYI @weedySeaDragon, @dg-ratiodata and @maxmeyer are the same person. It confuses me too 😄 |
@mattwynne ya, I learned that the other night on Gitter. I referenced both of those as kind of a joke about exactly that. :-) |
Maybe I'm missing something but I don't see why we need the specs in |
Yes and yes. These do test the new methods in Aruba::Platform, but then can be expanded (perhaps as shared examples or contexts) to also be used for the PRs that require different behavior based on the current OS. |
Rather than spreading the conditional logic about the OS around the code, I'd prefer to isolate it at the edges. Let's build some different instances of the I'll see if I can knock up a PR to show you what I mean. |
Sounds good. closing this. |
@mattwynne I started breaking up |
Should've just reverted the commits (not closed this whole thing) (max - sounds like you and should get coordinated about what should be done on Platform and SpawnProcess so that we don't duplicate work.) |
Yes. Personally I like to see what @mattwynne has in mind with From my point of view, having a class for edge cases (WindowsEnvironment, PosixEnvironment, WindowsWhich, PosixWhich) would be the way to go as this approach can handle both different data structures and different algorithms. I don't want to bloat |
…orm, and ruby_engine
…by_platform, and ruby_engine" This reverts commit bf04e21.
20ba0f7
to
b82cdf8
Compare
When I say "edges" I mean the edge of the architecture - use a ports & adapters design so we can pass in an adapter for the platform-specific stuff, and all method calls that need platform-specific implementations go across a common port. I think all of us are on the same page now (@weedySeaDragon and I already caught up about this on gitter) |
See #299 for a possible implementation for "a ports & adapters design". I use |
4b424bf
to
bbd9993
Compare
As we've got the check in |
I've added some methods into (lib)/api/platform.rb to query which OS is running. Since FFI is already being included by the project and FFI already has excellent methods for querying the OS, the methods are essentially pass-thru's to what FFI does.
If it's somehow not good to use ffi (it did require a require 'ffi' in platform.rb) I can use the already required rbconfig. (Tho I'll likely be re-writing what FFI has done.)