Skip to content

Commit

Permalink
Moved JRuby version files into particular path
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jan 28, 2020
1 parent bccb2a7 commit b0691d2
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 78 deletions.
13 changes: 6 additions & 7 deletions io-console.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ Gem::Specification.new do |s|
s.require_paths.unshift("jruby")
s.files.concat(%w[
jruby/io/console.rb
lib/io/console/jruby.rb
lib/io/console/jruby/bsd_console.rb
lib/io/console/jruby/common.rb
lib/io/console/jruby/linux_console.rb
lib/io/console/jruby/native_console.rb
lib/io/console/jruby/stty_console.rb
lib/io/console/jruby/stub_console.rb
jruby/io/console/bsd_console.rb
jruby/io/console/common.rb
jruby/io/console/linux_console.rb
jruby/io/console/native_console.rb
jruby/io/console/stty_console.rb
jruby/io/console/stub_console.rb
])
end

Expand Down
68 changes: 67 additions & 1 deletion jruby/io/console.rb
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
require 'io/console/jruby'
# This implementation of io/console is a little hacky. It shells out to `stty`
# for most operations, which does not work on Windows, in secured environments,
# and so on. In addition, because on Java 6 we can't actually launch
# subprocesses with tty control, stty will not actually manipulate the
# controlling terminal.
#
# For platforms where shelling to stty does not work, most operations will
# just be pass-throughs. This allows them to function, but does not actually
# change any tty flags.
#
# Finally, since we're using stty to shell out, we can only manipulate stdin/
# stdout tty rather than manipulating whatever terminal is actually associated
# with the IO we're calling against. This will produce surprising results if
# anyone is actually using io/console against non-stdio ttys...but that case
# seems like it would be pretty rare.
#
# Note: we are incorporating this into 1.7.0 since RubyGems uses io/console
# when pushing gems, in order to mask the password entry. Worst case is that
# we don't actually disable echo and the password is shown...we will try to
# do a better version of this in 1.7.1.

require 'rbconfig'

require_relative 'console/common'

# If Windows, always use the stub version
if RbConfig::CONFIG['host_os'] =~ /(mswin)|(win32)|(ming)/
require_relative 'console/stub_console'
else

# If Linux or BSD, try to load the native version
if RbConfig::CONFIG['host_os'].downcase =~ /darwin|openbsd|freebsd|netbsd|linux/
begin

# Attempt to load the native Linux and BSD console logic
require_relative 'console/native_console'
ready = true

rescue Exception => ex

warn "failed to load native console support: #{ex}" if $VERBOSE
ready = false

end
end

# Native failed, try to use stty
if !ready
begin

require_relative 'console/stty_console'
ready = true

rescue Exception

warn "failed to load stty console support: #{ex}" if $VERBOSE
ready = false

end
end

# If still not ready, just use stubbed version
if !ready
require_relative 'console/stub_console'
end

end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def getpass(prompt = nil)
str
end
end
end
end
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ def oflush

def ioflush
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def oflush

def ioflush
end
end
end
67 changes: 0 additions & 67 deletions lib/io/console/jruby.rb

This file was deleted.

0 comments on commit b0691d2

Please sign in to comment.