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.
@@ -1,7 +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
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
 
@@ -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/doc.rb
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/shell.rb
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
- Rbml
1
+ rbml
2
2
  by Jake Howerton, Evan Short
3
3
  http://rbml.rubyforge.org
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Rbml is a dsl framework for outputting other languages (currently supports Xhtml, XML)
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
- * XML support is totally untested since we don't need it
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
- require 'rbml'
5
- ::Rbml::Processor.run(ARGV)
3
+ $template_dir = File.dirname(ARGV[0]) if ARGV[0]
4
+
5
+ require 'lib/rbml'
6
+ ::Rbml::Processor.run(ARGV)
@@ -1,13 +1,17 @@
1
1
  cli :name=>"happycli", :prompt=>"happy> " do
2
2
  set :unknown_command do
3
- cliprint "my freakin command"
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
@@ -6,7 +6,7 @@ xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do
6
6
  end
7
7
 
8
8
  body do
9
- textilize "*Header*"
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 "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"]
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
- make
15
- make :install
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
@@ -5,7 +5,14 @@ module Rbml
5
5
  def find_partial(str)
6
6
  arr = str.split("/")
7
7
  arr.last[0,0] = "_"
8
- filename = ($template_dir + '/' + arr.join("/") + '.rbml')
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
@@ -51,6 +51,7 @@ module Rbml
51
51
  def textilize(str)
52
52
  RedCloth.new(str).to_html
53
53
  end
54
+ alias :t :textilize
54
55
 
55
56
  def method_missing(method, *args, &blk)
56
57
  if tags.include? method.to_s
@@ -60,4 +61,4 @@ module Rbml
60
61
  end
61
62
  end
62
63
  end
63
- end
64
+ end
@@ -36,4 +36,4 @@ module Rbml
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -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
@@ -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
- $whiner = ::Kernel::BlockBreaker.new do |name, args, block|
11
+ $breaker = BlockBreaker.new do |name, args, block|
11
12
  yield @dsl.__send__(name, *args, &block)
12
13
  end
13
- $whiner.__instance_eval__ &code
14
+ $breaker.__instance_eval__ &code
14
15
  end
15
16
  end
16
- end
17
+ end
data/lib/cli.rb CHANGED
@@ -12,7 +12,7 @@ module Rbml
12
12
  obj = IO.new(0, "w+")
13
13
  d.dsl.__send__("call", obj.gets.chomp)
14
14
  rescue Interrupt
15
- puts " Exiting #{options[:name]}..."
15
+ puts "\nExiting #{options[:name]}..."
16
16
  break
17
17
  end
18
18
  end
@@ -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
@@ -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
 
@@ -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
- # If ARGV is a glob, it will actually each over each one of the matching files.
5
- argv.each do |file_or_dir|
6
- load file_or_dir
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
@@ -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 'processor'
14
+ require 'shell'
@@ -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.8.11
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-01-30 00:00:00 -05:00
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 since we don't need it == SYNOPSIS: <tt>rbml path/to/file.rbml</tt>"
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/doc.rb
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/shell.rb
56
+ - lib/daemon.rb
54
57
  - spec/doc_spec.rb
55
58
  - spec/object_spec.rb
56
59
  - spec/rbml_spec.rb