Top Level Namespace

Includes:
Fox

Defined Under Namespace

Modules: FileProviderTestEvents, Options, Provider, RenameFunctions, ScriptLines Classes: ActionError, Array, BadOptionValueError, BaseTest, DEBUGGER__, DirectoryExistsError, File, FileLines, Filter, FilterNonMatches, Fixnum, MatchData, MissingOptionError, NameFileSource, NamePromptSource, NameSource, NameStreamSource, Object, OptionError, PrepareRegexp, Regexp, RenameWindow, Renamer, RenamerError, RenamerMock, String, TestArray, TestFile, TestFileLines, TestKernel, TestMatchData, TestMkdirs, TestRegexp, TestReload, TestRoman, TestScriptLines, TestString, TestTitleCase, Tracer, VerboseRegexp

Constant Summary collapse

SCRIPT_LINES__ =
{}

Instance Method Summary collapse

Instance Method Details

#copy(a, b) ⇒ Object



1
2
3
4
5
# File 'lib/innate/test/testreload.rb', line 1

def copy(a, b)
  File.open(b, 'w') do |f|
    f.write File.read(a)
  end
end

#debugObject



3
4
5
6
7
8
9
10
11
# File 'lib/innate/debug.rb', line 3

def debug
  if $SAFE == 0
    if require('innate/debugger')
      DEBUGGER__.start_debugger
    else
      DEBUGGER__.interrupt
    end
  end
end

#each_callerObject



30
31
32
33
34
35
# File 'lib/innate/kernel.rb', line 30

def each_caller
  caller.each do |c|
    m = /^(.+):(\d+)(:in `(.*)')?$/.match c
    yield m[1].gsub('\\', '/'), m[2] ? m[2].to_i : 0, m[4]
  end
end

#each_lfocObject



37
38
39
40
# File 'lib/innate/kernel.rb', line 37

def each_lfoc
  each_loaded_file {|fn| yield fn}
  each_caller {|fn, l, f| yield fn}
end

#each_loaded_fileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/innate/kernel.rb', line 15

def each_loaded_file
  ($").each do |f|
    if File.exists? f
      yield f
    else
      fn = File.absolute_path?(f) ? f : find_in_path(f)
      if fn
        yield fn
      else
        raise "file not found: #{f}" unless found
      end
    end
  end
end

#find_in_path(f) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/innate/kernel.rb', line 3

def find_in_path f
  (['.'] + $:).each do |p|
    ['', '.rb', '.rbw'].each do |ext|
      fn = File.expand_path File.join(p, f + ext)
      if File.exists? fn and !File.directory? fn
        return fn
      end
    end
  end
  nil
end

#reload(s) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
# File 'lib/innate/reload.rb', line 1

def reload s
  unless $".delete s
    if /\.rb$/ =~ s
      require s
    else
      reload s + '.rb'
    end
  else
    require s
  end
end

#targetfn {|'start 2'| ... } ⇒ Object

Yields:

  • ('start 2')


1
2
3
4
5
# File 'lib/innate/test/files/reloadtarget.rb', line 1

def targetfn
  yield 'start 2'
  sleep(1)
  'function2'
end