Module: Q

Defined in:
lib/q.rb,
lib/q/command.rb,
lib/q/commands/glob.rb,
lib/q/commands/help.rb,
lib/q/commands/search.rb

Defined Under Namespace

Classes: Command, Glob, Help, Search

Constant Summary collapse

DEFAULT_SHORTCUT =
:search
SHORTCUT =
if ARGV.empty?
	:help
elsif @@registered_commands.has_key? ARGV.first.to_sym
	ARGV.shift.to_sym
else
	DEFAULT_SHORTCUT
end
DOCSET_PATHS =

docsets to search within

[ # docsets to search within
	"/Library/Developer/Shared/Documentation/DocSets/*.docset",
	"/Developer/Documentation/DocSets/*.docset",
	"/Developer/Platforms/*.platform/Developer/Documentation/DocSets/*.docset"
]
DOCSET_CONTENTS_PATH =
"/Contents/Resources/Documents/documentation/*/Reference/"
PATTERNS =

these patterns are matched within <docset>/Contents/Resources/Documents/documentation/*/Reference/

[ # these patterns are matched within <docset>/Contents/Resources/Documents/documentation/*/Reference/
	"%{0}%{1}/Reference/reference.html", # iPhone/CoreGraphics
	"%{0}%{1}Ref/index.html", # iPhone CoreFoundation
	"%{0}%{1}Ref/Reference/reference.html", # CoreFoundation
	"%{0}%{1}_Class/%{0}%{1}/%{0}%{1}.html", # iPhone/UIKit
	"%{0}%{1}_Class/%{0}%{1}ClassReference/%{0}%{1}ClassReference.html",
	"%{0}%{1}_Class/Introduction/Introduction.html",
	"%{0}%{1}_class/Reference/%{0}%{1}.html",
	"%{0}%{1}_class/Reference/Reference.html",
	"%{0}%{1}_ClassRef/Reference/%{0}%{1}.html", # iPhone/OpenGL ES
	"%{0}%{1}_protocol/Reference/%{0}%{1}.html",
	"%{0}%{1}_protocol/Reference/Reference.html",
	"*/Protocols/%{0}%{1}_protocol/Reference/Reference.html",
	"*/Classes/%{0}%{1}_Class/Introduction/Introduction.html",
	"*/Classes/%{0}%{1}_Class/Reference/%{0}%{1}.html",
	"*/Classes/%{0}%{1}_Class/Reference/Reference.html",
	"Foundation/Classes/%{0}%{1}_Class/Reference/Reference.html",
	"ManPages/man3/%{0}%{1}.3.html", # man pages, e.g. OpenGL man pages
	"*/Classes/%{0}%{1}_Class/%{0}%{1}.html",
	"*/Classes/%{0}%{1}_WebKitAdditions/Reference/Reference.html",
]
PATTERN_PATHS =
(DOCSET_PATHS.reduce([]){ |memo, docset_path| memo + PATTERNS.collect{ |pattern| docset_path + DOCSET_CONTENTS_PATH + pattern } }).flatten
PREFIXES =
%w(ca cf cg dom eagl gl glu ib ns qt ui web)
@@registered_commands =
{}
@@unique_commands =
[]

Class Method Summary collapse

Class Method Details

.commandsObject



17
18
19
# File 'lib/q.rb', line 17

def self.commands
	@@registered_commands
end

.register_command(shortcut, command) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/q.rb', line 5

def self.register_command(shortcut, command)
	if shortcut.is_a? Array
		shortcut.each do |s|
			register_command(s, command)
		end
	else
		@@registered_commands[shortcut.to_sym] = command
		@@unique_commands << command unless @@unique_commands.include? command
		command.registered_shortcuts << shortcut.to_sym
	end
end

.unique_commandsObject



21
22
23
# File 'lib/q.rb', line 21

def self.unique_commands
	@@unique_commands
end