[前][次][番号順一覧][スレッド一覧]

ruby-changes:37269

From: nobu <ko1@a...>
Date: Tue, 20 Jan 2015 13:09:34 +0900 (JST)
Subject: [ruby-changes:37269] nobu:r49350 (trunk): redmine-backporter.rb: try Readline

nobu	2015-01-20 13:09:24 +0900 (Tue, 20 Jan 2015)

  New Revision: 49350

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49350

  Log:
    redmine-backporter.rb: try Readline
    
    * tool/redmine-backporter.rb (readline): try Readline.readline if
      available.

  Modified files:
    trunk/tool/redmine-backporter.rb
Index: tool/redmine-backporter.rb
===================================================================
--- tool/redmine-backporter.rb	(revision 49349)
+++ tool/redmine-backporter.rb	(revision 49350)
@@ -8,6 +8,12 @@ require 'stringio' https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L8
 require 'strscan'
 require 'optparse'
 require 'pp'
+begin
+  require 'readline'
+rescue LoadError
+else
+  include Readline
+end
 
 VERSION = '0.0.1'
 
@@ -195,7 +201,7 @@ def more(sio) https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L201
   end
 end
 
-def readline(prompt = '')
+def Readline.readline(prompt = '')
   console = IO.console
   console.binmode
   ly, lx = console.winsize
@@ -226,7 +232,7 @@ def readline(prompt = '') https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L232
       line << c
     end
   end
-end
+end unless defined?(Readline.readline)
 
 def mergeinfo
   `svn propget svn:mergeinfo #{RUBY_REPO_PATH}`
@@ -266,7 +272,7 @@ puts "Backporter #{VERSION}".color(bold: https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L272
 @changesets = nil
 while true
   begin
-    l = readline '> '
+    l = Readline.readline '> '
   rescue Interrupt
     break
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]