rbml 0.0.2 → 0.0.5
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/History.txt +10 -0
- data/Manifest.txt +13 -7
- data/README.txt +33 -27
- data/Rakefile +9 -0
- data/examples/cli/happycli.rbml +13 -0
- data/{spec/fixtures → examples/doc}/_partial.rbml +0 -0
- data/{spec/fixtures → examples/doc}/sublist/_sublist.rbml +0 -0
- data/{spec/fixtures → examples/doc}/synopsis.rbml +0 -0
- data/{spec/fixtures → examples/doc}/test.rbml +6 -2
- data/examples/shell/centos_apache_2_2_3.rbml +30 -0
- data/languages/cli/cli.rb +26 -0
- data/languages/doc/base.rb +18 -0
- data/languages/doc/xhtml.rb +63 -0
- data/languages/doc/xml.rb +39 -0
- data/lib/base.rb +16 -0
- data/lib/cli.rb +21 -0
- data/lib/doc.rb +4 -18
- data/lib/extensions/kernel.rb +25 -10
- data/lib/extensions/string.rb +6 -2
- data/lib/rbml.rb +5 -2
- data/lib/shell.rb +4 -0
- metadata +18 -12
- data/languages/base.rb +0 -10
- data/languages/xhtml.rb +0 -47
- data/languages/xml.rb +0 -35
    
        data/History.txt
    CHANGED
    
    | @@ -1,3 +1,13 @@ | |
| 1 | 
            +
            == 0.0.5 / 2007-01-30
         | 
| 2 | 
            +
            * base classes are more generic
         | 
| 3 | 
            +
            * routing for different types of dsls
         | 
| 4 | 
            +
            * cli framework implemented
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            == 0.0.2 / 2007-01-28
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            * load & require fixes
         | 
| 9 | 
            +
            * added charset method to Xhtml
         | 
| 10 | 
            +
             | 
| 1 11 | 
             
            == 0.0.1 / 2007-01-28
         | 
| 2 12 |  | 
| 3 13 | 
             
            * Rbml is born
         | 
    
        data/Manifest.txt
    CHANGED
    
    | @@ -3,19 +3,25 @@ Manifest.txt | |
| 3 3 | 
             
            README.txt
         | 
| 4 4 | 
             
            Rakefile
         | 
| 5 5 | 
             
            bin/rbml
         | 
| 6 | 
            -
            languages/ | 
| 7 | 
            -
            languages/ | 
| 8 | 
            -
            languages/ | 
| 6 | 
            +
            languages/cli/cli.rb
         | 
| 7 | 
            +
            languages/doc/base.rb
         | 
| 8 | 
            +
            languages/doc/xhtml.rb
         | 
| 9 | 
            +
            languages/doc/xml.rb
         | 
| 10 | 
            +
            examples/cli/happycli.rbml
         | 
| 11 | 
            +
            examples/doc/_partial.rbml
         | 
| 12 | 
            +
            examples/doc/sublist/_sublist.rbml
         | 
| 13 | 
            +
            examples/doc/synopsis.rbml
         | 
| 14 | 
            +
            examples/doc/test.rbml
         | 
| 15 | 
            +
            examples/shell/centos_apache_2_2_3.rbml
         | 
| 16 | 
            +
            lib/base.rb
         | 
| 17 | 
            +
            lib/cli.rb
         | 
| 9 18 | 
             
            lib/doc.rb
         | 
| 10 19 | 
             
            lib/extensions/kernel.rb
         | 
| 11 20 | 
             
            lib/extensions/string.rb
         | 
| 12 21 | 
             
            lib/processor.rb
         | 
| 13 22 | 
             
            lib/rbml.rb
         | 
| 23 | 
            +
            lib/shell.rb
         | 
| 14 24 | 
             
            spec/doc_spec.rb
         | 
| 15 | 
            -
            spec/fixtures/_partial.rbml
         | 
| 16 | 
            -
            spec/fixtures/sublist/_sublist.rbml
         | 
| 17 | 
            -
            spec/fixtures/synopsis.rbml
         | 
| 18 | 
            -
            spec/fixtures/test.rbml
         | 
| 19 25 | 
             
            spec/object_spec.rb
         | 
| 20 26 | 
             
            spec/rbml_spec.rb
         | 
| 21 27 | 
             
            spec/spec_helper.rb
         | 
    
        data/README.txt
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            Rbml
         | 
| 2 2 | 
             
                by Jake Howerton, Evan Short
         | 
