Class: Uncool::GeneratorAbstract
- Inherits:
-
Object
- Object
- Uncool::GeneratorAbstract
show all
- Defined in:
- lib/uncool/generator/abstract.rb
Overview
Instance Method Summary
collapse
Constructor Details
Returns a new instance of GeneratorAbstract.
8
9
10
11
12
|
# File 'lib/uncool/generator/abstract.rb', line 8
def initialize(options={})
@namespaces = options[:namespaces] || []
@checklist = options[:checklist]
@options = options || {}
end
|
Instance Method Details
#checklist ⇒ Object
20
21
22
|
# File 'lib/uncool/generator/abstract.rb', line 20
def checklist
@checklist ||= default_checklist
end
|
#covered? ⇒ Boolean
Include already covered methods.
35
36
37
|
# File 'lib/uncool/generator/abstract.rb', line 35
def covered?
options[:covered]
end
|
#default_checklist ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/uncool/generator/abstract.rb', line 54
def default_checklist
list = []
targets.each do |target|
target.public_instance_methods(false).each do |meth|
list << Unit.new(target, meth)
end
if private?
target.protected_instance_methods(false).each do |meth|
list << Unit.new(target, meth, :access=>:protected)
end
target.private_instance_methods(false).each do |meth|
list << Unit.new(target, meth, :access=>:private)
end
end
end
list
end
|
#generate ⇒ Object
Override this method in subclasses.
50
51
|
# File 'lib/uncool/generator/abstract.rb', line 50
def generate
end
|
#mapping ⇒ Object
45
46
47
|
# File 'lib/uncool/generator/abstract.rb', line 45
def mapping
checklist.sort.group_by{ |mp, yes| mp.target }
end
|
#namespaces ⇒ Object
15
16
17
|
# File 'lib/uncool/generator/abstract.rb', line 15
def namespaces
@namespaces
end
|
#options ⇒ Object
30
31
32
|
# File 'lib/uncool/generator/abstract.rb', line 30
def options
@options
end
|
#private? ⇒ Boolean
Include private and protected methods?
40
41
42
|
# File 'lib/uncool/generator/abstract.rb', line 40
def private?
options[:private]
end
|
#targets ⇒ Object
25
26
27
|
# File 'lib/uncool/generator/abstract.rb', line 25
def targets
@targets ||= namespaces.map{ |ns| eval(ns, TOPLEVEL_BINDING) }
end
|