rbml 0.0.5.9 → 0.0.5.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +6 -5
- data/bin/rbml +1 -1
- data/languages/cli/cli.rb +10 -3
- data/languages/doc/base.rb +4 -0
- data/languages/doc/xhtml.rb +1 -1
- data/languages/doc/xml.rb +1 -1
- data/lib/cli.rb +2 -1
- data/lib/doc.rb +2 -2
- data/lib/extensions/primitives.rb +33 -0
- data/lib/procedural.rb +15 -0
- data/lib/processor.rb +1 -4
- data/lib/rbml.rb +3 -1
- metadata +8 -6
data/Manifest.txt
CHANGED
@@ -9,22 +9,23 @@ examples/doc/sublist/_sublist.rbml
|
|
9
9
|
examples/doc/synopsis.rbml
|
10
10
|
examples/doc/test.rbml
|
11
11
|
examples/shell/centos_apache_2_2_3.rbml
|
12
|
+
languages/cli/cli.rb
|
12
13
|
languages/doc/base.rb
|
13
14
|
languages/doc/xhtml.rb
|
14
15
|
languages/doc/xml.rb
|
15
16
|
languages/shell/shell.rb
|
16
|
-
languages/cli/cli.rb
|
17
|
-
lib/doc.rb
|
18
17
|
lib/base.rb
|
19
18
|
lib/cli.rb
|
20
|
-
lib/
|
19
|
+
lib/daemon.rb
|
20
|
+
lib/doc.rb
|
21
21
|
lib/extensions/kernel.rb
|
22
|
+
lib/extensions/primitives.rb
|
22
23
|
lib/extensions/string.rb
|
24
|
+
lib/procedural.rb
|
23
25
|
lib/processor.rb
|
24
26
|
lib/rbml.rb
|
25
|
-
lib/
|
27
|
+
lib/shell.rb
|
26
28
|
spec/doc_spec.rb
|
27
29
|
spec/object_spec.rb
|
28
30
|
spec/rbml_spec.rb
|
29
31
|
spec/spec_helper.rb
|
30
|
-
|
data/bin/rbml
CHANGED
data/languages/cli/cli.rb
CHANGED
@@ -2,16 +2,23 @@ module Rbml
|
|
2
2
|
module Language
|
3
3
|
module Cli
|
4
4
|
module Cli
|
5
|
-
DEFINITION = {"unknown_command" => lambda {puts "
|
5
|
+
DEFINITION = {"unknown_command" => lambda {puts "unknown command type 'help' for instructions"}}
|
6
6
|
|
7
7
|
def set(method, &proc)
|
8
8
|
DEFINITION.update({method.to_s => proc})
|
9
9
|
nil
|
10
10
|
end
|
11
11
|
|
12
|
-
def call(method)
|
12
|
+
def call(method, *args)
|
13
13
|
begin
|
14
|
-
DEFINITION.fetch(method)
|
14
|
+
mymethod = DEFINITION.fetch(method)
|
15
|
+
if args.length == 0 && mymethod.arity == -1
|
16
|
+
mymethod.call
|
17
|
+
elsif mymethod.arity.abs == args.length
|
18
|
+
mymethod.call(*args)
|
19
|
+
else
|
20
|
+
puts "bad syntax"
|
21
|
+
end
|
15
22
|
rescue
|
16
23
|
DEFINITION.fetch("unknown_command").call
|
17
24
|
end
|
data/languages/doc/base.rb
CHANGED
data/languages/doc/xhtml.rb
CHANGED
data/languages/doc/xml.rb
CHANGED
data/lib/cli.rb
CHANGED
@@ -10,7 +10,8 @@ module Rbml
|
|
10
10
|
printf options[:prompt]
|
11
11
|
d.instance_eval_each(block, &display)
|
12
12
|
obj = IO.new(0, "w+")
|
13
|
-
|
13
|
+
args = obj.gets.split
|
14
|
+
d.dsl.__send__("call", *args)
|
14
15
|
rescue Interrupt
|
15
16
|
puts "\nExiting #{options[:name]}..."
|
16
17
|
break
|
data/lib/doc.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Primitives
|
2
|
+
class BlankSlate #:nodoc:
|
3
|
+
alias :__instance_eval__ :instance_eval
|
4
|
+
alias :__extend__ :extend
|
5
|
+
alias :__respond_to? :respond_to?
|
6
|
+
alias :__send__ :send
|
7
|
+
alias :__instance_variable_get :instance_variable_get
|
8
|
+
alias :__instance_variable_set :instance_variable_set
|
9
|
+
|
10
|
+
instance_methods.each {|m| undef_method m unless m =~ /^__/ }
|
11
|
+
|
12
|
+
def initialize(mod = nil)
|
13
|
+
__extend__ mod if mod
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class BlockBreaker < BlankSlate #:nodoc:
|
18
|
+
def initialize(&block)
|
19
|
+
if block_given?
|
20
|
+
@handler = block
|
21
|
+
else
|
22
|
+
raise NoBlockGiven, "Must be a block to break!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_missing(name, *args, &block)
|
27
|
+
@handler.call(name, args, block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class NoBlockGiven < StandardError #:nodoc:
|
32
|
+
end
|
33
|
+
end
|
data/lib/procedural.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rbml
|
2
|
+
class Procedural < Base
|
3
|
+
def self.render(language, options, &block)
|
4
|
+
d = Procedural.new(language)
|
5
|
+
display = lambda do |result|
|
6
|
+
puts "#{result}\n" unless result.nil?
|
7
|
+
end
|
8
|
+
loop do
|
9
|
+
d.instance_eval_each(block, &display)
|
10
|
+
stdin = IO.new(0, "w+")
|
11
|
+
d.dsl.__send__("call", stdin.gets.chomp)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/processor.rb
CHANGED
@@ -22,10 +22,7 @@ module Rbml
|
|
22
22
|
def method_name; caller[0][/`([^']*)'/, 1]; end
|
23
23
|
|
24
24
|
def self.run(argv)
|
25
|
-
argv.
|
26
|
-
processor = new
|
27
|
-
processor.instance_eval File.readlines(file).join
|
28
|
-
end
|
25
|
+
new.instance_eval File.readlines(argv.first).join
|
29
26
|
end
|
30
27
|
end
|
31
28
|
end
|
data/lib/rbml.rb
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
|
2
2
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + "/../languages")
|
3
3
|
|
4
4
|
module Rbml
|
5
|
-
VERSION = '0.0.5.9'
|
5
|
+
VERSION = '0.0.5.9.2'
|
6
6
|
end
|
7
7
|
require 'extensions/kernel'
|
8
8
|
require 'extensions/primitives'
|
@@ -12,3 +12,5 @@ require 'base'
|
|
12
12
|
require 'doc'
|
13
13
|
require 'cli'
|
14
14
|
require 'shell'
|
15
|
+
require 'processor'
|
16
|
+
require 'procedural'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rbml
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.5.9
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.5.9.2
|
7
|
+
date: 2007-03-06 00:00:00 -05:00
|
8
8
|
summary: Rbml is a dsl framework for writing other languages in ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -40,20 +40,22 @@ files:
|
|
40
40
|
- examples/doc/synopsis.rbml
|
41
41
|
- examples/doc/test.rbml
|
42
42
|
- examples/shell/centos_apache_2_2_3.rbml
|
43
|
+
- languages/cli/cli.rb
|
43
44
|
- languages/doc/base.rb
|
44
45
|
- languages/doc/xhtml.rb
|
45
46
|
- languages/doc/xml.rb
|
46
47
|
- languages/shell/shell.rb
|
47
|
-
- languages/cli/cli.rb
|
48
|
-
- lib/doc.rb
|
49
48
|
- lib/base.rb
|
50
49
|
- lib/cli.rb
|
51
|
-
- lib/
|
50
|
+
- lib/daemon.rb
|
51
|
+
- lib/doc.rb
|
52
52
|
- lib/extensions/kernel.rb
|
53
|
+
- lib/extensions/primitives.rb
|
53
54
|
- lib/extensions/string.rb
|
55
|
+
- lib/procedural.rb
|
54
56
|
- lib/processor.rb
|
55
57
|
- lib/rbml.rb
|
56
|
-
- lib/
|
58
|
+
- lib/shell.rb
|
57
59
|
- spec/doc_spec.rb
|
58
60
|
- spec/object_spec.rb
|
59
61
|
- spec/rbml_spec.rb
|