rubysl-irb 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +25 -0
  6. data/README.md +29 -0
  7. data/Rakefile +1 -0
  8. data/lib/irb/cmd/chws.rb +33 -0
  9. data/lib/irb/cmd/fork.rb +39 -0
  10. data/lib/irb/cmd/help.rb +31 -0
  11. data/lib/irb/cmd/load.rb +67 -0
  12. data/lib/irb/cmd/nop.rb +39 -0
  13. data/lib/irb/cmd/pushws.rb +39 -0
  14. data/lib/irb/cmd/subirb.rb +43 -0
  15. data/lib/irb/completion.rb +205 -0
  16. data/lib/irb/context.rb +255 -0
  17. data/lib/irb/ext/change-ws.rb +62 -0
  18. data/lib/irb/ext/history.rb +110 -0
  19. data/lib/irb/ext/loader.rb +120 -0
  20. data/lib/irb/ext/math-mode.rb +37 -0
  21. data/lib/irb/ext/multi-irb.rb +241 -0
  22. data/lib/irb/ext/save-history.rb +70 -0
  23. data/lib/irb/ext/tracer.rb +61 -0
  24. data/lib/irb/ext/use-loader.rb +65 -0
  25. data/lib/irb/ext/workspaces.rb +56 -0
  26. data/lib/irb/extend-command.rb +264 -0
  27. data/lib/irb/frame.rb +67 -0
  28. data/lib/irb/help.rb +35 -0
  29. data/lib/irb/init.rb +258 -0
  30. data/lib/irb/input-method.rb +120 -0
  31. data/lib/irb/lc/error.rb +30 -0
  32. data/lib/irb/lc/help-message.rb +37 -0
  33. data/lib/irb/lc/ja/error.rb +27 -0
  34. data/lib/irb/lc/ja/help-message +36 -0
  35. data/lib/irb/locale.rb +184 -0
  36. data/lib/irb/notifier.rb +145 -0
  37. data/lib/irb/output-method.rb +85 -0
  38. data/lib/irb/rubinius.rb +55 -0
  39. data/lib/irb/ruby-lex.rb +1149 -0
  40. data/lib/irb/ruby-token.rb +273 -0
  41. data/lib/irb/slex.rb +285 -0
  42. data/lib/irb/version.rb +16 -0
  43. data/lib/irb/workspace.rb +107 -0
  44. data/lib/irb/ws-for-case-2.rb +15 -0
  45. data/lib/irb/xmp.rb +86 -0
  46. data/lib/irb.rb +1 -0
  47. data/lib/rubysl/irb/irb.rb +356 -0
  48. data/lib/rubysl/irb/version.rb +5 -0
  49. data/lib/rubysl/irb.rb +2 -0
  50. data/rubysl-irb.gemspec +31 -0
  51. metadata +219 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 696c059444c6b7e435bfa5fa16a2227fb9fb2617
