diff options
author | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-10-19 00:11:45 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 00:11:45 -0300 |
commit | 46e6bba20ab921cb5600ae60e640bf2417f64efc (patch) | |
tree | ffa1c73ce4c9f4d3e74594280f3d9b60e3aae377 | |
parent | d53851be0d545453e58439c8faca98f4fbdebf40 (diff) | |
parent | f1a0800d86b0f8d3c2c6e3842ea4cbb2504ac92a (diff) | |
download | highline-46e6bba20ab921cb5600ae60e640bf2417f64efc.tar.gz |
Merge pull request #218 from JEG2/highline_use_colorv2.0.0.pre.develop.12
Ease transition from 1.7.x to 2.0.x (specially for travis.rb)
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | Changelog.md | 3 | ||||
-rwxr-xr-x | lib/highline.rb | 19 | ||||
-rw-r--r-- | lib/highline/io_console_compatible.rb (renamed from test/io_console_compatible.rb) | 0 | ||||
-rw-r--r-- | lib/highline/version.rb | 2 | ||||
-rw-r--r-- | test/test_helper.rb | 2 |
6 files changed, 23 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml index 82bfae2..75df415 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ matrix: - rvm: rbx-3.81 - rvm: jruby-19mode # JRuby in 1.9 mode - rvm: jruby-head + fast_finish: true include: - rvm: 1.9 before_install: diff --git a/Changelog.md b/Changelog.md index b07d79b..f19cb9f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,9 @@ Below is a complete listing of changes for each revision of HighLine. ### Unreleased +* PR #218 - Ease transition from 1.7.x to 2.0.x (@abinoam) + * Copy use_color from HighLine.default_instance + * Expose IOConsoleCompatible * PR #216 - Update .appveyor.yml - Fix Windows CI (@abinoam) ### 2.0.0-develop.11 / 2017-09-25 diff --git a/lib/highline.rb b/lib/highline.rb index b51a1a0..33ab7eb 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -115,9 +115,9 @@ class HighLine @header = nil @prompt = nil @key = nil - @use_color = true - @track_eof = true # The setting used to disable EOF tracking. + @use_color = default_use_color + @track_eof = true # The setting used to disable EOF tracking. @terminal = HighLine::Terminal.get_terminal(input, output) end @@ -619,6 +619,21 @@ class HighLine def actual_length(text) Wrapper.actual_length text end + + # Check to see if there's already a HighLine.default_instance or if + # this is the first time the method is called (eg: at + # HighLine.default_instance initialization). + # If there's already one, copy use_color settings. + # This is here most to help migrate code from HighLine 1.7.x to 2.0.x + # + # @return [Boolean] + def default_use_color + if HighLine.default_instance + HighLine.default_instance.use_color + else + true + end + end end HighLine.default_instance = HighLine.new diff --git a/test/io_console_compatible.rb b/lib/highline/io_console_compatible.rb index 7ff06f5..7ff06f5 100644 --- a/test/io_console_compatible.rb +++ b/lib/highline/io_console_compatible.rb diff --git a/lib/highline/version.rb b/lib/highline/version.rb index 87be435..41ff060 100644 --- a/lib/highline/version.rb +++ b/lib/highline/version.rb @@ -2,5 +2,5 @@ class HighLine # The version of the installed library. - VERSION = "2.0.0-develop.11".freeze + VERSION = "2.0.0-develop.12".freeze end diff --git a/test/test_helper.rb b/test/test_helper.rb index 0273900..32bfcb8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,7 +8,7 @@ require "simplecov" if RUBY_ENGINE == "ruby" # Compatibility module for StringIO, File # and Tempfile. Necessary for some tests. -require "io_console_compatible" +require "highline/io_console_compatible" require "highline" debug_message = "Tests will be run under:\n" |