malt 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.rdoc +18 -0
  2. data/README.rdoc +6 -2
  3. data/lib/malt.rb +9 -0
  4. data/lib/malt/engines/abstract.rb +7 -7
  5. data/lib/malt/engines/bluecloth.rb +3 -3
  6. data/lib/malt/engines/builder.rb +72 -0
  7. data/lib/malt/engines/erb.rb +2 -0
  8. data/lib/malt/engines/erector.rb +59 -0
  9. data/lib/malt/engines/haml.rb +2 -2
  10. data/lib/malt/engines/kramdown.rb +6 -4
  11. data/lib/malt/engines/less.rb +8 -8
  12. data/lib/malt/engines/markaby.rb +51 -0
  13. data/lib/malt/engines/mustache.rb +44 -0
  14. data/lib/malt/engines/radius.rb +4 -4
  15. data/lib/malt/engines/ragtag.rb +49 -0
  16. data/lib/malt/engines/rdiscount.rb +1 -1
  17. data/lib/malt/engines/rdoc.rb +3 -3
  18. data/lib/malt/engines/redcloth.rb +1 -1
  19. data/lib/malt/engines/sass.rb +8 -8
  20. data/lib/malt/engines/tenjin.rb +6 -6
  21. data/lib/malt/formats/abstract.rb +8 -2
  22. data/lib/malt/formats/builder.rb +56 -0
  23. data/lib/malt/formats/css.rb +8 -8
  24. data/lib/malt/formats/erector.rb +53 -0
  25. data/lib/malt/formats/haml.rb +2 -2
  26. data/lib/malt/formats/html.rb +3 -3
  27. data/lib/malt/formats/latex.rb +4 -4
  28. data/lib/malt/formats/less.rb +5 -5
  29. data/lib/malt/formats/liquid.rb +11 -1
  30. data/lib/malt/formats/markaby.rb +53 -0
  31. data/lib/malt/formats/markdown.rb +6 -6
  32. data/lib/malt/formats/mustache.rb +34 -0
  33. data/lib/malt/formats/pdf.rb +2 -2
  34. data/lib/malt/formats/radius.rb +4 -4
  35. data/lib/malt/formats/{rtals.rb → ragtag.rb} +13 -9
  36. data/lib/malt/formats/rdoc.rb +4 -4
  37. data/lib/malt/formats/ruby.rb +2 -2
  38. data/lib/malt/formats/sass.rb +10 -0
  39. data/lib/malt/formats/scss.rb +10 -0
  40. data/lib/malt/formats/tenjin.rb +4 -4
  41. data/lib/malt/formats/textile.rb +12 -12
  42. data/lib/malt/formats/xml.rb +29 -0
  43. data/lib/malt/formats/yaml.rb +2 -2
  44. data/lib/malt/meta/data.rb +4 -4
  45. data/lib/malt/meta/{gemfile → package} +6 -2
  46. data/lib/malt/render.rb +37 -9
  47. data/meta/data.rb +4 -4
  48. data/meta/{gemfile → package} +6 -2
  49. data/qed/03_formats/08_ragtag.rdoc +19 -0
  50. data/qed/03_formats/17_markaby.rdoc +50 -0
  51. data/qed/03_formats/18_builder.rb +50 -0
  52. data/qed/03_formats/19_erector.rb +50 -0
  53. data/qed/03_formats/20_mustache.rdoc +54 -0
  54. data/{test/samples/sample.md → qed/samples/sample.markdown} +0 -0
  55. data/{test → qed}/samples/sample.rdoc +0 -0
  56. metadata +81 -12
  57. data/lib/malt/engines/rtals.rb +0 -46
  58. data/qed/03_formats/08_rtal.rdoc +0 -15
@@ -16,7 +16,7 @@ module Malt::Engine
16
16
 
17
17
  # Convert Markdown text to HTML text.
18
18
  def render(params)
19
- case params[:format]
19
+ case params[:to]
20
20
  when :html, nil