4
+ data.tar.gz: 5f1dbf49b46d12f0bb3bb815c8254bf9e4d9b5ff
5
+ SHA512:
6
+ metadata.gz: 8eed1e867bc34bcac3225b78e91386ba418d1a1e634bf1bfb5f99f03d0e601581e07917046c93328df2337ece98cae2c8b5339448fe0e629338d7731463804ae
7
+ data.tar.gz: 9f1c6558010b7d808d65454e10a86dbf6a8860f654c300ab5c5202cd537c443d0977a917e1b38fdbae7a4e6f968623e0ea591a97a2072395c62884cde8b36440
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update --system
4
+ - gem --version
5
+ - gem install rubysl-bundler
6
+ script: bundle exec mspec spec
7
+ rvm:
8
+ - rbx-nightly-18mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubysl-irb.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2013, Brian Shirai
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ 3. Neither the name of the library nor the names of its contributors may be
13
+ used to endorse or promote products derived from this software without
14
+ specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT,
20
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rubysl::Irb
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubysl-irb'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubysl-irb
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,33 @@
1
+ #
2
+ # change-ws.rb -
3
+ # $Release Version: 0.9.5$
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ require "irb/cmd/nop.rb"
14
+ require "irb/ext/change-ws.rb"
15
+
16
+ module IRB
17
+ module ExtendCommand
18
+
19
+ class CurrentWorkingWorkspace<Nop
20
+ def execute(*obj)
21
+ irb_context.main
22
+ end
23
+ end
24
+
25
+ class ChangeWorkspace<Nop
26
+ def execute(*obj)
27
+ irb_context.change_workspace(*obj)
28
+ irb_context.main
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,39 @@
1
+ #
2
+ # fork.rb -
3
+ # $Release Version: 0.9.5 $
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ @RCS_ID='-$Id: fork.rb 11708 2007-02-12 23:01:19Z shyouhei $-'
14
+
15
+
16
+ module IRB
17
+ module ExtendCommand
18
+ class Fork<Nop
19
+ def execute(&block)
20
+ pid = send ExtendCommand.irb_original_method_name("fork")
21
+ unless pid
22
+ class<<self
23
+ alias_method :exit, ExtendCommand.irb_original_method_name('exit')
24
+ end
25
+ if iterator?
26
+ begin
27
+ yield
28
+ ensure
29
+ exit
30
+ end
31
+ end
32
+ end
33
+ pid
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+
@@ -0,0 +1,31 @@
1
+ #
2
+ # help.rb - helper using ri
3
+ # $Release Version: 0.9.5$
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ #
7
+ # --
8
+ #
9
+ #
10
+ #
11
+
12
+ require 'rdoc/ri/driver'
13
+
14
+ module IRB
15
+ module ExtendCommand
16
+ module Help
17
+ include RDoc::RI
18
+ def self.execute(context, *names)
19
+ names.each do |name|
20
+ begin
21
+ Driver.run(['-T', name.to_s])
22
+ rescue Driver::NotFoundError
23
+ puts $!.message
24
+ rescue SystemExit
25
+ end
26
+ end
27
+ nil
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,67 @@
1
+ #
2
+ # load.rb -
3
+ # $Release Version: 0.9.5$
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ require "irb/cmd/nop.rb"
14
+ require "irb/ext/loader"
15
+
16
+ module IRB
17
+ module ExtendCommand
18
+ class Load<Nop
19
+ include IrbLoader
20
+
21
+ def execute(file_name, priv = nil)
22
+ # return ruby_load(file_name) unless IRB.conf[:USE_LOADER]
23
+ return irb_load(file_name, priv)
24
+ end
25
+ end
26
+
27
+ class Require<Nop
28
+ include IrbLoader
29
+
30
+ def execute(file_name)
31
+ # return ruby_require(file_name) unless IRB.conf[:USE_LOADER]
32
+
33
+ rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
34
+ return false if $".find{|f| f =~ rex}
35
+
36
+ case file_name
37
+ when /\.rb$/
38
+ begin
39
+ if irb_load(file_name)
40
+ $".push file_name
41
+ return true
42
+ end
43
+ rescue LoadError
44
+ end
45
+ when /\.(so|o|sl)$/
46
+ return ruby_require(file_name)
47
+ end
48
+
49
+ begin
50
+ irb_load(f = file_name + ".rb")
51
+ $".push f
52
+ return true
53
+ rescue LoadError
54
+ return ruby_require(file_name)
55
+ end
56
+ end
57
+ end
58
+
59
+ class Source<Nop
60
+ include IrbLoader
61
+ def execute(file_name)
62
+ source_file(file_name)
63
+ end
64
+ end
65
+ end
66
+
67
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # nop.rb -
3
+ # $Release Version: 0.9.5$
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+ module IRB
13
+ module ExtendCommand
14
+ class Nop
15
+
16
+ @RCS_ID='-$Id: nop.rb 11708 2007-02-12 23:01:19Z shyouhei $-'
17
+
18
+ def self.execute(conf, *opts)
19
+ command = new(conf)
20
+ command.execute(*opts)
21
+ end
22
+
23
+ def initialize(conf)
24
+ @irb_context = conf
25
+ end
26
+
27
+ attr_reader :irb_context
28
+
29
+ def irb
30
+ @irb_context.irb
31
+ end
32
+
33
+ def execute(*opts)
34
+ #nop
35
+ end
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,39 @@
1
+ #
2
+ # change-ws.rb -
3
+ # $Release Version: 0.9.5$
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ require "irb/cmd/nop.rb"
14
+ require "irb/ext/workspaces.rb"
15
+
16
+ module IRB
17
+ module ExtendCommand
18
+ class Workspaces<Nop
19
+ def execute(*obj)
20
+ irb_context.workspaces.collect{|ws| ws.main}
21
+ end
22
+ end
23
+
24
+ class PushWorkspace<Workspaces
25
+ def execute(*obj)
26
+ irb_context.push_workspace(*obj)
27
+ super
28
+ end
29
+ end
30
+
31
+ class PopWorkspace<Workspaces
32
+ def execute(*obj)
33
+ irb_context.pop_workspace(*obj)
34
+ super
35
+ end
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,43 @@
1
+ #!/usr/local/bin/ruby
2
+ #
3
+ # multi.rb -
4
+ # $Release Version: 0.9.5$
5
+ # $Revision: 11708 $
6
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
7
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
8
+ #
9
+ # --
10
+ #
11
+ #
12
+ #
13
+
14
+ require "irb/cmd/nop.rb"
15
+ require "irb/ext/multi-irb"
16
+
17
+ module IRB
18
+ module ExtendCommand
19
+ class IrbCommand<Nop
20
+ def execute(*obj)
21
+ IRB.irb(nil, *obj)
22
+ end
23
+ end
24
+
25
+ class Jobs<Nop
26
+ def execute
27
+ IRB.JobManager
28
+ end
29
+ end
30
+
31
+ class Foreground<Nop
32
+ def execute(key)
33
+ IRB.JobManager.switch(key)
34
+ end
35
+ end
36
+
37
+ class Kill<Nop
38
+ def execute(*keys)
39
+ IRB.JobManager.kill(*keys)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,205 @@
1
+ #
2
+ # irb/completor.rb -
3
+ # $Release Version: 0.9$
4
+ # $Revision: 11708 $
5
+ # $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6
+ # by Keiju ISHITSUKA(keiju@ishitsuka.com)
7
+ # From Original Idea of shugo@ruby-lang.org
8
+ #
9
+
10
+ require "readline"
11
+
12
+ module IRB
13
+ module InputCompletor
14
+
15
+ @RCS_ID='-$Id: completion.rb 11708 2007-02-12 23:01:19Z shyouhei $-'
16
+
17
+ ReservedWords = [
18
+ "BEGIN", "END",
19
+ "alias", "and",
20
+ "begin", "break",
21
+ "case", "class",
22
+ "def", "defined", "do",
23
+ "else", "elsif", "end", "ensure",
24
+ "false", "for",
25
+ "if", "in",
26
+ "module",
27
+ "next", "nil", "not",
28
+ "or",
29
+ "redo", "rescue", "retry", "return",
30
+ "self", "super",
31
+ "then", "true",
32
+ "undef", "unless", "until",
33
+ "when", "while",
34
+ "yield",
35
+ ]
36
+
37
+ CompletionProc = proc { |input|
38
+ bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
39
+
40
+ # puts "input: #{input}"
41
+
42
+ case input
43
+ when /^(\/[^\/]*\/)\.([^.]*)$/
44
+ # Regexp
45
+ receiver = $1
46
+ message = Regexp.quote($2)
47
+
48
+ candidates = Regexp.instance_methods(true)
49
+ select_message(receiver, message, candidates)
50
+
51
+ when /^([^\]]*\])\.([^.]*)$/
52
+ # Array
53
+ receiver = $1
54
+ message = Regexp.quote($2)
55
+
56
+ candidates = Array.instance_methods(true)
57
+ select_message(receiver, message, candidates)
58
+
59
+ when /^([^\}]*\})\.([^.]*)$/
60
+ # Proc or Hash
61
+ receiver = $1
62
+ message = Regexp.quote($2)
63
+
64
+ candidates = Proc.instance_methods(true) | Hash.instance_methods(true)
65
+ select_message(receiver, message, candidates)
66
+
67
+ when /^(:[^:.]*)$/
68
+ # Symbol
69
+ if Symbol.respond_to?(:all_symbols)
70
+ sym = $1
71
+ candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
72
+ candidates.grep(/^#{sym}/)
73
+ else
74
+ []
75
+ end
76
+
77
+ when /^::([A-Z][^:\.\(]*)$/
78
+ # Absolute Constant or class methods
79
+ receiver = $1
80
+ candidates = Object.constants
81
+ candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
82
+
83
+ when /^(((::)?[A-Z][^:.\(]*)+)::?([^:.]*)$/
84
+ # Constant or class methods
85
+ receiver = $1
86
+ message = Regexp.quote($4)
87
+ begin
88
+ candidates = eval("#{receiver}.constants | #{receiver}.methods", bind)
89
+ rescue Exception
90
+ candidates = []
91
+ end
92
+ candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
93
+
94
+ when /^(:[^:.]+)\.([^.]*)$/
95
+ # Symbol
96
+ receiver = $1
97
+ message = Regexp.quote($2)
98
+
99
+ candidates = Symbol.instance_methods(true)
100
+ select_message(receiver, message, candidates)
101
+
102
+ when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
103
+ # Numeric
104
+ receiver = $1
105
+ message = Regexp.quote($5)
106
+
107
+ begin
108
+ candidates = eval(receiver, bind).methods
109
+ rescue Exception
110
+ candidates = []
111
+ end
112
+ select_message(receiver, message, candidates)
113
+
114
+ when /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/
115
+ # Numeric(0xFFFF)
116
+ receiver = $1
117
+ message = Regexp.quote($2)
118
+
119
+ begin
120
+ candidates = eval(receiver, bind).methods
121
+ rescue Exception
122
+ candidates = []
123
+ end
124
+ select_message(receiver, message, candidates)
125
+
126
+ when /^(\$[^.]*)$/
127
+ candidates = global_variables.grep(Regexp.new(Regexp.quote($1)))
128
+
129
+ # when /^(\$?(\.?[^.]+)+)\.([^.]*)$/
130
+ when /^((\.?[^.]+)+)\.([^.]*)$/
131
+ # variable
132
+ receiver = $1
133
+ message = Regexp.quote($3)
134
+
135
+ gv = eval("global_variables", bind)
136
+ lv = eval("local_variables", bind)
137
+ cv = eval("self.class.constants", bind)
138
+
139
+ if (gv | lv | cv).include?(receiver)
140
+ # foo.func and foo is local var.
141
+ candidates = eval("#{receiver}.methods", bind)
142
+ elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver
143
+ # Foo::Bar.func
144
+ begin
145
+ candidates = eval("#{receiver}.methods", bind)
146
+ rescue Exception
147
+ candidates = []
148
+ end
149
+ else
150
+ # func1.func2
151
+ candidates = []
152
+ ObjectSpace.each_object(Module){|m|
153
+ begin
154
+ name = m.name
155
+ rescue Exception
156
+ name = ""
157
+ end
158
+ next if name != "IRB::Context" and
159
+ /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
160
+ candidates.concat m.instance_methods(false)
161
+ }
162
+ candidates.sort!
163
+ candidates.uniq!
164
+ end
165
+ select_message(receiver, message, candidates)
166
+
167
+ when /^\.([^.]*)$/
168
+ # unknown(maybe String)
169
+
170
+ receiver = ""
171
+ message = Regexp.quote($1)
172
+
173
+ candidates = String.instance_methods(true)
174
+ select_message(receiver, message, candidates)
175
+
176
+ else
177
+ candidates = eval("methods | private_methods | local_variables | self.class.constants", bind)
178
+
179
+ (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
180
+ end
181
+ }
182
+
183
+ Operators = ["%", "&", "*", "**", "+", "-", "/",
184
+ "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
185
+ "[]", "[]=", "^",]
186
+
187
+ def self.select_message(receiver, message, candidates)
188
+ candidates.grep(/^#{message}/).collect do |e|
189
+ case e
190
+ when /^[a-zA-Z_]/
191
+ receiver + "." + e
192
+ when /^[0-9]/
193
+ when *Operators
194
+ #receiver + " " + e
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+
201
+ if Readline.respond_to?("basic_word_break_characters=")
202
+ Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
203
+ end
204
+ Readline.completion_append_character = nil
205
+ Readline.completion_proc = IRB::InputCompletor::CompletionProc