Module: CodeRunner::InteractiveMethods
- Defined in:
- lib/coderunner/interactive_methods.rb
Constant Summary collapse
- INTERACTIVE_METHODS =
<<EOF include CodeRunner::InteractiveMethods setup_interactive module Kernel alias_method(:shell_do, "`".to_sym) def `(cmd) c =caller if c[0] =~ /irb_binding/ system(cmd) else shell_do(cmd) end end end EOF
Instance Method Summary collapse
- #cd(dirct) ⇒ Object
-
#change_root_folder(folder) ⇒ Object
(also: #crf)
Change the default root folder(s) for commands.
- #pwd ⇒ Object
- #runs ⇒ Object
- #setup_interactive ⇒ Object
- #up ⇒ Object
Instance Method Details
#cd(dirct) ⇒ Object
14 15 16 |
# File 'lib/coderunner/interactive_methods.rb', line 14 def cd(dirct) Dir.chdir(dirct) end |
#change_root_folder(folder) ⇒ Object Also known as: crf
Change the default root folder(s) for commands. If a runner has not been loaded for a given folder, it will be loaded as subsequently required.
41 42 43 |
# File 'lib/coderunner/interactive_methods.rb', line 41 def change_root_folder(folder) DEFAULT_COMMAND_OPTIONS[:Y] = folder end |
#pwd ⇒ Object
32 33 34 |
# File 'lib/coderunner/interactive_methods.rb', line 32 def pwd puts Dir.pwd end |
#runs ⇒ Object
35 36 37 |
# File 'lib/coderunner/interactive_methods.rb', line 35 def runs CodeRunner.runner.run_list end |
#setup_interactive ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/coderunner/interactive_methods.rb', line 17 def setup_interactive @runner = CodeRunner.fetch_runner(CodeRunner::DEFAULT_COMMAND_OPTIONS.dup) unless CodeRunner::DEFAULT_COMMAND_OPTIONS[:q] @r = @runner if @r histfile = @r.root_folder + '/.code-runner-irb-save-history' if FileTest.exist?(histfile) if @r.is_in_repo? repo = Repository.open_in_subfolder(@r.root_folder) repo.add(histfile) repo.autocommit("Updated save history in #{repo.relative_path(@r.root_folder)}") if repo.modified? histfile end end end end |
#up ⇒ Object
10 11 12 13 |
# File 'lib/coderunner/interactive_methods.rb', line 10 def up ObjectSpace.each_object{|obj| obj.update if obj.class.to_s =~ /CodeRunner$/} nil end |