Object
# File lib/myrurema.rb, line 49 def init sh "svn co -rHEAD #{SVN_URL}/doctree/trunk #{doctree_path}" sh "svn co -rHEAD #{SVN_URL}/bitclust/trunk #{bitclust_path}" init_db(@opt.rubyver) end
# File lib/myrurema.rb, line 107 def list should_have_db(@opt.rubyver) sh "#{bitclust_path/'bin/refe'}" + " -l -d #{db_path(@opt.rubyver)}", :silent => true end
# File lib/myrurema.rb, line 139 def preview file, target = *@opt.rest_args if file error "file not found: #{file}" unless File.exist?(file) result = sh "#{bitclust_path/'tools/bc-tohtml.rb'}" + " #{file}" + (target ? " --target=#{target}" : "") + " --ruby=#{@opt.rubyver}" + " > #{TMP_FILE}" if result && @opt.open_browser cmd = (/mswin/ =~ RUBY_PLATFORM) ? "start" : "open" sh "#{cmd} #{TMP_FILE}" end else sh "cd #{doctree_path/'refm/api/src'}" end end
# File lib/myrurema.rb, line 23 def run if @opt.command send(@opt.command) else query = @opt.rest_args num = if !query.empty? and query.last =~ /\A\d+\z/ query.pop.to_i else nil end case when query.empty? if num search(num, @opt.rubyver) else @opt.usage end when query && num search_num(query, num, @opt.rubyver) else search(query, @opt.rubyver) end end end
query: Array or String
ver: String
# File lib/myrurema.rb, line 62 def search(query, ver) should_have_db(ver) args = Array(query).map{|s| Shellwords.escape s}.join(" ") cmd = "#{bitclust_path/'bin/refe'}" + " #{args} -d #{db_path(ver)}" sh cmd, :silent => true do |txt| lines = txt.lines.to_a if candidate_list_responded?(lines, query) words = {} k = 0 puts lines.map{|line| line.gsub(/(\S+)/){|str| k+=1 words[k] = str "(#{k})#{str}" } } print "which one? > " line = $stdin.gets or (puts; exit) n = line.to_i puts "searching #{words[n]}" puts search(words[n].sub(/\.#/, "."), ver) else puts txt end end end
# File lib/myrurema.rb, line 93 def search_num(query, num, ver) should_have_db(ver) result = `#{bitclust_path/'bin/refe'} #{query} -d #{db_path(ver)}` word = result.split[num-1] if word word.gsub!(/\.#/, ".") # avoid multi-hit for a module function puts "searching #{word}" search(word, ver) else error "less than #{num} entries found" end end
# File lib/myrurema.rb, line 114 def server port = @opt.port || default_port(@opt.rubyver) th = Thread.new{ sh "ruby #{bitclust_path/'standalone.rb'}" + " --srcdir=#{bitclust_path}" + " --baseurl=http://localhost:#{port}" + " --port=#{port}" + " --database=#{db_path(@opt.rubyver)}" + " --debug" # needed to avoid the server running as daemon :-( } url = "http://localhost:#{port}/view/" puts "Starting BitClust server .." puts "Open #{url} in your browser." puts if @opt.open_browser sleep 1 # wait for the server to start Launchy.open(url) end th.join end
Generated with the Darkfish Rdoc Generator 2.