fastri 0.3.0.1 → 0.3.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,11 @@
1
1
 
2
2
  User-visible changes in FastRI
3
+ Since version 0.3.0 (2007-01-29)
4
+ ================================
5
+ * speed increases
6
+ * works on Leopard and with non-standard RubyGems setups
7
+ * -1 (--exact) option to disable second-guessing.
8
+ * -a (--all) option to show the documentation for all matching entries
3
9
 
4
10
  Since version 0.2.1 (2006-11-23)
5
11
  ================================
data/README.en CHANGED
@@ -16,7 +16,13 @@ Just run
16
16
 
17
17
  Usage
18
18
  =====
19
- There are two parts to FastRI:
19
+ FastRI can be used either standalone or with a DRb server, for extra speed.
20
+
21
+ The standalone client is qri and is used the same way as ri; run
22
+ $ qri -h
23
+ to list the options.
24
+
25
+ There are two parts to FastRI over DRb:
20
26
  * the server: fastri-server
21
27
  * the client: fri
22
28
 
@@ -25,8 +31,11 @@ without needing to indicate the DRb URIs manually. It can work across
25
31
  machines if you make sure the ring server is bound to the correct interface,
26
32
  and the ACL permissions are correct.
27
33
 
28
- Quickstart
29
- ----------
34
+ qri and fri are nearly identical, the only difference being that fri tries to
35
+ use a FastRI service over DRb by default.
36
+
37
+ fri Quickstart
38
+ --------------
30
39
  $ fastri-server (blocks)
31
40
  Later,
32
41
  $ fri String
data/Rakefile CHANGED
@@ -52,7 +52,7 @@ EOF
52
52
  s.require_path = 'lib'
53
53
  s.author = "Mauricio Fernandez"
54
54
  s.email = "mfp@acm.org"
55
- s.homepage = "http://eigenclass.org/hiki.rb?fastri"
55
+ s.homepage = "http://eigenclass.org/hiki/fastri"
56
56
  s.bindir = "bin"
57
57
  s.executables = %w[fri qri fastri-server ri-emacs]
58
58
  s.has_rdoc = true
data/bin/fri CHANGED
@@ -3,7 +3,6 @@
3
3
  # Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
4
4
  #
5
5
 
6
- require 'optparse'
7
6
  require 'fastri/util'
8
7
  require 'fastri/full_text_index'
9
8
 
@@ -39,119 +38,136 @@ options = {
39
38
  :extended => false,
40
39
  :index_file => File.join(FastRI::Util.find_home, ".fastri-index"),
41
40
  :local_mode => default_local_mode,
41
+ :do_second_guess => true,
42
+ :expand_choices => false,
42
43
  }
43
44
 
44
45
  override_addr_env = false
45
46
 
46
- optparser = OptionParser.new do |opts|
47
- opts.version = FastRI::FASTRI_VERSION
48
- opts.release = FastRI::FASTRI_RELEASE_DATE
49
- opts.banner = "Usage: #{File.basename($0)} [options] <query>"
50
47
 
51
- opts.on("-L", "--local", "Try to use local index instead of DRb service.",
52
- *[("(default)" if default_local_mode)].compact) do
53
- options[:local_mode] = true
54
- end
55
- opts.on("--index-file=FILE", "Use index file (forces --local mode).",
56
- "(default: #{options[:index_file]})") do |file|
57
- options[:index_file] = file
58
- options[:local_mode] = true
59
- end
60
- opts.on("-R", "--remote", "Use DRb service. #{'(default)' unless default_local_mode}") do
61
- options[:local_mode] = false
62
- end
63
- opts.on("-s", "--bind ADDR", "Bind to ADDR for incoming DRb connections.",
64
- "(default: 127.0.0.1)") do |addr|
65
- options[:addr] = addr
66
- override_addr_env = true
67
- end
48
+ # only load optparse if actually needed
49
+ # saves ~0.01-0.04s.
50
+ if (arg = ARGV[0]) && arg[0, 1] == "-" or ARGV.empty?
51
+ require 'optparse'
52
+ optparser = OptionParser.new do |opts|
53
+ opts.version = FastRI::FASTRI_VERSION
54
+ opts.release = FastRI::FASTRI_RELEASE_DATE
55
+ opts.banner = "Usage: #{File.basename($0)} [options] <query>"
68
56
 