| 3 3 | 
             
                http://rbml.rubyforge.org
         | 
| 4 4 |  | 
| @@ -7,19 +7,25 @@ rbmlhoe | |
| 7 7 | 
             
            Rbml is a dsl framework for outputting other languages (currently supports Xhtml, XML)
         | 
| 8 8 |  | 
| 9 9 | 
             
            == FEATURES/PROBLEMS:
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 | 
            +
            * can load rbml partials using +include+ method
         | 
| 11 12 | 
             
            * XML support is totally untested since we don't need it
         | 
| 12 13 |  | 
| 13 14 | 
             
            == SYNOPSIS:
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            <tt>rbml path/to/file.rbml</tt>
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            file.rbml:
         | 
| 19 | 
            +
             | 
| 14 20 | 
             
            	xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do
         | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 21 | 
            +
            	  head do
         | 
| 22 | 
            +
            	    title "Sample Site"
         | 
| 23 | 
            +
            	    stylesheets :base, :links
         | 
| 24 | 
            +
            	    #COMMENTS DONT GET EVAL'd
         | 
| 25 | 
            +
            	  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            	  body do
         | 
| 28 | 
            +
            	    textilize "*Header*"
         | 
| 23 29 | 
             
            	    div "this is our first html doc!"
         | 
| 24 30 | 
             
            	    p "its really awesome"
         | 
| 25 31 | 
             
            	    myvar = "withconcat"
         | 
