Sha256: 6ee006a13dcb06dde1521c5cba0be5ef740d447a8764771143eed4337c5c036f
Contents?: true
Size: 1.06 KB
Versions: 11
Compression:
Stored size: 1.06 KB
Contents
#!/usr/bin/env ruby require 're_expand' #require '/Users/masui/expand_ruby/lib/re_expand.rb' #require '/Users/masui/expand_ruby/lib/re_expand/Generator' #require '/Users/masui/expand_ruby/lib/re_expand/Node' #require '/Users/masui/expand_ruby/lib/re_expand/Scanner' require 'json' DATAFILE = File.expand_path("~/.githelp") data = JSON.parse(File.read(DATAFILE)) # # 関数定義などをeval # data['codes'].each { |code| eval code } g = ExpandRuby::Generator.new # re_expandのジェネレータ # # GitHelpエントリ # lines = [] data['defs'].each { |line| if line =~ /^\s*\$\s*(.*)$/ # $.... lines << $1 elsif line =~ /^\s*\%\s*(.*)$/ # %.... cmd = $1 lines.each { |l| desc = eval('"' + l + '"') g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8') } lines = [] end } res = g.generate " #{args.join(' ')} " listed = {} list = res[0].find_all { |a| # 0 ambig if listed[a[1]] false else listed[a[1]] = true end } list.each_with_index { |entry,ind| puts "#[#{ind}] #{entry[0]}" puts " #{entry[1]}" }
Version data entries
11 entries across 11 versions & 1 rubygems