Module: MethodArgs
- Defined in:
- lib/method_args.rb,
lib/method_args/args.rb,
lib/method_args/version.rb,
lib/method_args/processor.rb,
lib/method_args/method_registry.rb
Defined Under Namespace
Classes: Args, MethodRegistry, Processor
Constant Summary
collapse
- ClassMethodRegistry =
Hash.new{|h, k| h[k] = MethodRegistry.new}
- FileRegistry =
Set.new
- VERSION =
'0.1.1'
Class Method Summary
collapse
Class Method Details
.args_for_method(method) ⇒ Object
.class_key(cls) ⇒ Object
42
43
44
45
46
|
# File 'lib/method_args.rb', line 42
def self.class_key(cls)
nesting = cls.class_eval("Module.nesting")
nesting.pop
nesting.join('::')
end
|
.expand_path(file) ⇒ Object
48
49
50
51
|
# File 'lib/method_args.rb', line 48
def self.expand_path(file)
file = File.expand_path(file)
File.exist?(file) ? file : "#{file}.rb"
end
|
.load(file, require_file = true) ⇒ Object
16
17
18
19
|
# File 'lib/method_args.rb', line 16
def self.load(file, require_file = true)
require file if require_file
register file
end
|
.parse(file, require_file = true) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/method_args.rb', line 34
def self.parse(file, require_file = true)
parser = RubyParser.new
sexp = parser.process(File.read(expand_path(file)))
method_args = Processor.new
method_args.process(sexp)
method_args.methods
end
|
.register(file) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/method_args.rb', line 26
def self.register(file)
file = expand_path(file)
unless FileRegistry.include?(file)
FileRegistry << file
parse(file).each { |cls, methods| ClassMethodRegistry[cls].add_methods!(methods) }
end
end
|