Module: Qdocs
- Defined in:
- lib/qdocs.rb,
lib/qdocs/server.rb,
lib/qdocs/version.rb,
lib/qdocs/active_record.rb
Defined Under Namespace
Modules: ActiveRecord, Base, Helpers
Classes: Server, UnknownClassError, UnknownMethodError, UnknownMethodTypeError, UnknownPatternError
Constant Summary
collapse
- METHOD_REGEXP =
/(?:[a-zA-Z_]+|\[\])[?!=]?/.freeze
- CONST_REGEXP =
/[[:upper:]]\w*(?:::[[:upper:]]\w*)*/.freeze
- Handler =
if Object.const_defined? :ActiveRecord
require "qdocs/active_record"
Qdocs::ActiveRecord
else
Qdocs::Base
end
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.load_env(dir_level = nil) ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/qdocs.rb', line 155
def self.load_env(dir_level = nil)
check_dir = dir_level || ["."]
project_top_level = Pathname(File.join(*check_dir, "Gemfile")).exist? ||
Pathname(File.join(*check_dir, ".git")).exist?
if project_top_level && Pathname(File.join(*check_dir, "config", "environment.rb")).exist?
require File.join(*check_dir, "config", "environment.rb")
elsif project_top_level
else
dir_level ||= []
dir_level << ".."
Qdocs.load_env(dir_level)
end
end
|
.lookup(input) ⇒ Object
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/qdocs.rb', line 179
def self.lookup(input)
case input
when /\A([[:lower:]](?:#{METHOD_REGEXP})?)\z/
Handler::Method.new(input).show(Object, $1, :instance)
when /\A(#{CONST_REGEXP})\.(#{METHOD_REGEXP})\z/
Handler::Method.new(input).show($1, $2, :singleton)
when /\A(#{CONST_REGEXP})#(#{METHOD_REGEXP})\z/
Handler::Method.new(input).show($1, $2, :instance)
when /\A(#{CONST_REGEXP})\z/
Handler::Const.new(input).show($1)
when %r{\A(#{CONST_REGEXP})/([^/]+)/\z}
Handler::Method.new(input).index($1, Regexp.new($2))
else
raise UnknownPatternError, "Unrecognised pattern #{input}"
end
end
|