| @@ -27,28 +33,28 @@ Rbml is a dsl framework for outputting other languages (currently supports Xhtml | |
| 27 33 | 
             
            	      inline "dot operator #{myvar}"
         | 
| 28 34 | 
             
            	      span "nested span"
         | 
| 29 35 | 
             
            	    end
         | 
| 30 | 
            -
             | 
| 36 | 
            +
            	  end
         | 
| 31 37 | 
             
            	end
         | 
| 32 38 |  | 
| 33 39 | 
             
            Outputs
         | 
| 34 40 |  | 
| 35 41 | 
             
            	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
         | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 42 | 
            +
            	<html>
         | 
| 43 | 
            +
            	   <head>
         | 
| 44 | 
            +
            	     <title>Sample Site</title>
         | 
| 45 | 
            +
            	     <link href='/stylesheets/base.css' rel='stylesheet' type='text/css'/>
         | 
| 46 | 
            +
            	     <link href='/stylesheets/links.css' rel='stylesheet' type='text/css'/>
         | 
| 47 | 
            +
            	   </head>
         | 
| 48 | 
            +
            	   <body>
         | 
| 49 | 
            +
            	     <p>
         | 
| 50 | 
            +
            	       <strong>Header</strong>
         | 
| 51 | 
            +
            	     </p>
         | 
| 52 | 
            +
            	     <div>this is our first html doc!</div>
         | 
| 53 | 
            +
            	     <p>its really awesome</p>
         | 
| 54 | 
            +
            	     <p>dot operator withconcat<span>nested span</span>
         | 
| 55 | 
            +
            	     </p>
         | 
| 56 | 
            +
            	   </body>
         | 
| 57 | 
            +
            	</html>
         | 
| 52 58 |  | 
| 53 59 | 
             
            == REQUIREMENTS:
         | 
| 54 60 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -4,12 +4,21 @@ require 'rubygems' | |
| 4 4 | 
             
            require 'hoe'
         | 
| 5 5 | 
             
            require './lib/rbml.rb'
         | 
| 6 6 |  | 
| 7 | 
            +
            RDOC_OPTS = ['--quiet', '--title', "Rbml documentation",
         | 
| 8 | 
            +
                "--opname", "index.html",
         | 
| 9 | 
            +
                "--line-numbers", 
         | 
| 10 | 
            +
                "--main", "README",
         | 
| 11 | 
            +
                "--inline-source"]
         | 
| 12 | 
            +
                
         | 
| 7 13 | 
             
            Hoe.new('rbml', Rbml::VERSION) do |p|
         | 
| 8 14 | 
             
              p.rubyforge_name = 'rbml'
         | 
| 9 15 | 
             
              p.summary = 'Rbml is a dsl framework for writing other languages in ruby'
         | 
| 10 16 | 
             
              p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
         | 
| 11 17 | 
             
              p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
         | 
| 12 18 | 
             
              p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
         | 
| 19 | 
            +
              p.rdoc_pattern =  /^(lib|bin|languages)|txt$/
         | 
| 20 | 
            +
              p.spec_extras = {:rdoc_options => '--inline-source'}
         | 
| 13 21 | 
             
            end
         | 
| 14 22 |  | 
| 23 | 
            +
             | 
| 15 24 | 
             
            # vim: syntax=Ruby
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -2,7 +2,7 @@ xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do | |
| 2 2 | 
             
            	head do
         | 
| 3 3 | 
             
            	  title "Bridgewater Golf Club"
         | 
| 4 4 | 
             
            	  stylesheets :base, :links, :membership, :contact
         | 
| 5 | 
            -
             | 
| 5 | 
            +
            	  charset 'utf-8'
         | 
| 6 6 | 
             
            	end
         | 
| 7 7 |  | 
| 8 8 | 
             
            	body do
         | 
| @@ -11,7 +11,11 @@ xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do | |
| 11 11 | 
             
                p "its really awesome"
         | 
| 12 12 | 
             
                myvar = "withconcat"
         | 
| 13 13 | 
             
                p do
         | 
| 14 | 
            -
                   | 
| 14 | 
            +
                  if myvar != 'withconcat'
         | 
| 15 | 
            +
                    inline "dot operator #{myvar}"
         | 
| 16 | 
            +
                  else
         | 
| 17 | 
            +
                    inline 'this is in an if statement'
         | 
| 18 | 
            +
                  end 
         | 
| 15 19 | 
             
                  span "nested span"
         | 
| 16 20 | 
             
                end
         | 
| 17 21 | 
             
                include "partial"
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            shell "building apache" do
         | 
| 2 | 
            +
              download "http://apache.roweboat.net/httpd/httpd-2.2.3.tar.gz", :to => '~/src'
         | 
| 3 | 
            +
              unpack 'httpd-2.2.3.tar.gz', :verbose=>true, :from => '~/src' do
         | 
| 4 | 
            +
                configure :prefix => '/usr/local/apache2' , 
         | 
| 5 | 
            +
                          "enable-mods-shared" => "all", 
         | 
| 6 | 
            +
                          "with-suexec-caller" => "apache",
         | 
| 7 | 
            +
                          "with-suexec-docroot"=>"/var/www", 
         | 
| 8 | 
            +
                          "with-suexec-userdir"=>"httpdocs",
         | 
| 9 | 
            +
                          "with-suexec-bin"=>"/usr/local/apache2/bin/suexec",
         | 
| 10 | 
            +
                          :sbindir =>"/usr/local/apache2/sbin", 
         | 
| 11 | 
            +
                          :options => ["enable-deflate", "enable-proxy", "enable-proxy-balancer", 
         | 
| 12 | 
            +
                                       "enable-fastcgi", "with-gettext", "enable-xml", "with-libxml", "enable-suexec"]
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                make
         | 
| 15 | 
            +
                make :install
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            __END__
         | 
| 20 | 
            +
            *Install apache*
         | 
| 21 | 
            +
            curl -O http://apache.roweboat.net/httpd/httpd-2.2.3.tar.gz
         | 
| 22 | 
            +
            tar xvzf httpd-2.2.3.tar.gz
         | 
| 23 | 
            +
            cd httpd-2.2.3
         | 
| 24 | 
            +
            ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-proxy \
         | 
| 25 | 
            +
            --enable-proxy-balancer --enable-fastcgi --with-gettext --enable-xml --with-libxml --enable-suexec \
         | 
| 26 | 
            +
            --with-suexec-caller=apache --with-suexec-docroot=/var/www --with-suexec-userdir=httpdocs \
         | 
| 27 | 
            +
            --sbindir=/usr/local/apache2/sbin --with-suexec-bin=/usr/local/apache2/bin/suexec
         | 
| 28 | 
            +
            make
         | 
| 29 | 
            +
            make install
         | 
| 30 | 
            +
            cd ..
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            module Rbml
         | 
| 2 | 
            +
              module Language
         | 
| 3 | 
            +
                module Cli
         | 
| 4 | 
            +
                  module Cli
         | 
| 5 | 
            +
                    DEFINITION = {"unknown_command" => lambda {puts "unkown command type 'help' for instructions"}}
         | 
| 6 | 
            +
                    
         | 
| 7 | 
            +
                    def set(method, &proc)
         | 
| 8 | 
            +
                      DEFINITION.update({method.to_s => proc})
         | 
| 9 | 
            +
                      nil
         | 
| 10 | 
            +
                    end
         | 
| 11 | 
            +
                    
         | 
| 12 | 
            +
                    def call(method)
         | 
| 13 | 
            +
                      begin
         | 
| 14 | 
            +
                        DEFINITION.fetch(method).call
         | 
| 15 | 
            +
                      rescue
         | 
| 16 | 
            +
                        DEFINITION.fetch("unknown_command").call
         | 
| 17 | 
            +
                      end
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
                    
         | 
| 20 | 
            +
                    def cliprint(string)
         | 
| 21 | 
            +
                      string
         | 
| 22 | 
            +
                    end        
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            module Rbml
         | 
| 2 | 
            +
              module Language
         | 
| 3 | 
            +
                module Doc
         | 
| 4 | 
            +
                  module Base
         | 
| 5 | 
            +
                    def find_partial(str)
         | 
| 6 | 
            +
                      arr = str.split("/")
         | 
| 7 | 
            +
                      arr.last[0,0] = "_"
         | 
| 8 | 
            +
                      filename = ($template_dir + '/' + arr.join("/") + '.rbml')
         | 
| 9 | 
            +
                      __instance_eval__ File.read(filename)
         | 
| 10 | 
            +
                    end
         | 
| 11 | 
            +
                    
         | 
| 12 | 
            +
                    def format(doc)
         | 
| 13 | 
            +
                      "Please define a method for format in your library"
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            require 'languages/doc/xml'
         | 
| 2 | 
            +
            require 'rubygems'
         | 
| 3 | 
            +
            require 'redcloth'
         | 
| 4 | 
            +
            require 'rexml/document'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Rbml
         | 
| 7 | 
            +
              module Language
         | 
| 8 | 
            +
                module Doc
         | 
| 9 | 
            +
                  module Xhtml
         | 
| 10 | 
            +
                    include Xml
         | 
| 11 | 
            +
                    ::Kernel.send(:undef_method, :p)
         | 
| 12 | 
            +
                      
         | 
| 13 | 
            +
                    def tags; %w(body title head p div ul li html a br span)end
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                    def stylesheets *sheets
         | 
| 16 | 
            +
                      all_sheets = ''
         | 
| 17 | 
            +
                      sheets.each {|sheet| all_sheets << stylesheet(sheet)}
         | 
| 18 | 
            +
                      all_sheets
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  
         | 
| 21 | 
            +
                    def stylesheet what
         | 
| 22 | 
            +
                      "<link rel='stylesheet' href='/stylesheets/#{what}.css' type='text/css' />"
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                    def doctype(options)
         | 
| 26 | 
            +
                      strictness = options[:strict] ? "Strict" : "Transitional"
         | 
| 27 | 
            +
                      "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 #{strictness}//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-#{strictness.downcase}.dtd\">"
         | 
| 28 | 
            +
                    end
         | 
| 29 | 
            +
                
         | 
| 30 | 
            +
                    def charset(encoding)
         | 
| 31 | 
            +
                      "<meta http-equiv='Content-Type' content='text/html; charset=#{encoding}' />"
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
                
         | 
| 34 | 
            +
                    def start_tag(*options)
         | 
| 35 | 
            +
                      "#{doctype options.first}<html>"
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
                
         | 
| 38 | 
            +
                    def end_tag *options
         | 
| 39 | 
            +
                      "</html>"
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
                    def include(str)
         | 
| 43 | 
            +
                      find_partial(str)
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                    
         | 
| 46 | 
            +
                    def format(doc)
         | 
| 47 | 
            +
                      fdoc = REXML::Document.new doc.assemble_doc
         | 
| 48 | 
            +
                      fdoc.write doc.formatted_doc, 1
         | 
| 49 | 
            +
                    end
         | 
| 50 | 
            +
                
         | 
| 51 | 
            +
                    def textilize(str)      
         | 
| 52 | 
            +
                      RedCloth.new(str).to_html
         | 
| 53 | 
            +
                    end
         | 
| 54 | 
            +
                  
         | 
| 55 | 
            +
                    def method_missing(method, *args, &blk)
         | 
| 56 | 
            +
                      if tags.include? method.to_s
         | 
| 57 | 
            +
                        print_tag(method.to_s, args, &blk)
         | 
| 58 | 
            +
                      end  
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'languages/doc/base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Rbml
         | 
| 4 | 
            +
              module Language
         | 
| 5 | 
            +
                module Doc
         | 
| 6 | 
            +
                  module Xml
         | 
| 7 | 
            +
                    include Base
         | 
| 8 | 
            +
                    def tags;[]end
         | 
| 9 | 
            +
                    def inline what; what end
         | 
| 10 | 
            +
                
         | 
| 11 | 
            +
                    alias :i :inline 
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
                    def method_missing(method, *args, &blk)
         | 
| 14 | 
            +
                      print_tag(method.to_s, args, &blk)  
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
                    def print_tag(tag, *args, &blk)
         | 
| 18 | 
            +
                      options = {}
         | 
| 19 | 
            +
                      content = ''
         | 
| 20 | 
            +
                      args.flatten.each do |a| 
         | 
| 21 | 
            +
                        content = a if a.kind_of? String
         | 
| 22 | 
            +
                        options.merge! a if a.kind_of? Hash
         | 
| 23 | 
            +
                      end
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                      attributes = ' '
         | 
| 26 | 
            +
                      options.each{|k, v| attributes << "#{k}='#{v}' "} if options.kind_of? Hash
         | 
| 27 | 
            +
                  
         | 
| 28 | 
            +
                      if block_given?
         | 
| 29 | 
            +
                        ["<#{tag}#{attributes unless attributes.blank?}>", blk, "</#{tag}>"]
         | 
| 30 | 
            +
                      elsif !content.blank?
         | 
| 31 | 
            +
                        "<#{tag}#{attributes unless attributes.blank?}>#{content}</#{tag}>"
         | 
| 32 | 
            +
                      else
         | 
| 33 | 
            +
                        "<#{tag}#{attributes unless attributes.blank?} />"
         | 
| 34 | 
            +
                      end
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
    
        data/lib/base.rb
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            module Rbml
         | 
| 2 | 
            +
              class Base
         | 
| 3 | 
            +
                attr_accessor :dsl
         | 
| 4 | 
            +
                
         | 
| 5 | 
            +
                def initialize(language=nil)
         | 
| 6 | 
            +
                  @dsl = BlankSlate.new(language)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
                  
         | 
| 9 | 
            +
                def instance_eval_each(code, &blk)
         | 
| 10 | 
            +
                  $whiner = ::Kernel::BlockBreaker.new do |name, args, block|
         | 
| 11 | 
            +
                     yield @dsl.__send__(name, *args, &block)
         | 
| 12 | 
            +
                   end
         | 
| 13 | 
            +
                   $whiner.__instance_eval__ &code
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
    
        data/lib/cli.rb
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module Rbml
         | 
| 2 | 
            +
              class Cli < Base
         | 
| 3 | 
            +
                def self.render(language, options, &block)
         | 
| 4 | 
            +
                  d = Cli.new(language)
         | 
| 5 | 
            +
                  display = lambda do |result|
         | 
| 6 | 
            +
                      puts "#{result}\n" unless result.nil?
         | 
| 7 | 
            +
                    end
         | 
| 8 | 
            +
                  loop do
         | 
| 9 | 
            +
                    begin
         | 
| 10 | 
            +
                      printf options[:prompt]
         | 
| 11 | 
            +
                      d.instance_eval_each(block, &display)
         | 
| 12 | 
            +
                      obj = IO.new(0, "w+")
         | 
| 13 | 
            +
                      d.dsl.__send__("call", obj.gets.chomp)
         | 
| 14 | 
            +
                    rescue Interrupt
         | 
| 15 | 
            +
                      puts " Exiting #{options[:name]}..."
         | 
| 16 | 
            +
                      break
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
    
        data/lib/doc.rb
    CHANGED
    
    | @@ -1,20 +1,10 @@ | |
| 1 | 
            +
            require "base"
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module Rbml
         | 
| 2 | 
            -
              class Doc
         | 
| 3 | 
            -
                attr_accessor :dsl
         | 
| 4 | 
            +
              class Doc < Base
         | 
| 4 5 | 
             
                attr_accessor :assemble_doc
         | 
| 5 6 | 
             
                attr_accessor :formatted_doc
         | 
| 6 7 |  | 
| 7 | 
            -
                def initialize(language=nil)
         | 
| 8 | 
            -
                  @dsl = BlankSlate.new(language)
         | 
| 9 | 
            -
                end
         | 
| 10 | 
            -
                  
         | 
| 11 | 
            -
                def instance_eval_each(code, &blk)
         | 
| 12 | 
            -
                  $whiner = ::Kernel::BlockBreaker.new do |name, args, block|
         | 
| 13 | 
            -
                     yield @dsl.__send__(name, *args, &block)
         | 
| 14 | 
            -
                   end
         | 
| 15 | 
            -
                   $whiner.__instance_eval__ &code
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
                
         | 
| 18 8 | 
             
                def self.render(language, options, &block)
         | 
| 19 9 | 
             
                  d = Doc.new(language)
         | 
| 20 10 | 
             
                  d.assemble_doc = ""
         | 
| @@ -28,8 +18,6 @@ module Rbml | |
| 28 18 | 
             
                  d.assemble_doc << d.dsl.start_tag(options)
         | 
| 29 19 | 
             
                  d.instance_eval_each(block, &display)
         | 
| 30 20 | 
             
                  d.assemble_doc << d.dsl.end_tag
         | 
| 31 | 
            -
                  
         | 
| 32 | 
            -
                  
         | 
| 33 21 | 
             
                  d.formatted_doc = ''
         | 
| 34 22 | 
             
                  begin
         | 
| 35 23 | 
             
                    d.format
         | 
| @@ -39,9 +27,7 @@ module Rbml | |
| 39 27 | 
             
                end
         | 
| 40 28 |  | 
| 41 29 | 
             
                def format
         | 
| 42 | 
            -
                   | 
| 43 | 
            -
                  doc = REXML::Document.new assemble_doc
         | 
| 44 | 
            -
                  doc.write formatted_doc, 1
         | 
| 30 | 
            +
                  dsl.format(self)
         | 
| 45 31 | 
             
                end
         | 
| 46 32 |  | 
| 47 33 | 
             
                def print
         | 
    
        data/lib/extensions/kernel.rb
    CHANGED
    
    | @@ -1,17 +1,32 @@ | |
| 1 1 | 
             
            module Kernel
         | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 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)
         | 