21
21
  intermediate(params).to_html
22
22
  else
@@ -15,9 +15,9 @@ module Malt::Engine
15
15
 
16
16
  # Convert rdoc text to html.
17
17
  def render(params)
18
- text = params[:text]
19
- format = params[:format]
20
- case format
18
+ text = params[:text]
19
+ into = params[:to]
20
+ case into
21
21
  when :html, nil
22
22
  html_engine.convert(text).to_s
23
23
  else
@@ -14,7 +14,7 @@ module Malt::Engine
14
14
  # :format => Symbol of the format to render [:html]
15
15
  #
16
16
  def render(params={})
17
- case params[:format]
17
+ case params[:to]
18
18
  when :html, nil
19
19
  intermediate(params).to_html
20
20
  else
@@ -10,11 +10,11 @@ module Malt::Engine
10
10
 
11
11
  #
12
12
  def render(params, &yld)
13
- text = params[:text]
14
- file = params[:file]
15
- format = params[:format]
13
+ text = params[:text]
14
+ file = params[:file]
15
+ into = params[:to]
16
16
 
17
- case format
17
+ case into
18
18
  when :css, nil
19
19
  engine = intermediate(params)
20
20
  engine.render
@@ -39,10 +39,10 @@ module Malt::Engine
39
39
  require_library 'sass'
40
40
  end
41
41
 
42
- def engine_options
43
- opts = {}
44
- opts
45
- end
42
+ #def engine_options
43
+ # opts = {}
44
+ # opts
45
+ #end
46
46
 
47
47
  end
48
48
 
@@ -15,13 +15,13 @@ module Malt::Engine
15
15
 
16
16
  #
17
17
  def render(params, &yld)
18
- text = params[:text]
19
- file = params[:file]
20
- data = params[:data]
21
- type = params[:type]
22
- format = params[:format] || :html
18
+ text = params[:text]
19
+ file = params[:file]
20
+ data = params[:data]
21
+ type = params[:type]
22
+ into = params[:to] || :html
23
23
 
24
- return super(params, &yld) if type == :rbhtml && format != :html
24
+ return super(params, &yld) if type == :rbhtml && into != :html
25
25
 
26
26
  data = make_hash(data, &yld)
27
27
  template = intermediate(params)
@@ -28,7 +28,9 @@ module Format
28
28
  @extensions
29
29
  end
30
30
 
31
- #
31
+ #--
32
+ # TODO: warning: instance variable @engine not initialized
33
+ #++
32
34
  def self.engine(set=nil)
33
35
  @engine = set if set
34
36
  @engine
@@ -47,7 +49,6 @@ module Format
47
49
  def initialize_engine
48
50
  end
49
51
 
50
-
51
52
  public
52
53
 
53
54
  # Access to the options given to the initializer.
@@ -160,6 +161,11 @@ module Format
160
161
  text
161
162
  end
162
163
 
164
+ #
165
+ def to_default(data=nil, &yld)
166
+ to(default, data, &yld)
167
+ end
168
+
163
169
  # Default rendering type is +:html+. Override if it
164
170
  # differs for the subclassing format.
165
171
  def default
@@ -0,0 +1,56 @@
1
+ require 'malt/formats/abstract'
2
+ require 'malt/formats/html'
3
+ require 'malt/engines/builder'
4
+
5
+ module Malt::Format
6
+
7
+ # Builder looks like a Markup format, but it is a template format
8
+ # as Ruby code.
9
+ #
10
+ # http://builder.rubyforge.org/
11
+ #
12
+ class Builder < Abstract
13
+
14
+ register 'builder'
15
+
16
+ #
17
+ def builder(*)
18
+ text
19
+ end
20
+
21
+ #
22
+ def to_builder(*)
23
+ self
24
+ end
25
+
26
+ #
27
+ def html(data=nil, &yld)
28
+ render_engine.render(:format=>:html, :text=>text, :file=>file, :data=>data, &yld)
29
+ end
30
+
31
+ #
32
+ def to_html(data=nil, &yld)
33
+ text = html(data, &yld)
34
+ opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
35
+ HTML.new(opts)
36
+ end
37
+
38
+ #
39
+ #def to_ruby(db, &yld)
40
+ # @ruby ||= (
41
+ # source = engine.compile(text, file)
42
+ # Ruby.new(:text=>source, :file=>refile(:rb))
43
+ # )
44
+ #end
45
+
46
+ private
47
+
48
+ #
49
+ def render_engine
50
+ @render_engine ||= Malt::Engine::Builder.new(options)
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+
@@ -19,14 +19,14 @@ module Malt::Format
19
19
 
