diff options
author | r-obert <r-obert@users.noreply.github.com> | 2017-10-22 17:07:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-22 17:07:47 +0200 |
commit | 1f32f89ae6d406e12db9cd1645e5eca31452b465 (patch) | |
tree | 5994eec4748a8ca7f804c51e9505c5e8aec58146 | |
parent | b1e76dd4d2121a2d56b85737272d33203c14d74e (diff) | |
download | pry-1f32f89ae6d406e12db9cd1645e5eca31452b465.tar.gz |
add linux? & mac_osx? predicates to BaseHelpers (#1668)
* add linux? and mac_osx? predicates to BaseHelpers
* update documentation
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | lib/pry/helpers/base_helpers.rb | 33 |
2 files changed, 38 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ff1776d0..e10174f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### HEAD + +__Features:__ + +* Add mac_osx? and linux? utility functions to Pry::Helpers::BaseHelpers. +[#1668](https://github.com/pry/pry/pull/1668) + ### 0.11.0 * Add alias 'whereami[?!]+' for 'whereami' command. ([#1597](https://github.com/pry/pry/pull/1597)) diff --git a/lib/pry/helpers/base_helpers.rb b/lib/pry/helpers/base_helpers.rb index 0b6cc560..cb5eac92 100644 --- a/lib/pry/helpers/base_helpers.rb +++ b/lib/pry/helpers/base_helpers.rb @@ -60,9 +60,38 @@ class Pry "\e[1m#{text}\e[0m" end - # have fun on the Windows platform. + # + # @return [Boolean] + # Returns true if Pry is running on Mac OSX. + # + # @note + # Queries RbConfig::CONFIG['host_os'] with a best guess. + # + def mac_osx? + !!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i) + end + + # + # @return [Boolean] + # Returns true if Pry is running on Linux. + # + # @note + # Queries RbConfig::CONFIG['host_os'] with a best guess. + # + # + def linux? + !!(RbConfig::CONFIG['host_os'] =~ /linux/i) + end + + # + # @return [Boolean] + # Returns true if Pry is running on Windows. + # + # @note + # Queries RbConfig::CONFIG['host_os'] with a best guess. + # def windows? - RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ + !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) end # are we able to use ansi on windows? |