command-set 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/Specifications +64 -17
- data/lib/command-set.rb +1 -1
- data/lib/command-set/arguments.rb +40 -36
- data/lib/command-set/command-set.rb +68 -31
- data/lib/command-set/command.rb +123 -53
- data/lib/command-set/dsl.rb +54 -45
- data/lib/command-set/formatter/base.rb +186 -0
- data/lib/command-set/formatter/strategy.rb +243 -0
- data/lib/command-set/formatter/xml.rb +56 -0
- data/lib/command-set/{interpreter.rb → interpreter/base.rb} +43 -36
- data/lib/command-set/{batch-interpreter.rb → interpreter/batch.rb} +0 -0
- data/lib/command-set/{quick-interpreter.rb → interpreter/quick.rb} +4 -4
- data/lib/command-set/{text-interpreter.rb → interpreter/text.rb} +29 -25
- data/lib/command-set/results.rb +4 -478
- data/lib/command-set/standard-commands.rb +2 -2
- data/lib/command-set/structural.rb +230 -0
- data/lib/command-set/subject.rb +153 -39
- metadata +13 -8
- data/lib/command-set/command-common.rb +0 -110
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: command-set
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.10.0
|
7
|
+
date: 2008-02-06 00:00:00 -08:00
|
8
8
|
summary: Framework for interactive programs focused around a DSL for commands
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -33,18 +33,23 @@ files:
|
|
33
33
|
- lib/command-set
|
34
34
|
- lib/command-set/command-set.rb
|
35
35
|
- lib/command-set/arguments.rb
|
36
|
-
- lib/command-set/command-common.rb
|
37
36
|
- lib/command-set/og.rb
|
38
|
-
- lib/command-set/
|
37
|
+
- lib/command-set/interpreter
|
38
|
+
- lib/command-set/interpreter/text.rb
|
39
|
+
- lib/command-set/interpreter/base.rb
|
40
|
+
- lib/command-set/interpreter/quick.rb
|
41
|
+
- lib/command-set/interpreter/batch.rb
|
39
42
|
- lib/command-set/subject.rb
|
40
43
|
- lib/command-set/result-list.rb
|
44
|
+
- lib/command-set/structural.rb
|
41
45
|
- lib/command-set/dsl.rb
|
46
|
+
- lib/command-set/formatter
|
47
|
+
- lib/command-set/formatter/strategy.rb
|
48
|
+
- lib/command-set/formatter/base.rb
|
49
|
+
- lib/command-set/formatter/xml.rb
|
42
50
|
- lib/command-set/command.rb
|
43
|
-
- lib/command-set/interpreter.rb
|
44
51
|
- lib/command-set/standard-commands.rb
|
45
52
|
- lib/command-set/results.rb
|
46
|
-
- lib/command-set/quick-interpreter.rb
|
47
|
-
- lib/command-set/batch-interpreter.rb
|
48
53
|
- doc/README
|
49
54
|
- doc/GUIDED_TOUR
|
50
55
|
- doc/Specifications
|
@@ -56,7 +61,7 @@ rdoc_options:
|
|
56
61
|
- --main
|
57
62
|
- Command
|
58
63
|
- --title
|
59
|
-
- command-set-0.
|
64
|
+
- command-set-0.10.0 RDoc
|
60
65
|
extra_rdoc_files:
|
61
66
|
- doc/README
|
62
67
|
- doc/GUIDED_TOUR
|
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'command-set/arguments'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
module Command
|
5
|
-
class SetVisitor < OpenStruct
|
6
|
-
def leave_from(terms, node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def arrive_at(terms, node)
|
10
|
-
end
|
11
|
-
|
12
|
-
def set_out_of_terms(node)
|
13
|
-
end
|
14
|
-
|
15
|
-
def command_out_of_terms(node)
|
16
|
-
end
|
17
|
-
|
18
|
-
def term_without_hop(terms, node)
|
19
|
-
end
|
20
|
-
|
21
|
-
def extra_terms(terms, node)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module Common
|
26
|
-
def path
|
27
|
-
if @parent.nil?
|
28
|
-
return []
|
29
|
-
else
|
30
|
-
return @parent.path + [@name]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def add_requirements(subject)
|
35
|
-
each_command do |command|
|
36
|
-
subject.required_fields(*(command.subject_requirements.uniq))
|
37
|
-
command.argument_list.each do |argument|
|
38
|
-
subject.required_fields(*(argument.subject_requirements.uniq))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
return subject
|
42
|
-
end
|
43
|
-
|
44
|
-
def find_command(path)
|
45
|
-
visitor = SetVisitor.new(:command => nil)
|
46
|
-
def visitor.set_out_of_terms(node)
|
47
|
-
self.command = node
|
48
|
-
end
|
49
|
-
|
50
|
-
def visitor.arrive_at(terms, node)
|
51
|
-
self.command = node
|
52
|
-
end
|
53
|
-
|
54
|
-
def visitor.term_without_hop(terms, node)
|
55
|
-
raise CommandException, "No such command #{terms.first}"
|
56
|
-
end
|
57
|
-
|
58
|
-
visit(path, visitor)
|
59
|
-
return visitor.command
|
60
|
-
end
|
61
|
-
|
62
|
-
def process_terms(terms, subject, arg_hash={})
|
63
|
-
visitor = SetVisitor.new(:command_class => nil, :subject => subject, :arg_hash => {})
|
64
|
-
def visitor.arrive_at(terms, node)
|
65
|
-
self.command_class = node.factory
|
66
|
-
subject = self.subject.get_image(node.subject_requirements)
|
67
|
-
return node.consume_terms(terms, subject, self.arg_hash)
|
68
|
-
end
|
69
|
-
visit(terms, visitor)
|
70
|
-
return visitor
|
71
|
-
end
|
72
|
-
|
73
|
-
def completion_list(terms, prefix, subject)
|
74
|
-
visitor = SetVisitor.new(:prefix => prefix,
|
75
|
-
:subject => subject,
|
76
|
-
:completion_list => [],
|
77
|
-
:arguments => [],
|
78
|
-
:original_terms => terms.dup)
|
79
|
-
def visitor.arrive_at(terms, node)
|
80
|
-
self.arguments = node.argument_list.dup
|
81
|
-
image = subject.get_image(node.subject_requirements)
|
82
|
-
until(terms.empty? or arguments.empty?) do
|
83
|
-
arguments.first.match_terms(image, terms, arguments)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def visitor.set_out_of_terms(node)
|
88
|
-
if arguments.empty? or not arguments.first.required?
|
89
|
-
self.completion_list = node.command_names.grep(%r{^#{prefix}.*})
|
90
|
-
end
|
91
|
-
self.command_out_of_terms(node)
|
92
|
-
end
|
93
|
-
|
94
|
-
def visitor.command_out_of_terms(node)
|
95
|
-
image = subject.get_image(node.subject_requirements)
|
96
|
-
arguments.each do |handler|
|
97
|
-
self.completion_list += handler.complete(original_terms, prefix, image)
|
98
|
-
break unless handler.omittable?
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def visitor.term_without_hop(terms, node)
|
103
|
-
return []
|
104
|
-
end
|
105
|
-
|
106
|
-
visit(terms, visitor)
|
107
|
-
return visitor.completion_list
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|