20
20
  private
21
21
 
22
- #
23
- def render_engine
24
- end
25
-
26
- # CSS default output type is itself.
27
- def default
28
- :css
29
- end
22
+ #
23
+ def render_engine
24
+ end
25
+
26
+ # CSS default output type is itself.
27
+ def default
28
+ :css
29
+ end
30
30
 
31
31
  end
32
32
 
@@ -0,0 +1,53 @@
1
+ require 'malt/formats/abstract'
2
+ require 'malt/formats/html'
3
+ require 'malt/engines/erector'
4
+
5
+ module Malt::Format
6
+
7
+ # Erecotr looks like a Markup format, but it is a template format
8
+ # Much like pure Ruby too.
9
+ class Erector < Abstract
10
+
11
+ register 'erector'
12
+
13
+ #
14
+ def erector(*)
15
+ text
16
+ end
17
+
18
+ #
19
+ def to_erector(*)
20
+ self
21
+ end
22
+
23
+ #
24
+ def html(data=nil, &yld)
25
+ render_engine.render(:format=>:html, :text=>text, :file=>file, :data=>data, &yld)
26
+ end
27
+
28
+ #
29
+ def to_html(data=nil, &yld)
30
+ text = html(data, &yld)
31
+ opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
32
+ HTML.new(opts)
33
+ end
34
+
35
+ #
36
+ #def to_ruby(db, &yld)
37
+ # @ruby ||= (
38
+ # source = engine.compile(text, file)
39
+ # Ruby.new(:text=>source, :file=>refile(:rb))
40
+ # )
41
+ #end
42
+
43
+ private
44
+
45
+ #
46
+ def render_engine
47
+ @render_engine ||= Malt::Engine::Erector.new(options)
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
@@ -11,12 +11,12 @@ module Malt::Format
11
11
  register 'haml'
12
12
 
13
13
  #
14
- def haml
14
+ def haml(*)
15
15
  text
16
16
  end
17
17
 
18
18
  #
19
- def to_haml
19
+ def to_haml(*)
20
20
  self
21
21
  end
22
22
 
@@ -19,9 +19,9 @@ module Malt::Format
19
19
 
20
20
  private
21
21
 
22
- #
23
- def render_engine
24
- end
22
+ #
23
+ def render_engine
24
+ end
25
25
 
26
26
  end
27
27
 
@@ -9,22 +9,22 @@ module Malt::Format
9
9
  register 'latex'
10
10
 
11
11
  #
12
- def latex
12
+ def latex(*)
13
13
  text
14
14
  end
15
15
 
16
16
  #
17
- def to_latex
17
+ def to_latex(*)
18
18
  self
19
19
  end
20
20
 
21
21
  # TODO
22
- def pdf
22
+ def pdf(*)
23
23
  raise "not implemented yet"
24
24
  end
25
25
 
26
26
  # TODO
27
- def to_pdf
27
+ def to_pdf(*)
28
28
  text = pdf
29
29
  opts = options.merge(:text=>text, :file=>refile(:pdf), :type=>:pdf)
30
30
  PDF.new(opts)
@@ -12,24 +12,24 @@ module Malt::Format
12
12
  register('less')
13
13
 
14
14
  #
