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.
@@ -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/shell.rb
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/daemon.rb
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
@@ -2,5 +2,5 @@
2
2
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
3
3
  $template_dir = File.dirname(ARGV[0]) if ARGV[0]
4
4
 
5
- require 'lib/rbml'
5
+ require File.dirname(__FILE__)+'/../lib/rbml'
6
6
  ::Rbml::Processor.run(ARGV)
@@ -2,16 +2,23 @@ module Rbml
2
2
  module Language
3
3
  module Cli
4
4
  module Cli
5
- DEFINITION = {"unknown_command" => lambda {puts "unkown command type 'help' for instructions"}}
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).call
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
@@ -16,6 +16,10 @@ module Rbml
16
16
  __instance_eval__ File.read(filename)
17
17
  end
18
18
 
19
+ def print(doc)
20
+ puts doc
21
+ end
22
+
19
23
  def format(doc)
20
24
  "Please define a method for format in your library"
21
25
  end
@@ -1,6 +1,6 @@
1
- require 'languages/doc/xml'
2
1
  require 'rubygems'
3
2
  require 'redcloth'
3
+ require 'doc/xml'
4
4
  require 'rexml/document'
5
5
 
6
6
  module Rbml
@@ -1,4 +1,4 @@
1
- require 'languages/doc/base'
1
+ require 'doc/base'
2
2
 
3
3
  module Rbml
4
4
  module Language
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
- d.dsl.__send__("call", obj.gets.chomp)
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
@@ -31,7 +31,7 @@ module Rbml
31
31
  end
32
32
 
33
33
  def print
34
- puts formatted_doc.blank? ? assemble_doc : formatted_doc
34
+ formatted_doc.blank? ? assemble_doc : formatted_doc
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -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
@@ -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
@@ -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.each do |file|
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
@@ -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-02-27 00:00:00 -05:00
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/shell.rb
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/daemon.rb
58
+ - lib/shell.rb
57
59
  - spec/doc_spec.rb
58
60
  - spec/object_spec.rb
59
61
  - spec/rbml_spec.rb