Class: BitClust::LibraryEntry
- Inherits:
-
Entry
show all
- Defined in:
- lib/bitclust/libraryentry.rb
Overview
Entry for libraries ("_builtin", "yaml", etc.)
Constant Summary
Constants inherited
from Entry
Entry::BracketLink
Constants included
from NameUtils
NameUtils::CHAR_TO_MARK, NameUtils::CHAR_TO_NAME, NameUtils::CLASS_NAME_RE, NameUtils::CLASS_PATH_RE, NameUtils::CONST_PATH_RE, NameUtils::CONST_RE, NameUtils::GVAR_RE, NameUtils::LIBNAME_RE, NameUtils::MARK_TO_CHAR, NameUtils::MARK_TO_NAME, NameUtils::METHOD_NAME_RE, NameUtils::METHOD_SPEC_RE, NameUtils::MID, NameUtils::NAME_TO_CHAR, NameUtils::NAME_TO_MARK, NameUtils::TYPEMARK_RE
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
(also: #label)
readonly
Returns the value of attribute name.
Instance Method Summary
collapse
Methods inherited from Entry
#detail_source, #encoding, #loaded?, persistent_properties, property, #save, #synopsis_source, #type_id
Methods included from NameUtils
build_method_id, classid2name, classname2id, classname?, decodeid, decodename_fs, decodename_url, display_typemark, encodeid, encodename_fs, encodename_rdocurl, encodename_url, functionname?, gvarname?, html_filename, libid2name, libname2id, libname?, method_spec?, methodid2classid, methodid2libid, methodid2mname, methodid2specparts, methodid2specstring, methodid2typechar, methodid2typemark, methodid2typename, methodname?, split_method_id, split_method_spec, typechar2mark, typechar2name, typechar?, typemark2char, typemark2name, typemark?, typename2char, typename2mark, typename?
Constructor Details
Returns a new instance of LibraryEntry.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/bitclust/libraryentry.rb', line 23
def initialize(db, id)
super db
@id = id
@name = libid2name(@id)
if saved?
@classmap = nil
@methodmap = nil
@link_checked = true
else
@classmap = {}
@methodmap = {}
@link_checked = false
end
init_properties
@all_classes = nil
end
|
Instance Attribute Details
Returns the value of attribute id.
40
41
42
|
# File 'lib/bitclust/libraryentry.rb', line 40
def id
@id
end
|
#name ⇒ Object
Also known as:
label
Returns the value of attribute name.
40
41
42
|
# File 'lib/bitclust/libraryentry.rb', line 40
def name
@name
end
|
Instance Method Details
#<=>(other) ⇒ Object
55
56
57
|
# File 'lib/bitclust/libraryentry.rb', line 55
def <=>(other)
@id.casecmp(other.id)
end
|
#==(other) ⇒ Object
Also known as:
eql?
44
45
46
47
|
# File 'lib/bitclust/libraryentry.rb', line 44
def ==(other)
return false if self.class != other.class
@id == other.id
end
|
#add_class(c) ⇒ Object
210
211
212
213
214
215
216
|
# File 'lib/bitclust/libraryentry.rb', line 210
def add_class(c)
unless classmap()[c.name]
classes().push c
classmap()[c.name] = c
@db.dirty_library self
end
end
|
#add_method(m) ⇒ Object
218
219
220
221
222
223
224
|
# File 'lib/bitclust/libraryentry.rb', line 218
def add_method(m)
unless methodmap()[m]
methods().push m
methodmap()[m] = m
@db.dirty_library self
end
end
|
#all_classes ⇒ Object
108
109
110
111
112
|
# File 'lib/bitclust/libraryentry.rb', line 108
def all_classes
return (@all_classes || raise) if @all_classes
required_classes = (sublibraries & requires).map{|l| l.classes }.flatten
@all_classes = (classes() + required_classes).uniq.sort
end
|
#all_error_classes ⇒ Object
118
119
120
|
# File 'lib/bitclust/libraryentry.rb', line 118
def all_error_classes
@all_error_classes ||= all_classes.select{|c| c.error_class? }
end
|
#all_modules ⇒ Object
122
123
124
|
# File 'lib/bitclust/libraryentry.rb', line 122
def all_modules
@all_modules ||= all_classes.select{|c| c.module? }.sort
end
|
#all_objects ⇒ Object
126
127
128
|
# File 'lib/bitclust/libraryentry.rb', line 126
def all_objects
@all_objects ||= all_classes.select{|c| c.object? }.sort
end
|
#all_requires(libs = {}) ⇒ Object
99
100
101
102
103
104
105
106
|
# File 'lib/bitclust/libraryentry.rb', line 99
def all_requires(libs = {})
requires.each{|l|
next if libs[l.name]
libs[l.name] = l
l.all_requires(libs)
}
libs.values
end
|
#check_link(path = []) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/bitclust/libraryentry.rb', line 86
def check_link(path = [])
return if @link_checked
if path.include?(name())
raise InvalidLink, "looped require: #{path_string(path)}"
end
path.push name()
requires().each do |lib|
lib.check_link path
end
path.pop
@link_checked = true
end
|
#classnames ⇒ Object
150
151
152
|
# File 'lib/bitclust/libraryentry.rb', line 150
def classnames
classes().map {|c| c.name }
end
|
#description ⇒ Object
82
83
84
|
# File 'lib/bitclust/libraryentry.rb', line 82
def description
description_text(source.split(/\n\n+/, 2)[0])
end
|
#each_class(&block) ⇒ Object
154
155
156
|
# File 'lib/bitclust/libraryentry.rb', line 154
def each_class(&block)
classes().each(&block)
end
|
#each_method(&block) ⇒ Object
193
194
195
|
# File 'lib/bitclust/libraryentry.rb', line 193
def each_method(&block)
methods().each(&block)
end
|
#error_classes ⇒ Object
114
115
116
|
# File 'lib/bitclust/libraryentry.rb', line 114
def error_classes
@error_classes ||= classes.select{|c| c.error_class? }
end
|
#fetch_class(name) ⇒ Object
141
142
143
144
|
# File 'lib/bitclust/libraryentry.rb', line 141
def fetch_class(name)
get_class(name) or
raise ClassNotFound, "no such class in the library #{name()}: #{name}"
end
|
#fetch_method(spec) ⇒ Object
184
185
186
187
188
189
190
191
|
# File 'lib/bitclust/libraryentry.rb', line 184
def fetch_method(spec)
classes().each do |c|
m = c.get_method(spec)
return m if m
end
methods().detect {|m| spec.match?(m) } or
raise MethodNotFound, "no such method in the library #{name()}: #{name}"
end
|
#fetch_methods(spec) ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/bitclust/libraryentry.rb', line 171
def fetch_methods(spec)
ms = if c = get_class(spec.klass)
then c.fetch_methods(spec)
else [] end +
methods().select {|m| spec.match?(m) }
if ms.empty?
raise MethodNotFound, "no such method in the library #{name()}: #{name}"
end
ms
end
|
#get_class(name) ⇒ Object
146
147
148
|
# File 'lib/bitclust/libraryentry.rb', line 146
def get_class(name)
classes().detect {|c| c.name == name }
end
|
51
52
53
|
# File 'lib/bitclust/libraryentry.rb', line 51
def hash
@id.hash
end
|
78
79
80
|
# File 'lib/bitclust/libraryentry.rb', line 78
def inspect
"#<library #{@id}>"
end
|
59
60
61
|
# File 'lib/bitclust/libraryentry.rb', line 59
def labels
[label()]
end
|
#name?(n) ⇒ Boolean
63
64
65
|
# File 'lib/bitclust/libraryentry.rb', line 63
def name?(n)
name() == n
end
|
#require(lib) ⇒ Object
130
131
132
|
# File 'lib/bitclust/libraryentry.rb', line 130
def require(lib)
requires().push lib
end
|
#sublibrary(lib) ⇒ Object
134
135
136
137
138
139
|
# File 'lib/bitclust/libraryentry.rb', line 134
def sublibrary(lib)
unless sublibraries().include?(lib)
sublibraries().push lib
lib.is_sublibrary = true
end
end
|