rbml 0.0.5 → 0.0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -4
- data/Manifest.txt +9 -6
- data/README.txt +8 -3
- data/bin/rbml +4 -3
- data/examples/cli/happycli.rbml +7 -3
- data/examples/doc/test.rbml +2 -2
- data/examples/shell/centos_apache_2_2_3.rbml +17 -14
- data/languages/doc/base.rb +9 -2
- data/languages/doc/xhtml.rb +2 -1
- data/languages/doc/xml.rb +1 -1
- data/languages/shell/shell.rb +30 -0
- data/lib/base.rb +4 -3
- data/lib/cli.rb +1 -1
- data/lib/daemon.rb +14 -0
- data/lib/extensions/kernel.rb +1 -53
- data/lib/processor.rb +25 -4
- data/lib/rbml.rb +5 -2
- data/lib/shell.rb +12 -0
- metadata +13 -10
data/History.txt
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
== 0.0.5 / 2007-01
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
1
|
+
== 0.0.5.1 / 2007-02-01
|
2
|
+
|
3
|
+
* cleaned up the gem a bit
|
4
|
+
* able to run exammples now
|
5
|
+
|
6
|
+
== 0.0.5 / 2007-01-29
|
7
|
+
|
8
|
+
* successfully processing different types of files
|
9
|
+
* command line
|
10
|
+
* text processing
|
5
11
|
|
6
12
|
== 0.0.2 / 2007-01-28
|
7
13
|
|
data/Manifest.txt
CHANGED
@@ -3,25 +3,28 @@ Manifest.txt
|
|
3
3
|
README.txt
|
4
4
|
Rakefile
|
5
5
|
bin/rbml
|
6
|
-
languages/cli/cli.rb
|
7
|
-
languages/doc/base.rb
|
8
|
-
languages/doc/xhtml.rb
|
9
|
-
languages/doc/xml.rb
|
10
6
|
examples/cli/happycli.rbml
|
11
7
|
examples/doc/_partial.rbml
|
12
8
|
examples/doc/sublist/_sublist.rbml
|
13
9
|
examples/doc/synopsis.rbml
|
14
10
|
examples/doc/test.rbml
|
15
11
|
examples/shell/centos_apache_2_2_3.rbml
|
12
|
+
languages/doc/base.rb
|
13
|
+
languages/doc/xhtml.rb
|
14
|
+
languages/doc/xml.rb
|
15
|
+
languages/shell/shell.rb
|
16
|
+
languages/cli/cli.rb
|
17
|
+
lib/doc.rb
|
16
18
|
lib/base.rb
|
17
19
|
lib/cli.rb
|
18
|
-
lib/
|
20
|
+
lib/shell.rb
|
19
21
|
lib/extensions/kernel.rb
|
20
22
|
lib/extensions/string.rb
|
21
23
|
lib/processor.rb
|
22
24
|
lib/rbml.rb
|
23
|
-
lib/
|
25
|
+
lib/daemon.rb
|
24
26
|
spec/doc_spec.rb
|
25
27
|
spec/object_spec.rb
|
26
28
|
spec/rbml_spec.rb
|
27
29
|
spec/spec_helper.rb
|
30
|
+
|
data/README.txt
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
-
|
1
|
+
rbml
|
2
2
|
by Jake Howerton, Evan Short
|
3
3
|
http://rbml.rubyforge.org
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
|
7
|
+
rbml is a block processing engine that serves as a framework for writing
|
8
|
+
nested DSLs. Currently rbml has been implemented in document processing
|
9
|
+
(+xml+, +xhtml+) and command line interfacing. daemons and some level of
|
10
|
+
scripting capability are anticipated in 0.0.7
|
8
11
|
|
9
12
|
== FEATURES/PROBLEMS:
|
10
13
|
|
11
14
|
* can load rbml partials using +include+ method
|
12
|
-
*
|
15
|
+
* sample support for command line interfaces
|
16
|
+
* document processing: xml, xhtml
|
17
|
+
* XML support is totally untested (we don't need it right now...)
|
13
18
|
|
14
19
|
== SYNOPSIS:
|
15
20
|
|
data/bin/rbml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
3
|
-
$template_dir = File.dirname(ARGV[0])
|
4
|
-
|
5
|
-
|
3
|
+
$template_dir = File.dirname(ARGV[0]) if ARGV[0]
|
4
|
+
|
5
|
+
require 'lib/rbml'
|
6
|
+
::Rbml::Processor.run(ARGV)
|
data/examples/cli/happycli.rbml
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
cli :name=>"happycli", :prompt=>"happy> " do
|
2
2
|
set :unknown_command do
|
3
|
-
cliprint "
|
3
|
+
cliprint "overwritten unknown command"
|
4
4
|
end
|
5
5
|
|
6
6
|
set :help do
|
7
|
-
cliprint "helpdocs"
|
7
|
+
cliprint "put helpdocs here"
|
8
8
|
end
|
9
9
|
|
10
|
+
set :corey_is_awesome do
|
11
|
+
cliprint "corey is awesome"
|
12
|
+
end
|
13
|
+
|
10
14
|
set :quit do
|
11
15
|
exit
|
12
16
|
end
|
13
|
-
end
|
17
|
+
end
|
data/examples/doc/test.rbml
CHANGED
@@ -6,7 +6,7 @@ xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
body do
|
9
|
-
|
9
|
+
t "*Header*"
|
10
10
|
div "this is our first html doc!"
|
11
11
|
p "its really awesome"
|
12
12
|
myvar = "withconcat"
|
@@ -20,4 +20,4 @@ xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do
|
|
20
20
|
end
|
21
21
|
include "partial"
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -1,23 +1,26 @@
|
|
1
|
-
shell "
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
shell "*Install Apache*" do
|
2
|
+
cd '~/src' do
|
3
|
+
download "http://apache.roweboat.net/httpd/httpd-2.2.3.tar.gz"
|
4
|
+
unpack 'httpd-2.2.3.tar.gz', :verbose=>true do
|
5
|
+
configure :prefix => '/usr/local/apache2' ,
|
6
|
+
"enable-mods-shared" => "all",
|
7
|
+
"with-suexec-caller" => "apache",
|
8
|
+
"with-suexec-docroot"=>"/var/www",
|
9
|
+
"with-suexec-userdir"=>"httpdocs",
|
10
|
+
"with-suexec-bin"=>"/usr/local/apache2/bin/suexec",
|
11
|
+
:sbindir =>"/usr/local/apache2/sbin",
|
12
|
+
:flags => ["enable-deflate", "enable-proxy", "enable-proxy-balancer",
|
13
|
+
"enable-fastcgi", "with-gettext", "enable-xml", "with-libxml", "enable-suexec"]
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
make
|
16
|
+
make :install
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
__END__
|
20
22
|
*Install apache*
|
23
|
+
cd ~/src
|
21
24
|
curl -O http://apache.roweboat.net/httpd/httpd-2.2.3.tar.gz
|
22
25
|
tar xvzf httpd-2.2.3.tar.gz
|
23
26
|
cd httpd-2.2.3
|
data/languages/doc/base.rb
CHANGED
@@ -5,7 +5,14 @@ module Rbml
|
|
5
5
|
def find_partial(str)
|
6
6
|
arr = str.split("/")
|
7
7
|
arr.last[0,0] = "_"
|
8
|
-
|
8
|
+
find_local_file(arr.join("/") + '.rbml')
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_local_file(filename)
|
12
|
+
find_file($template_dir +'/' + filename)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_file(filename)
|
9
16
|
__instance_eval__ File.read(filename)
|
10
17
|
end
|
11
18
|
|
@@ -15,4 +22,4 @@ module Rbml
|
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
18
|
-
end
|
25
|
+
end
|
data/languages/doc/xhtml.rb
CHANGED
data/languages/doc/xml.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Rbml
|
2
|
+
module Language
|
3
|
+
module Shell
|
4
|
+
module Shell
|
5
|
+
|
6
|
+
def cd(dir, &block)
|
7
|
+
["cd #{dir}", block]
|
8
|
+
end
|
9
|
+
|
10
|
+
def download(url, options={})
|
11
|
+
"curl -O #{url}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def unpack(archive, options={}, &block)
|
15
|
+
["tar x#{"v" if options[:verbose]}zf #{archive}", "cd #{archive.sub(".tar.gz", "")}", block]
|
16
|
+
end
|
17
|
+
|
18
|
+
def configure(options={})
|
19
|
+
flags = options.delete(:flags).map { |f| "--#{f}" }.join(" ")
|
20
|
+
coptions = options.map { |k,v| "--#{k}=#{v}" }.join(" ")
|
21
|
+
"./configure #{flags} #{coptions}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def make(directive=nil)
|
25
|
+
"make#{" " + directive.to_s if directive}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Rbml
|
2
2
|
class Base
|
3
|
+
include Primitives
|
3
4
|
attr_accessor :dsl
|
4
5
|
|
5
6
|
def initialize(language=nil)
|
@@ -7,10 +8,10 @@ module Rbml
|
|
7
8
|
end
|
8
9
|
|
9
10
|
def instance_eval_each(code, &blk)
|
10
|
-
$
|
11
|
+
$breaker = BlockBreaker.new do |name, args, block|
|
11
12
|
yield @dsl.__send__(name, *args, &block)
|
12
13
|
end
|
13
|
-
$
|
14
|
+
$breaker.__instance_eval__ &code
|
14
15
|
end
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
data/lib/cli.rb
CHANGED
data/lib/daemon.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rbml
|
2
|
+
class Daemon < Base
|
3
|
+
def self.render(language, options, &block)
|
4
|
+
d = Daemon.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
|
data/lib/extensions/kernel.rb
CHANGED
@@ -1,55 +1,3 @@
|
|
1
|
-
module Kernel
|
2
|
-
|
3
|
-
ROUTES = {:xhtml => "Doc",
|
4
|
-
:cli => "Cli",
|
5
|
-
:shell => "Shell"}
|
6
|
-
|
7
|
-
def route_for(name)
|
8
|
-
ROUTES.fetch(name)
|
9
|
-
end
|
10
|
-
|
11
|
-
def spawn(options, &block)
|
12
|
-
require "languages/#{route_for(method_name.to_sym).downcase}/#{method_name}"
|
13
|
-
language = "Language::#{route_for(method_name.to_sym)}::#{method_name.camelize}".to_m
|
14
|
-
Rbml.const_get(route_for(method_name.to_sym)).render(language, options, &block)
|
15
|
-
end
|
16
|
-
|
17
|
-
ROUTES.each_key do |k|
|
18
|
-
alias_method k, :spawn
|
19
|
-
end
|
20
|
-
|
21
|
-
def method_name; caller[0][/`([^']*)'/, 1]; end
|
22
|
-
|
23
|
-
class BlankSlate #:nodoc:
|
24
|
-
alias :__instance_eval__ :instance_eval
|
25
|
-
alias :__extend__ :extend
|
26
|
-
alias :__respond_to? :respond_to?
|
27
|
-
alias :__send__ :send
|
28
|
-
alias :__instance_variable_get :instance_variable_get
|
29
|
-
alias :__instance_variable_set :instance_variable_set
|
30
|
-
|
31
|
-
instance_methods.each {|m| undef_method m unless m =~ /^__/ }
|
32
|
-
|
33
|
-
def initialize(mod = nil)
|
34
|
-
__extend__ mod if mod
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class BlockBreaker < BlankSlate #:nodoc:
|
39
|
-
def initialize(&block)
|
40
|
-
if block_given?
|
41
|
-
@handler = block
|
42
|
-
else
|
43
|
-
raise NoBlockGiven, "Must be a block to whine to"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def method_missing(name, *args, &block)
|
48
|
-
@handler.call(name, args, block)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class NoBlockGiven < StandardError #:nodoc:
|
53
|
-
end
|
1
|
+
module Kernel
|
54
2
|
end
|
55
3
|
|
data/lib/processor.rb
CHANGED
@@ -1,10 +1,31 @@
|
|
1
1
|
module Rbml
|
2
2
|
class Processor
|
3
|
+
|
4
|
+
ROUTES = {:xhtml => "Doc",
|
5
|
+
:cli => "Cli",
|
6
|
+
:shell => "Shell"}
|
7
|
+
|
8
|
+
def route_for(name)
|
9
|
+
ROUTES.fetch(name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def spawn(options, &block)
|
13
|
+
require "#{route_for(method_name.to_sym).downcase}/#{method_name}"
|
14
|
+
language = "Language::#{route_for(method_name.to_sym)}::#{method_name.camelize}".to_m
|
15
|
+
Rbml.const_get(route_for(method_name.to_sym)).render(language, options, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
ROUTES.each_key do |k|
|
19
|
+
alias_method k, :spawn
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_name; caller[0][/`([^']*)'/, 1]; end
|
23
|
+
|
3
24
|
def self.run(argv)
|
4
|
-
|
5
|
-
|
6
|
-
|
25
|
+
argv.each do |file|
|
26
|
+
processor = new
|
27
|
+
processor.instance_eval File.readlines(file).join
|
7
28
|
end
|
8
29
|
end
|
9
30
|
end
|
10
|
-
end
|
31
|
+
end
|
data/lib/rbml.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + "/../languages")
|
2
3
|
|
3
4
|
module Rbml
|
4
|
-
VERSION = '0.0.5'
|
5
|
+
VERSION = '0.0.5.9'
|
5
6
|
end
|
6
7
|
require 'extensions/kernel'
|
8
|
+
require 'extensions/primitives'
|
7
9
|
require 'extensions/string'
|
10
|
+
require 'processor'
|
8
11
|
require 'base'
|
9
12
|
require 'doc'
|
10
13
|
require 'cli'
|
11
|
-
require '
|
14
|
+
require 'shell'
|
data/lib/shell.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
module Rbml
|
2
2
|
class Shell < Base
|
3
|
+
def self.render(language, options, &block)
|
4
|
+
d = Shell.new(language)
|
5
|
+
puts options
|
6
|
+
display = lambda do |result|
|
7
|
+
if result.kind_of? Array
|
8
|
+
result.each {|r| r.kind_of?(Proc) ? d.instance_eval_each(r, &display) : puts(r) }
|
9
|
+
else
|
10
|
+
puts result unless result.nil?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
d.instance_eval_each(block, &display)
|
14
|
+
end
|
3
15
|
end
|
4
16
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
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
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.5.9
|
7
|
+
date: 2007-02-27 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
|
11
11
|
email: ryand-ruby@zenspider.com
|
12
12
|
homepage: " by Jake Howerton, Evan Short"
|
13
13
|
rubyforge_project: rbml
|
14
|
-
description: "== FEATURES/PROBLEMS: * can load rbml partials using +include+ method * XML support is totally untested
|
14
|
+
description: "== FEATURES/PROBLEMS: * can load rbml partials using +include+ method * sample support for command line interfaces * document processing: xml, xhtml * XML support is totally untested (we don't need it right now...) == SYNOPSIS: <tt>rbml path/to/file.rbml</tt>"
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Ryan Davis
|
30
31
|
files:
|
@@ -33,24 +34,26 @@ files:
|
|
33
34
|
- README.txt
|
34
35
|
- Rakefile
|
35
36
|
- bin/rbml
|
36
|
-
- languages/cli/cli.rb
|
37
|
-
- languages/doc/base.rb
|
38
|
-
- languages/doc/xhtml.rb
|
39
|
-
- languages/doc/xml.rb
|
40
37
|
- examples/cli/happycli.rbml
|
41
38
|
- examples/doc/_partial.rbml
|
42
39
|
- examples/doc/sublist/_sublist.rbml
|
43
40
|
- examples/doc/synopsis.rbml
|
44
41
|
- examples/doc/test.rbml
|
45
42
|
- examples/shell/centos_apache_2_2_3.rbml
|
43
|
+
- languages/doc/base.rb
|
44
|
+
- languages/doc/xhtml.rb
|
45
|
+
- languages/doc/xml.rb
|
46
|
+
- languages/shell/shell.rb
|
47
|
+
- languages/cli/cli.rb
|
48
|
+
- lib/doc.rb
|
46
49
|
- lib/base.rb
|
47
50
|
- lib/cli.rb
|
48
|
-
- lib/
|
51
|
+
- lib/shell.rb
|
49
52
|
- lib/extensions/kernel.rb
|
50
53
|
- lib/extensions/string.rb
|
51
54
|
- lib/processor.rb
|
52
55
|
- lib/rbml.rb
|
53
|
-
- lib/
|
56
|
+
- lib/daemon.rb
|
54
57
|
- spec/doc_spec.rb
|
55
58
|
- spec/object_spec.rb
|
56
59
|
- spec/rbml_spec.rb
|