Top Level Namespace
Defined Under Namespace
Modules: Kernel, Main, Process
Classes: Object
Instance Method Summary
collapse
-
#argument(*a, &b) ⇒ Object
(also: #arg)
-
#can_has(ptype, *a, &b) ⇒ Object
-
#chunkname ⇒ Object
TODO - for some reason these hork the usage!.
-
#default_options! ⇒ Object
-
#environment(*a, &b) ⇒ Object
(also: #env)
-
#has(key, *keys) ⇒ Object
-
#keyword(*a, &b) ⇒ Object
(also: #kw)
-
#mixin(name, *names, &block) ⇒ Object
-
#mode(name, &block) ⇒ Object
-
#option(*a, &b) ⇒ Object
(also: #opt, #switch)
-
#parameter(*a, &b) ⇒ Object
Instance Method Details
#argument(*a, &b) ⇒ Object
Also known as:
arg
5
6
7
|
# File 'lib/main/dsl.rb', line 5
def argument(*a, &b)
(parameters << Parameter.create(:argument, self, *a, &b)).last
end
|
#can_has(ptype, *a, &b) ⇒ Object
37
38
39
40
41
|
# File 'lib/main/dsl.rb', line 37
def can_has(ptype, *a, &b)
key = a.map{|s| s.to_s}.sort_by{|s| -s.size }.first
can_has_hash.update key => [ptype, a, b]
key
end
|
#chunkname ⇒ Object
TODO - for some reason these hork the usage!
68
69
70
71
72
73
74
75
|
# File 'lib/main/dsl.rb', line 68
%w[ examples samples api ].each do |chunkname|
module_eval <<-code
def #{ chunkname } *a, &b
txt = b ? b.call : a.join("\\n")
usage['#{ chunkname }'] = txt
end
code
end
|
#default_options! ⇒ Object
26
27
28
|
# File 'lib/main/dsl.rb', line 26
def default_options!
option 'help', 'h' unless parameters.has_option?('help', 'h')
end
|
#environment(*a, &b) ⇒ Object
Also known as:
env
21
22
23
|
# File 'lib/main/dsl.rb', line 21
def environment(*a, &b)
(parameters << Parameter.create(:environment, self, *a, &b)).last
end
|
#has(key, *keys) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/main/dsl.rb', line 43
def has(key, *keys)
keys = [key, *keys].flatten.compact.map{|k| k.to_s}
keys.map do |key|
ptype, a, b = can_has_hash[key]
abort "yo - can *not* has #{ key.inspect }!?" unless(ptype and a and b)
send ptype, *a, &b
key
end
end
|
#keyword(*a, &b) ⇒ Object
Also known as:
kw
16
17
18
|
# File 'lib/main/dsl.rb', line 16
def keyword(*a, &b)
(parameters << Parameter.create(:keyword, self, *a, &b)).last
end
|
#mixin(name, *names, &block) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/main/dsl.rb', line 53
def mixin(name, *names, &block)
names = [name, *names].flatten.compact.map{|name| name.to_s}
if block
names.each do |name|
mixin_table[name] = block
end
else
names.each do |name|
module_eval(&mixin_table[name])
end
end
end
|
#mode(name, &block) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/main/dsl.rb', line 30
def mode(name, &block)
name = name.to_s
modes[name] = block
block.fattr(:name => name)
block
end
|
#option(*a, &b) ⇒ Object
Also known as:
opt, switch
10
11
12
|
# File 'lib/main/dsl.rb', line 10
def option(*a, &b)
(parameters << Parameter.create(:option, self, *a, &b)).last
end
|
#parameter(*a, &b) ⇒ Object
1
2
3
|
# File 'lib/main/dsl.rb', line 1
def parameter(*a, &b)
(parameters << Parameter.create(:parameter, self, *a, &b)).last
end
|