15
- def less
15
+ def less(*)
16
16
  text
17
17
  end
18
18
 
19
19
  #
20
- def to_less
20
+ def to_less(*)
21
21
  self
22
22
  end
23
23
 
24
24
  #
25
- def css
25
+ def css(*)
26
26
  render_engine.render(:text=>text, :file=>:file, :format=>:css)
27
27
  end
28
28
 
29
29
  #
30
- def to_css
30
+ def to_css(*)
31
31
  text = css
32
- opts = options.merge(:text=>text, file=>refile(:css), :type=>:css)
32
+ opts = options.merge(:text=>text, :file=>refile(:css), :type=>:css)
33
33
  CSS.new(opts)
34
34
  end
35
35
 
@@ -9,7 +9,17 @@ module Malt::Format
9
9
  #
10
10
  class Liquid < AbstractTemplate
11
11
 
12
- register 'liquid'
12
+ register('liquid')
13
+
14
+ #
15
+ def liquid(*)
16
+ text
17
+ end
18
+
19
+ #
20
+ def to_liquid(*)
21
+ self
22
+ end
13
23
 
14
24
  # #
15
25
  # def to(type, data=nil, &yld)
@@ -0,0 +1,53 @@
1
+ require 'malt/formats/abstract'
2
+ require 'malt/formats/html'
3
+ require 'malt/engines/markaby'
4
+
5
+ module Malt::Format
6
+
7
+ # Erecotr looks like a Markup format, but it is a template format
8
+ # Much like pure Ruby too.
9
+ class Markaby < Abstract
10
+
11
+ register 'markaby', 'mab'
12
+
13
+ #
14
+ def markaby(*)
15
+ text
16
+ end
17
+
18
+ #
19
+ def to_markaby(*)
20
+ self
21
+ end
22
+
23
+ #
24
+ def html(data=nil, &yld)
25
+ render_engine.render(:format=>:html, :text=>text, :file=>file, :data=>data, &yld)
26
+ end
27
+
28
+ #
29
+ def to_html(data=nil, &yld)
30
+ text = html(data, &yld)
31
+ opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
32
+ HTML.new(opts)
33
+ end
34
+
35
+ #
36
+ #def to_ruby(db, &yld)
37
+ # @ruby ||= (
38
+ # source = engine.compile(text, file)
39
+ # Ruby.new(:text=>source, :file=>refile(:rb))
40
+ # )
41
+ #end
42
+
43
+ private
44
+
45
+ #
46
+ def render_engine
47
+ @render_engine ||= Malt::Engine::Markaby.new(options)
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
@@ -12,17 +12,17 @@ module Malt::Format
12
12
  register('markdown', 'md')
13
13
 
14
14
  #
15
- def html
15
+ def html(*)
16
16
  render_engine.render(:text=>text, :file=>file, :format=>:html)
17
17
  end
18
18
 
19
19
  #
20
- def latex
20
+ def latex(*)
21
21
  render_engine.render(:text=>text, :file=>file, :format=>:latex)
22
22
  end
23
23
 
24
24
  #
25
- def markdown
25
+ def markdown(*)
26
26
  text
27
27
  end
28
28
 
@@ -30,19 +30,19 @@ module Malt::Format
30
30
  alias_method :md, :markdown
31
31
 
32
32
  # Convert to HTML.
33
- def to_html
33
+ def to_html(*)
34
34
  opts = options.merge(:text=>html, :file=>refile(:html), :type=>:html)
35
35
  HTML.new(opts)
36
36
  end
37
37
 
38
38
  # Latex is only supported by the Kramdown engine.
39
- def to_latex
39
+ def to_latex(*)
40
40
  opts = options.merge(:text=>html, :file=>refile(:latex), :type=>:latex)
41
41
  Latex.new(opts)
42
42
  end
43
43
 
44
44
  #
45
- def to_markdown
45
+ def to_markdown(*)
46
46
  self
47
47
  end
48
48