69
- order_mapping = {
70
- 'e' => :exact, 'E' => :exact_ci, 'n' => :nested, 'N' => :nested_ci,
71
- 'p' => :partial, 'P' => :partial_ci, 'x' => :nested_partial,
72
- 'X' => :nested_partial_ci, 'a' => :anywhere, 'A' => :anywhere_ci,
73
- 'm' => :namespace_partial, 'M' => :namespace_partial_ci,
74
- 'f' => :full_partial, 'F' => :full_partial_ci,
75
- }
76
- opts.on("-O", "--order ORDER", "Specify lookup order.",
77
- "(default: eEnNpPxX)", "Uppercase: case-indep.",
78
- "e:exact n:nested p:partial (completion)",
79
- "x:nested and partial m:complete namespace",
80
- "f:complete both class and method",
81
- "a:match method name anywhere") do |order|
82
- options[:lookup_order] = order.split(//).map{|x| order_mapping[x]}.compact
83
- end
57
+ opts.on("-L", "--local", "Try to use local index instead of DRb service.",
58
+ *[("(default)" if default_local_mode)].compact) do
59
+ options[:local_mode] = true
60
+ end
61
+ opts.on("--index-file=FILE", "Use index file (forces --local mode).",
62
+ "(default: #{options[:index_file]})") do |file|
63
+ options[:index_file] = file
64
+ options[:local_mode] = true
65
+ end
66
+ opts.on("-R", "--remote", "Use DRb service. #{'(default)' unless default_local_mode}") do
67
+ options[:local_mode] = false
68
+ end
69
+ opts.on("-s", "--bind ADDR", "Bind to ADDR for incoming DRb connections.",
70
+ "(default: 127.0.0.1)") do |addr|
71
+ options[:addr] = addr
72
+ override_addr_env = true
73
+ end
84
74
 
85
- opts.on("-e", "--extended", "Show all methods for given namespace.") do
86
- options[:extended] = true
87
- options[:use_pager] = true
88
- options[:format] = "plain"
89
- end
75
+ order_mapping = {
76
+ 'e' => :exact, 'E' => :exact_ci, 'n' => :nested, 'N' => :nested_ci,
77
+ 'p' => :partial, 'P' => :partial_ci, 'x' => :nested_partial,
78
+ 'X' => :nested_partial_ci, 'a' => :anywhere, 'A' => :anywhere_ci,
79
+ 'm' => :namespace_partial, 'M' => :namespace_partial_ci,
80
+ 'f' => :full_partial, 'F' => :full_partial_ci,
81
+ }
82
+ opts.on("-O", "--order ORDER", "Specify lookup order.",
83
+ "(default: eEnNpPxX)", "Uppercase: case-indep.",
84
+ "e:exact n:nested p:partial (completion)",
85
+ "x:nested and partial m:complete namespace",
86
+ "f:complete both class and method",
87
+ "a:match method name anywhere") do |order|
88
+ options[:lookup_order] = order.split(//).map{|x| order_mapping[x]}.compact
89
+ end
90
90
 
91
- opts.on("--show-matches", "Only show matching entries."){ options[:show_matches] = true }
91
+ opts.on("-1", "--exact", "Does not do second guess(exact query).") do
92
+ options[:do_second_guess] = false
93
+ options[:lookup_order] = [ :exact ]
94
+ end
95
+ opts.on("-a", "--all", "Show info for all methods in Multiple choices",
96
+ "(default: don't)") do
97
+ options[:expand_choices] = true
98
+ end
92
99
 
93
- opts.on("--classes", "List all known classes/modules.") do
94
- options[:use_pager] = true
95
- options[:list_classes] = true
96
- end
97
- opts.on("--methods", "List all known methods.") do
98
- options[:use_pager] = true
99
- options[:list_methods] = true
100
- end
101
- opts.on("-l", "--list-names", "List all known namespaces/methods.") do
102
- options[:use_pager] = true
103
- options[:list_classes] = true
104
- options[:list_methods] = true
105
- end
100
+ opts.on("-e", "--extended", "Show all methods for given namespace.") do
101
+ options[:extended] = true
102
+ options[:use_pager] = true
103
+ options[:format] = "plain"
104
+ end
106
105
 
107
- opts.on("-S", "--full-text", "Perform full-text search.") do
108
- options[:do_full_text] = true
109
- options[:use_pager] = true if options[:use_pager].nil?
110
- options[:format] = "plain"
111
- end
106
+ opts.on("--show-matches", "Only show matching entries."){ options[:show_matches] = true }
112
107
 
113
- opts.on("-F", "--full-text-dir DIR", "Use full-text index in DIR",
114
- "(default: #{options[:full_text_dir]})") do |dir|
115
- options[:full_text_dir] = dir if dir
116
- options[:do_full_text] = true
117
- options[:use_pager] = true
118
- options[:format] = "plain"
119
- end
108
+ opts.on("--classes", "List all known classes/modules.") do
109
+ options[:use_pager] = true
110
+ options[:list_classes] = true
111
+ end
112
+ opts.on("--methods", "List all known methods.") do
113
+ options[:use_pager] = true
114
+ options[:list_methods] = true
115
+ end
116
+ opts.on("-l", "--list-names", "List all known namespaces/methods.") do
117
+ options[:use_pager] = true
118
+ options[:list_classes] = true
119
+ options[:list_methods] = true
120
+ end
120
121
 
121
- opts.on("-f", "--format FMT", "Format to use when displaying output:",
122
- " ansi, plain (default: #{options[:format]})") do |format|
123
- options[:format] = format
124
- end
122
+ opts.on("-S", "--full-text", "Perform full-text search.") do
123
+ options[:do_full_text] = true
124
+ options[:use_pager] = true if options[:use_pager].nil?
125
+ options[:format] = "plain"
126
+ end
125
127
 
126
- opts.on("-P", "--[no-]pager", "Use pager.", "(default: don't)") do |usepager|
127
- options[:use_pager] = usepager
128
- options[:format] = "plain" if usepager
129
- end
128
+ opts.on("-F", "--full-text-dir DIR", "Use full-text index in DIR",
129
+ "(default: #{options[:full_text_dir]})") do |dir|
130
+ options[:full_text_dir] = dir if dir
131
+ options[:do_full_text] = true
132
+ options[:use_pager] = true
133
+ options[:format] = "plain"
134
+ end
130
135
 
131
- opts.on("-T", "Don't use a pager."){ options[:use_pager] = false }
136
+ opts.on("-f", "--format FMT", "Format to use when displaying output:",
137
+ " ansi, plain (default: #{options[:format]})") do |format|
138
+ options[:format] = format
139
+ end
132
140
 
133
- opts.on("--pager-cmd PAGER", "Use pager PAGER.", "(default: don't)") do |pager|
134
- options[:pager] = pager
135
- options[:use_pager] = true
136
- options[:format] = "plain"
137
- end
141
+ opts.on("-P", "--[no-]pager", "Use pager.", "(default: don't)") do |usepager|
142
+ options[:use_pager] = usepager
143
+ options[:format] = "plain" if usepager
144
+ end
138
145
 
139
- opts.on("-w", "--width WIDTH", "Set the width of the output.") do |width|
140
- w = width.to_i
141
- options[:width] = w > 0 ? w : options[:width]
146
+ opts.on("-T", "Don't use a pager."){ options[:use_pager] = false }
147
+
148
+ opts.on("--pager-cmd PAGER", "Use pager PAGER.", "(default: don't)") do |pager|
149
+ options[:pager] = pager
150
+ options[:use_pager] = true
151
+ options[:format] = "plain"
152
+ end
153
+
154
+ opts.on("-w", "--width WIDTH", "Set the width of the output.") do |width|
155
+ w = width.to_i
156
+ options[:width] = w > 0 ? w : options[:width]
157
+ end
158
+
159
+ opts.on("-h", "--help", "Show this help message") do
160
+ puts opts
161
+ exit
162
+ end
142
163
  end
164
+ optparser.parse!
143
165
 
144
- opts.on("-h", "--help", "Show this help message") do
145
- puts opts
166
+ if !options[:list_classes] && !options[:list_methods] && ARGV.empty?
167
+ puts optparser
146
168
  exit
147
169
  end
148
- end
149
- optparser.parse!
150
-
151
- if !options[:list_classes] && !options[:list_methods] && ARGV.empty?
152
- puts optparser
153
- exit
154
- end
170
+ end # lazy optparse loading
155
171
 
156
172
  # {{{ try to find where the method comes from exactly
157
173
  include FastRI::Util::MagicHelp
@@ -308,6 +324,7 @@ info_options = {
308
324
  :width => options[:width],
309
325
  :lookup_order => options[:lookup_order],
310
326
  :extended => options[:extended],
327
+ :expand_choices => options[:expand_choices],
311
328
  }
312
329
 
313
330
  # {{{ list classes or methods
@@ -326,7 +343,7 @@ ARGV.each do |term|
326
343
  # second-guess the correct method type only as the last resort.
327
344
  if result
328
345
  puts result
329
- elsif (new_query = FastRI::Util.change_query_method_type(help_query)) != help_query
346
+ elsif options[:do_second_guess] and (new_query = FastRI::Util.change_query_method_type(help_query)) != help_query
330
347
  puts service.info(new_query)
331
348
  else
332
349
  puts nil
data/bin/qri CHANGED
@@ -3,7 +3,6 @@
3
3
  # Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
4
4
  #
5
5
 
6
- require 'optparse'
7
6
  require 'fastri/util'
8
7
  require 'fastri/full_text_index'
9
8
 
@@ -39,119 +38,136 @@ options = {
39
38
  :extended => false,
40
39
  :index_file => File.join(FastRI::Util.find_home, ".fastri-index"),
41
40
  :local_mode => default_local_mode,
41
+ :do_second_guess => true,
42
+ :expand_choices => false,
42
43
  }
43
44
 
44
45
  override_addr_env = false
45
46
 
46
- optparser = OptionParser.new do |opts|
47
- opts.version = FastRI::FASTRI_VERSION
48
- opts.release = FastRI::FASTRI_RELEASE_DATE
49
- opts.banner = "Usage: #{File.basename($0)} [options] <query>"
50
47
 
51
- opts.on("-L", "--local", "Try to use local index instead of DRb service.",
52
- *[("(default)" if default_local_mode)].compact) do
53
- options[:local_mode] = true
54
- end
55
- opts.on("--index-file=FILE", "Use index file (forces --local mode).",
56
- "(default: #{options[:index_file]})") do |file|
57
- options[:index_file] = file
58
- options[:local_mode] = true
59
- end
60
- opts.on("-R", "--remote", "Use DRb service. #{'(default)' unless default_local_mode}") do
61
- options[:local_mode] = false
62
- end
63
- opts.on("-s", "--bind ADDR", "Bind to ADDR for incoming DRb connections.",
64
- "(default: 127.0.0.1)") do |addr|
65
- options[:addr] = addr
66
- override_addr_env = true
67
- end
48
+ # only load optparse if actually needed
49
+ # saves ~0.01-0.04s.
50
+ if (arg = ARGV[0]) && arg[0, 1] == "-" or ARGV.empty?
51
+ require 'optparse'
52
+ optparser = OptionParser.new do |opts|
53
+ opts.version = FastRI::FASTRI_VERSION
54
+ opts.release = FastRI::FASTRI_RELEASE_DATE
55
+ opts.banner = "Usage: #{File.basename($0)} [options] <query>"
68
56
 
69
- order_mapping = {
70
- 'e' => :exact, 'E' => :exact_ci, 'n' => :nested, 'N' => :nested_ci,
71
- 'p' => :partial, 'P' => :partial_ci, 'x' => :nested_partial,
72
- 'X' => :nested_partial_ci, 'a' => :anywhere, 'A' => :anywhere_ci,
73
- 'm' => :namespace_partial, 'M' => :namespace_partial_ci,
74
- 'f' => :full_partial, 'F' => :full_partial_ci,
75
- }
76
- opts.on("-O", "--order ORDER", "Specify lookup order.",
77
- "(default: eEnNpPxX)", "Uppercase: case-indep.",
78
- "e:exact n:nested p:partial (completion)",
79
- "x:nested and partial m:complete namespace",
80
- "f:complete both class and method",
81
- "a:match method name anywhere") do |order|
82
- options[:lookup_order] = order.split(//).map{|x| order_mapping[x]}.compact
83
- end
57
+ opts.on("-L", "--local", "Try to use local index instead of DRb service.",
58
+ *[("(default)" if default_local_mode)].compact) do
59
+ options[:local_mode] = true
60
+ end
61
+ opts.on("--index-file=FILE", "Use index file (forces --local mode).",
62
+ "(default: #{options[:index_file]})") do |file|
63
+ options[:index_file] = file
64
+ options[:local_mode] = true
65
+ end
66
+ opts.on("-R", "--remote", "Use DRb service. #{'(default)' unless default_local_mode}") do
67
+ options[:local_mode] = false
68
+ end
69
+ opts.on("-s", "--bind ADDR", "Bind to ADDR for incoming DRb connections.",
70
+ "(default: 127.0.0.1)") do |addr|
71
+ options[:addr] = addr
72
+ override_addr_env = true
73
+ end
84
74
 
85
- opts.on("-e", "--extended", "Show all methods for given namespace.") do
86
- options[:extended] = true
87
- options[:use_pager] = true
88
- options[:format] = "plain"
89
- end
75
+ order_mapping = {
76
+ 'e' => :exact, 'E' => :exact_ci, 'n' => :nested, 'N' => :nested_ci,
77
+ 'p' => :partial, 'P' => :partial_ci, 'x' => :nested_partial,
78
+ 'X' => :nested_partial_ci, 'a' => :anywhere, 'A' => :anywhere_ci,
79
+ 'm' => :namespace_partial, 'M' => :namespace_partial_ci,
80
+ 'f' => :full_partial, 'F' => :full_partial_ci,
81
+ }
82
+ opts.on("-O", "--order ORDER", "Specify lookup order.",
83
+ "(default: eEnNpPxX)", "Uppercase: case-indep.",
84
+ "e:exact n:nested p:partial (completion)",
85
+ "x:nested and partial m:complete namespace",
86
+ "f:complete both class and method",
87
+ "a:match method name anywhere") do |order|
88
+ options[:lookup_order] = order.split(//).map{|x| order_mapping[x]}.compact
89
+ end
90
90
 
91
- opts.on("--show-matches", "Only show matching entries."){ options[:show_matches] = true }
91
+ opts.on("-1", "--exact", "Does not do second guess(exact query).") do
92
+ options[:do_second_guess] = false
93
+ options[:lookup_order] = [ :exact ]
94
+ end
95
+ opts.on("-a", "--all", "Show info for all methods in Multiple choices",
96
+ "(default: don't)") do
97
+ options[:expand_choices] = true
98
+ end
92
99
 
93
- opts.on("--classes", "List all known classes/modules.") do
94
- options[:use_pager] = true
95
- options[:list_classes] = true
96
- end
97
- opts.on("--methods", "List all known methods.") do
98
- options[:use_pager] = true
99
- options[:list_methods] = true
100
- end
101
- opts.on("-l", "--list-names", "List all known namespaces/methods.") do
102
- options[:use_pager] = true
103
- options[:list_classes] = true
104
- options[:list_methods] = true
105
- end
100
+ opts.on("-e", "--extended", "Show all methods for given namespace.") do
101
+ options[:extended] = true
102
+ options[:use_pager] = true
103
+ options[:format] = "plain"
104
+ end
106
105
 
107
- opts.on("-S", "--full-text", "Perform full-text search.") do
108
- options[:do_full_text] = true
109
- options[:use_pager] = true if options[:use_pager].nil?
110
- options[:format] = "plain"
111
- end
106
+ opts.on("--show-matches", "Only show matching entries."){ options[:show_matches] = true }
112
107
 
113
- opts.on("-F", "--full-text-dir DIR", "Use full-text index in DIR",
114
- "(default: #{options[:full_text_dir]})") do |dir|
115
- options[:full_text_dir] = dir if dir
116
- options[:do_full_text] = true
117
- options[:use_pager] = true
118
- options[:format] = "plain"
119
- end
108
+ opts.on("--classes", "List all known classes/modules.") do
109
+ options[:use_pager] = true
110
+ options[:list_classes] = true
111
+ end
112
+ opts.on("--methods", "List all known methods.") do
113
+ options[:use_pager] = true
114
+ options[:list_methods] = true
115
+ end
116
+ opts.on("-l", "--list-names", "List all known namespaces/methods.") do
117
+ options[:use_pager] = true
118
+ options[:list_classes] = true
119
+ options[:list_methods] = true
120
+ end
120
121
 
121
- opts.on("-f", "--format FMT", "Format to use when displaying output:",
122
- " ansi, plain (default: #{options[:format]})") do |format|
123
- options[:format] = format
124
- end
122
+ opts.on("-S", "--full-text", "Perform full-text search.") do
123
+ options[:do_full_text] = true
124
+ options[:use_pager] = true if options[:use_pager].nil?
125
+ options[:format] = "plain"
126
+ end
125
127
 
126
- opts.on("-P", "--[no-]pager", "Use pager.", "(default: don't)") do |usepager|
127
- options[:use_pager] = usepager
128
- options[:format] = "plain" if usepager
129
- end
128
+ opts.on("-F", "--full-text-dir DIR", "Use full-text index in DIR",
129
+ "(default: #{options[:full_text_dir]})") do |dir|
130
+ options[:full_text_dir] = dir if dir
131
+ options[:do_full_text] = true
132
+ options[:use_pager] = true
133
+ options[:format] = "plain"
134
+ end
130
135
 
131
- opts.on("-T", "Don't use a pager."){ options[:use_pager] = false }
136
+ opts.on("-f", "--format FMT", "Format to use when displaying output:",
137
+ " ansi, plain (default: #{options[:format]})") do |format|
138
+ options[:format] = format
139
+ end
132
140
 
133
- opts.on("--pager-cmd PAGER", "Use pager PAGER.", "(default: don't)") do |pager|
134
- options[:pager] = pager
135
- options[:use_pager] = true
136
- options[:format] = "plain"
137
- end
141
+ opts.on("-P", "--[no-]pager", "Use pager.", "(default: don't)") do |usepager|
142
+ options[:use_pager] = usepager
143
+ options[:format] = "plain" if usepager
144
+ end
138
145
 
139
- opts.on("-w", "--width WIDTH", "Set the width of the output.") do |width|
140
- w = width.to_i
141
- options[:width] = w > 0 ? w : options[:width]
146
+ opts.on("-T", "Don't use a pager."){ options[:use_pager] = false }
147
+
148
+ opts.on("--pager-cmd PAGER", "Use pager PAGER.", "(default: don't)") do |pager|
149
+ options[:pager] = pager
150
+ options[:use_pager] = true
151
+ options[:format] = "plain"
152
+ end
153
+
154
+ opts.on("-w", "--width WIDTH", "Set the width of the output.") do |width|
155
+ w = width.to_i
156
+ options[:width] = w > 0 ? w : options[:width]
157
+ end
158
+
159
+ opts.on("-h", "--help", "Show this help message") do
160
+ puts opts
161
+ exit
162
+ end
142
163
  end
164
+ optparser.parse!
143
165
 
144
- opts.on("-h", "--help", "Show this help message") do
145
- puts opts
166
+ if !options[:list_classes] && !options[:list_methods] && ARGV.empty?
167
+ puts optparser
146
168
  exit
147
169
  end
148
- end
149
- optparser.parse!
150
-
151
- if !options[:list_classes] && !options[:list_methods] && ARGV.empty?
152
- puts optparser
153
- exit
154
- end
170
+ end # lazy optparse loading
155
171
 
156
172
  # {{{ try to find where the method comes from exactly
157
173
  include FastRI::Util::MagicHelp
@@ -308,6 +324,7 @@ info_options = {
308
324
  :width => options[:width],
309
325
  :lookup_order => options[:lookup_order],
310
326
  :extended => options[:extended],
327
+ :expand_choices => options[:expand_choices],
311
328
  }
312
329
 
313
330
  # {{{ list classes or methods
@@ -326,7 +343,7 @@ ARGV.each do |term|
326
343
  # second-guess the correct method type only as the last resort.
327
344
  if result
328
345
  puts result
329
- elsif (new_query = FastRI::Util.change_query_method_type(help_query)) != help_query
346
+ elsif options[:do_second_guess] and (new_query = FastRI::Util.change_query_method_type(help_query)) != help_query
330
347
  puts service.info(new_query)
331
348
  else
332
349
  puts nil
@@ -29,7 +29,7 @@ require 'fastri/util'
29
29
  # {{{ cmdline parsing and service discovery
30
30
  # we bind to 127.0.0.1 by default, because otherwise Ruby will try with
31
31
  # 0.0.0.0, which results in a DNS request, adding way too much latency
32
- options = {:addr => "127.0.0.1"}
32
+ options = {:addr => "127.0.0.1", :width => ENV['RI_EMACS_COLUMNS'] ? ENV['RI_EMACS_COLUMNS'].to_i : 72}
33
33
  override_addr_env = false
34
34
  optparser = OptionParser.new do |opts|
35
35
  opts.banner = "Usage: ri-emacs [options] <query>"
@@ -40,6 +40,10 @@ optparser = OptionParser.new do |opts|
40
40
  override_addr_env = true
41
41
  end
42
42
 
43
+ opts.on("-w", "--width WIDTH", "Set the width of the output.") do |width|
44
+ options[:width] = width
45
+ end
46
+
43
47
  opts.on("-h", "--help", "Show this help message") do
44
48
  puts opts
45
49
  exit
@@ -75,8 +79,9 @@ service = ring_server.read([:name, :FastRI, nil, nil])[2]
75
79
  class EventLoop
76
80
  include FastRI::Util::MagicHelp
77
81
 
78
- def initialize(ri)
82
+ def initialize(ri, options)
79
83
  @ri = ri
84
+ @opts = options
80
85
  end
81
86
 
82
87
  def run
@@ -171,11 +176,11 @@ class EventLoop
171
176
  end
172
177
 
173
178
  def display_(what, keyw)
174
- data = @ri.__send__(what, magic_help(keyw))
179
+ data = @ri.__send__(what, magic_help(keyw), :width => @opts[:width])
175
180
  if data
176
181
  puts data
177
182
  elsif (new_keyw = FastRI::Util.change_query_method_type(keyw)) != keyw
178
- puts @ri.__send__(what, new_keyw)
183
+ puts @ri.__send__(what, new_keyw, :width => @opts[:width])
179
184
  end
180
185
  puts "RI_EMACS_END_OF_INFO"
181
186
  end
@@ -192,6 +197,6 @@ end
192
197
 
193
198
  #{{{ event loop
194
199
  #$stdout.sync = true # better not set sync=true, causes problems with emacs
195
- EventLoop.new(service).run
200
+ EventLoop.new(service, options).run
196
201
 
197
202
  # vi: set sw=2 expandtab:
@@ -181,6 +181,7 @@ class RiService
181
181
  :formatter => :ansi,
182
182
  :width => 72,
183
183
  :extended => false,
184
+ :expand_choices => false,
184
185
  }
185
186
 
186
187
  def matches(keyword, options = {})
@@ -224,6 +225,9 @@ class RiService
224
225
  formatter.draw_line("Multiple choices:")
225
226
  formatter.blankline
226
227
  formatter.wrap(entries.map{|x| x.full_name}.join(", "))
228
+ entries.each do |entry|
229
+ display.display_method_info(@ri_reader.get_method(entry)) if entry.type == :method
230
+ end if options[:expand_choices]
227
231
  end
228
232
  end
229
233
  rescue RiError
@@ -7,13 +7,27 @@ unless defined? ::Gem
7
7
  require 'rbconfig'
8
8
  module Gem
9
9
  def self.path
10
- ENV['GEM_HOME'] || default_dir
10
+ [ENV['GEM_HOME'], ENV['GEM_PATH'], default_dir].compact.flatten
11
11
  end
12
12
  def self.default_dir
13
13
  if defined? RUBY_FRAMEWORK_VERSION
14
- return File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems")
14
+ paths = []
15
+ paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
16
+ path = File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems")
17
+ newpath = File.join(path, Config::CONFIG['ruby_version'])
18
+ # RubyGems post r1498 appends the ruby version to the path. This
19
+ # modification was included in the RubyGems shipped with 10.5.0.
20
+ if File.directory?(newpath)
21
+ # try new path first, user might have upgraded RubyGems and left old
22
+ # installation behind
23
+ paths + [ newpath ]
24
+ else
25
+ # pre-10.5.0 or older RubyGems
26
+ paths + [ path ]
27
+ end
15
28
  else
16
- File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
29
+ [ File.join(Config::CONFIG['libdir'], 'ruby', 'gems',
30
+ Config::CONFIG['ruby_version']) ]
17
31
  end
18
32
  end
19
33
  end
@@ -34,10 +48,10 @@ module Util
34
48
  # (once per version).
35
49
  def gem_directories_unique
36
50
  return [] unless defined? Gem
37
- gemdirs = Dir["#{Gem.path}/doc/*/ri"]
51
+ gemdirs = Gem.path.map{|p| Dir["#{p}/doc/*/ri"]}.flatten
38
52
  gems = Hash.new{|h,k| h[k] = []}
39
53
  gemdirs.each do |path|
40
- gemname, version = %r{/([^/]+)-(.*)/ri$}.match(path).captures
54
+ gemname, version = %r{/([^/]+)-([^-]*)/ri$}.match(path).captures
41
55
  if gemname.nil? # doesn't follow any conventions :(
42
56
  gems[path[%r{/([^/]+)/ri$}, 1]] << [nil, path]
43
57
  else
@@ -2,8 +2,8 @@
2
2
  #
3
3
 
4
4
  module FastRI
5
- FASTRI_VERSION = "0.3.0"
6
- FASTRI_RELEASE_DATE = "2007-01-29"
5
+ FASTRI_VERSION = "0.3.1"
6
+ FASTRI_RELEASE_DATE = "2008-02-02"
7
7
  FASTRI_INDEX_FORMAT = "0.1.0"
8
8
  FASTRI_FT_INDEX_FORMAT = "1.0.0"
9
9
  FASTRI_FT_INDEX_FORMAT_MAJOR = "1"
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: fastri
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0.1
7
- date: 2007-01-29 00:00:00 +01:00
6
+ version: 0.3.1.1
7
+ date: 2008-02-02 00:00:00 +01:00
8
8
  summary: RI docs across machines, faster and smarter than ri.
9
9
  require_paths:
10
10
  - lib
11
11
  email: mfp@acm.org
12
- homepage: http://eigenclass.org/hiki.rb?fastri
12
+ homepage: http://eigenclass.org/hiki/fastri
13
13
  rubyforge_project:
14
14
  description: FastRI is an alternative to the ri command-line tool. It is *much* faster, and also allows you to offer RI lookup services over DRb. FastRI is smarter than ri, and can find classes anywhere in the hierarchy without specifying the "full path". FastRI can perform fast full-text searches. It also knows about gems, and can tell you e.g. which extensions to a core class were added by a specific gem.
15
15
  autorequire:
@@ -59,35 +59,35 @@ files:
59
59
  - bin/fastri-server
60
60
  - bin/ri-emacs
61
61
  - lib/fastri/ri_index.rb
62
- - lib/fastri/ri_service.rb
63
62
  - lib/fastri/version.rb
63
+ - lib/fastri/name_descriptor.rb
64
+ - lib/fastri/ri_service.rb
64
65
  - lib/fastri/util.rb
65
- - lib/fastri/full_text_indexer.rb
66
66
  - lib/fastri/full_text_index.rb
67
- - lib/fastri/name_descriptor.rb
67
+ - lib/fastri/full_text_indexer.rb
68
68
  - CHANGES
69
69
  - COPYING
70
70
  - LEGAL
71
71
  - LICENSE
72
72
  - Rakefile
73
73
  - README.en
74
- - test/test_ri_index.rb
75
74
  - test/test_full_text_index.rb
76
- - test/test_functional_ri_service.rb
77
- - test/test_full_text_indexer.rb
78
75
  - test/test_name_descriptor.rb
79
- - test/test_util.rb
80
76
  - test/test_integration_full_text_index.rb
77
+ - test/test_full_text_indexer.rb
78
+ - test/test_functional_ri_service.rb
79
+ - test/test_util.rb
80
+ - test/test_ri_index.rb
81
81
  - setup.rb
82
82
  - pre-install.rb
83
83
  test_files:
84
- - test/test_ri_index.rb
85
84
  - test/test_full_text_index.rb
86
- - test/test_functional_ri_service.rb
87
- - test/test_full_text_indexer.rb
88
85
  - test/test_name_descriptor.rb
89
- - test/test_util.rb
90
86
  - test/test_integration_full_text_index.rb
87
+ - test/test_full_text_indexer.rb
88
+ - test/test_functional_ri_service.rb
89
+ - test/test_util.rb
90
+ - test/test_ri_index.rb
91
91
  rdoc_options:
92
92
  - --title
93
93
  - "FastRI: better, faster ri"