Class: BitClust::LibraryEntry
- Inherits:
-
Entry
show all
- Includes:
- Enumerable
- Defined in:
- lib/bitclust/libraryentry.rb
Overview
Entry for libraries (“_builtin”, “yaml”, etc.)
Constant Summary
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.
Class Method Summary
collapse
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, 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.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/bitclust/libraryentry.rb', line 25
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.
42
43
44
|
# File 'lib/bitclust/libraryentry.rb', line 42
def id
@id
end
|
#name ⇒ Object
Also known as:
label
Returns the value of attribute name.
42
43
44
|
# File 'lib/bitclust/libraryentry.rb', line 42
def name
@name
end
|
Class Method Details
21
22
23
|
# File 'lib/bitclust/libraryentry.rb', line 21
def LibraryEntry.type_id
:library
end
|
Instance Method Details
#<=>(other) ⇒ Object
57
58
59
|
# File 'lib/bitclust/libraryentry.rb', line 57
def <=>(other)
@id.casecmp(other.id)
end
|
#==(other) ⇒ Object
Also known as:
eql?
46
47
48
49
|
# File 'lib/bitclust/libraryentry.rb', line 46
def ==(other)
return false if self.class != other.class
@id == other.id
end
|
#add_class(c) ⇒ Object
209
210
211
212
213
214
215
|
# File 'lib/bitclust/libraryentry.rb', line 209
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
217
218
219
220
221
222
223
|
# File 'lib/bitclust/libraryentry.rb', line 217
def add_method(m)
unless methodmap()[m]
methods().push m
methodmap()[m] = m
@db.dirty_library self
end
end
|
#all_classes ⇒ Object
110
111
112
113
114
|
# File 'lib/bitclust/libraryentry.rb', line 110
def all_classes
return @all_classes if @all_classes
required_classes = (sublibraries & requires).map{|l| l.classes }.flatten
@all_classes = (classes() + required_classes).uniq.sort
end
|
#all_error_classes ⇒ Object
120
121
122
|
# File 'lib/bitclust/libraryentry.rb', line 120
def all_error_classes
@all_error_classes ||= all_classes.select{|c| c.error_class? }
end
|
#all_modules ⇒ Object
124
125
126
|
# File 'lib/bitclust/libraryentry.rb', line 124
def all_modules
@all_modules ||= all_classes.select{|c| c.module? }.sort
end
|
#all_objects ⇒ Object
128
129
130
|
# File 'lib/bitclust/libraryentry.rb', line 128
def all_objects
@all_objects ||= all_classes.select{|c| c.object? }.sort
end
|
#all_requires(libs = {}) ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'lib/bitclust/libraryentry.rb', line 101
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
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/bitclust/libraryentry.rb', line 88
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
152
153
154
|
# File 'lib/bitclust/libraryentry.rb', line 152
def classnames
classes().map {|c| c.name }
end
|
#description ⇒ Object
84
85
86
|
# File 'lib/bitclust/libraryentry.rb', line 84
def description
source.split(/\n\n+/, 2)[0]
end
|
#each_class(&block) ⇒ Object
156
157
158
|
# File 'lib/bitclust/libraryentry.rb', line 156
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
116
117
118
|
# File 'lib/bitclust/libraryentry.rb', line 116
def error_classes
@error_classes ||= classes.select{|c| c.error_class? }
end
|
#fetch_class(name) ⇒ Object
143
144
145
146
|
# File 'lib/bitclust/libraryentry.rb', line 143
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
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/bitclust/libraryentry.rb', line 172
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
148
149
150
|
# File 'lib/bitclust/libraryentry.rb', line 148
def get_class(name)
classes().detect {|c| c.name == name }
end
|
53
54
55
|
# File 'lib/bitclust/libraryentry.rb', line 53
def hash
@id.hash
end
|
80
81
82
|
# File 'lib/bitclust/libraryentry.rb', line 80
def inspect
"#<library #{@id}>"
end
|
61
62
63
|
# File 'lib/bitclust/libraryentry.rb', line 61
def labels
[label()]
end
|
#name?(n) ⇒ Boolean
65
66
67
|
# File 'lib/bitclust/libraryentry.rb', line 65
def name?(n)
name() == n
end
|
#require(lib) ⇒ Object
132
133
134
|
# File 'lib/bitclust/libraryentry.rb', line 132
def require(lib)
requires().push lib
end
|
#sublibrary(lib) ⇒ Object
136
137
138
139
140
141
|
# File 'lib/bitclust/libraryentry.rb', line 136
def sublibrary(lib)
unless sublibraries().include?(lib)
sublibraries().push lib
lib.is_sublibrary = true
end
end
|