| 6 15 | 
             
              end
         | 
| 7 | 
            -
               | 
| 8 | 
            -
               | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              ROUTES.each_key do |k|
         | 
| 18 | 
            +
                alias_method k, :spawn
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              
         | 
| 9 21 | 
             
              def method_name; caller[0][/`([^']*)'/, 1]; end
         | 
| 10 22 |  | 
| 11 | 
            -
              class BlankSlate
         | 
| 23 | 
            +
              class BlankSlate #:nodoc:
         | 
| 12 24 | 
             
                alias :__instance_eval__ :instance_eval
         | 
| 13 25 | 
             
                alias :__extend__ :extend
         | 
| 14 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
         | 
| 15 30 |  | 
| 16 31 | 
             
                instance_methods.each {|m| undef_method m unless m =~ /^__/ }
         | 
| 17 32 |  | 
| @@ -20,8 +35,7 @@ module Kernel | |
| 20 35 | 
             
                end
         | 
| 21 36 | 
             
              end
         | 
| 22 37 |  | 
| 23 | 
            -
              class BlockBreaker < BlankSlate
         | 
| 24 | 
            -
                
         | 
| 38 | 
            +
              class BlockBreaker < BlankSlate #:nodoc:
         | 
| 25 39 | 
             
                def initialize(&block)
         | 
| 26 40 | 
             
                  if block_given?
         | 
| 27 41 | 
             
                    @handler = block
         | 
| @@ -35,6 +49,7 @@ module Kernel | |
| 35 49 | 
             
                end
         | 
| 36 50 | 
             
              end
         | 
| 37 51 |  | 
| 38 | 
            -
              class NoBlockGiven < StandardError | 
| 52 | 
            +
              class NoBlockGiven < StandardError #:nodoc:
         | 
| 53 | 
            +
              end 
         | 
| 39 54 | 
             
            end
         | 
| 40 55 |  | 
    
        data/lib/extensions/string.rb
    CHANGED
    
    | @@ -4,7 +4,11 @@ class String | |
| 4 4 | 
             
              end
         | 
| 5 5 |  | 
| 6 6 | 
             
              def to_m
         | 
| 7 | 
            -
                 | 
| 8 | 
            -
             | 
| 7 | 
            +
                self.split("::").inject(Rbml) { |injection, element| injection.const_get(element) }
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
              
         | 
| 10 | 
            +
              #TODO: not really camelize
         | 
| 11 | 
            +
              def camelize
         | 
| 12 | 
            +
                self[0,1].upcase + self[1, self.length]
         | 
| 9 13 | 
             
              end
         | 
| 10 14 | 
             
            end
         | 
    
        data/lib/rbml.rb
    CHANGED
    
    | @@ -1,8 +1,11 @@ | |
| 1 1 | 
             
            $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            module Rbml
         | 
| 3 | 
            -
              VERSION = '0.0. | 
| 4 | 
            +
              VERSION = '0.0.5'
         | 
| 4 5 | 
             
            end
         | 
| 5 6 | 
             
            require 'extensions/kernel'
         | 
| 6 7 | 
             
            require 'extensions/string'
         | 
| 8 | 
            +
            require 'base'
         | 
| 7 9 | 
             
            require 'doc'
         | 
| 8 | 
            -
            require ' | 
| 10 | 
            +
            require 'cli'
         | 
| 11 | 
            +
            require 'processor'
         | 
    
        data/lib/shell.rb
    ADDED
    
    
    
        metadata
    CHANGED
    
    | @@ -3,15 +3,15 @@ rubygems_version: 0.8.11 | |
| 3 3 | 
             
            specification_version: 1
         | 
| 4 4 | 
             
            name: rbml
         | 
| 5 5 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            -
              version: 0.0. | 
| 7 | 
            -
            date: 2007-01- | 
| 6 | 
            +
              version: 0.0.5
         | 
| 7 | 
            +
            date: 2007-01-30 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:  * XML support is totally untested since we don't need it  == SYNOPSIS:  | 
| 14 | 
            +
            description: "== FEATURES/PROBLEMS:  * can load rbml partials using +include+ method * XML support is totally untested since we don't need it  == SYNOPSIS:  <tt>rbml path/to/file.rbml</tt>"
         | 
| 15 15 | 
             
            autorequire: 
         | 
| 16 16 | 
             
            default_executable: 
         | 
| 17 17 | 
             
            bindir: bin
         | 
| @@ -33,26 +33,32 @@ files: | |
| 33 33 | 
             
            - README.txt
         | 
| 34 34 | 
             
            - Rakefile
         | 
| 35 35 | 
             
            - bin/rbml
         | 
| 36 | 
            -
            - languages/ | 
| 37 | 
            -
            - languages/ | 
| 38 | 
            -
            - languages/ | 
| 36 | 
            +
            - languages/cli/cli.rb
         | 
| 37 | 
            +
            - languages/doc/base.rb
         | 
| 38 | 
            +
            - languages/doc/xhtml.rb
         | 
| 39 | 
            +
            - languages/doc/xml.rb
         | 
| 40 | 
            +
            - examples/cli/happycli.rbml
         | 
| 41 | 
            +
            - examples/doc/_partial.rbml
         | 
| 42 | 
            +
            - examples/doc/sublist/_sublist.rbml
         | 
| 43 | 
            +
            - examples/doc/synopsis.rbml
         | 
| 44 | 
            +
            - examples/doc/test.rbml
         | 
| 45 | 
            +
            - examples/shell/centos_apache_2_2_3.rbml
         | 
| 46 | 
            +
            - lib/base.rb
         | 
| 47 | 
            +
            - lib/cli.rb
         | 
| 39 48 | 
             
            - lib/doc.rb
         | 
| 40 49 | 
             
            - lib/extensions/kernel.rb
         | 
| 41 50 | 
             
            - lib/extensions/string.rb
         | 
| 42 51 | 
             
            - lib/processor.rb
         | 
| 43 52 | 
             
            - lib/rbml.rb
         | 
| 53 | 
            +
            - lib/shell.rb
         | 
| 44 54 | 
             
            - spec/doc_spec.rb
         | 
| 45 | 
            -
            - spec/fixtures/_partial.rbml
         | 
| 46 | 
            -
            - spec/fixtures/sublist/_sublist.rbml
         | 
| 47 | 
            -
            - spec/fixtures/synopsis.rbml
         | 
| 48 | 
            -
            - spec/fixtures/test.rbml
         | 
| 49 55 | 
             
            - spec/object_spec.rb
         | 
| 50 56 | 
             
            - spec/rbml_spec.rb
         | 
| 51 57 | 
             
            - spec/spec_helper.rb
         | 
| 52 58 | 
             
            test_files: []
         | 
| 53 59 |  | 
| 54 | 
            -
            rdoc_options:  | 
| 55 | 
            -
             | 
| 60 | 
            +
            rdoc_options: 
         | 
| 61 | 
            +
            - --inline-source
         | 
| 56 62 | 
             
            extra_rdoc_files: []
         | 
| 57 63 |  | 
| 58 64 | 
             
            executables: 
         | 
    
        data/languages/base.rb
    DELETED
    
    
    
        data/languages/xhtml.rb
    DELETED
    
    | @@ -1,47 +0,0 @@ | |
| 1 | 
            -
            require 'languages/xml'
         | 
| 2 | 
            -
            require 'redcloth'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module Rbml
         | 
| 5 | 
            -
              module Xhtml
         | 
| 6 | 
            -
                include Xml
         | 
| 7 | 
            -
                
         | 
| 8 | 
            -
                def tags; ['body', 'title', 'head', 'p', 'div', 'ul', 'li', 'html', 'a', 'br', 'span']end
         | 
| 9 | 
            -
                
         | 
| 10 | 
            -
                def stylesheets *sheets
         | 
| 11 | 
            -
                  all_sheets = ''
         | 
| 12 | 
            -
                  sheets.each {|sheet| all_sheets << stylesheet(sheet)}
         | 
| 13 | 
            -
                  all_sheets
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
                  
         | 
| 16 | 
            -
                def stylesheet what
         | 
| 17 | 
            -
                  "<link rel='stylesheet' href='/stylesheets/#{what}.css' type='text/css' />"
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
                
         | 
| 20 | 
            -
                def doctype(options)
         | 
| 21 | 
            -
                  strictness = options[:strict] ? "Strict" : "Transitional"
         | 
| 22 | 
            -
                  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 #{strictness}//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-#{strictness.downcase}.dtd\">"
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
                
         | 
| 25 | 
            -
                def start_tag(*options)
         | 
| 26 | 
            -
                  "#{doctype options.first}<html>"
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
                
         | 
| 29 | 
            -
                def end_tag *options
         | 
| 30 | 
            -
                  "</html>"
         | 
| 31 | 
            -
                end
         | 
| 32 | 
            -
                
         | 
| 33 | 
            -
                def include(str)
         | 
| 34 | 
            -
                  find_partial(str)
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
                
         | 
| 37 | 
            -
                def textilize(str)      
         | 
| 38 | 
            -
                  RedCloth.new(str).to_html
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
                  
         | 
| 41 | 
            -
                def method_missing(method, *args, &blk)
         | 
| 42 | 
            -
                  if tags.include? method.to_s
         | 
| 43 | 
            -
                    print_tag(method.to_s, args, &blk)
         | 
| 44 | 
            -
                  end  
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
              end
         | 
| 47 | 
            -
            end
         | 
    
        data/languages/xml.rb
    DELETED
    
    | @@ -1,35 +0,0 @@ | |
| 1 | 
            -
            require 'languages/base'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Rbml
         | 
| 4 | 
            -
              module Xml
         | 
| 5 | 
            -
                include Base
         | 
| 6 | 
            -
                def tags;[]end
         | 
| 7 | 
            -
                def inline what; what end
         | 
| 8 | 
            -
                
         | 
| 9 | 
            -
                alias :i :inline 
         | 
| 10 | 
            -
              
         | 
| 11 | 
            -
                def method_missing(method, *args, &blk)
         | 
| 12 | 
            -
                  print_tag(method.to_s, args, &blk)  
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              
         | 
| 15 | 
            -
                def print_tag(tag, *args, &blk)
         | 
| 16 | 
            -
                  options = {}
         | 
| 17 | 
            -
                  content = ''
         | 
| 18 | 
            -
                  args.flatten.each do |a| 
         | 
| 19 | 
            -
                    content = a if a.kind_of? String
         | 
| 20 | 
            -
                    options.merge! a if a.kind_of? Hash
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                
         | 
| 23 | 
            -
                  attributes = ' '
         | 
| 24 | 
            -
                  options.each{|k, v| attributes << "#{k}='#{v}' "} if options.kind_of? Hash
         | 
| 25 | 
            -
                  
         | 
| 26 | 
            -
                  if block_given?
         | 
| 27 | 
            -
                    ["<#{tag}#{attributes unless attributes.blank?}>", blk, "</#{tag}>"]
         | 
| 28 | 
            -
                  elsif !content.blank?
         | 
| 29 | 
            -
                    "<#{tag}#{attributes unless attributes.blank?}>#{content}</#{tag}>"
         | 
| 30 | 
            -
                  else
         | 
| 31 | 
            -
                    "<#{tag}#{attributes unless attributes.blank?} />"
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
              end
         | 
| 35 | 
            -
            end
         |