Module: Impl

Defined in:
lib/impl.rb

Constant Summary collapse

VERSION =
'1.0'

Class Method Summary collapse

Class Method Details

.generate(ctags, dir) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/impl.rb', line 4

def generate(ctags, dir)
  memo = []
  Dir.glob(dir + '/**/*.c') do |f|
    File.read(f).each_line do |line|
      if /^\s*rb_define_(singleton_)?(?:private_)?method\(rb_.(.*?),\s*"(.*?)",\s*(\w+),(?#\))/ =~ line
        is_singleton, klass, method, func = [!!$1, $2, $3, $4]
        fullmethod = [klass, is_singleton ? '.' : '#', method].join
        ctags.scan(/^#{func}\t(.*)/) do |x|
          memo << "#{fullmethod}\t#{x[0]}"
        end
      end
    end
  end
  memo
end

.helpObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/impl.rb', line 21

def help
  "  impl version \#{VERSION}\n\n  USAGE\n    impl -h: shows this message\n    impl:    shows additional information, assuming you already have |tags|\n             and Ruby codes in the current directory.\n    impl --suite {directory}:\n             generates new |tags| file in {directory} using files in\n             {directory}.\n  EOH\nend\n"