malt 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/History.rdoc +15 -1
  2. data/Syckfile +80 -0
  3. data/lib/malt.rb +1 -1
  4. data/lib/malt/config.rb +12 -0
  5. data/lib/malt/engines.rb +1 -1
  6. data/lib/malt/engines/abstract.rb +2 -2
  7. data/lib/malt/engines/bluecloth.rb +1 -1
  8. data/lib/malt/engines/erb.rb +1 -1
  9. data/lib/malt/engines/erubis.rb +1 -1
  10. data/lib/malt/engines/haml.rb +1 -1
  11. data/lib/malt/engines/kramdown.rb +1 -1
  12. data/lib/malt/engines/less.rb +1 -1
  13. data/lib/malt/engines/liquid.rb +1 -1
  14. data/lib/malt/engines/radius.rb +1 -1
  15. data/lib/malt/engines/rdiscount.rb +1 -1
  16. data/lib/malt/engines/rdoc.rb +1 -1
  17. data/lib/malt/engines/redcloth.rb +1 -1
  18. data/lib/malt/engines/rtals.rb +1 -1
  19. data/lib/malt/engines/ruby.rb +1 -1
  20. data/lib/malt/engines/sass.rb +1 -1
  21. data/lib/malt/engines/tenjin.rb +1 -1
  22. data/lib/malt/formats.rb +1 -1
  23. data/lib/malt/formats/abstract.rb +5 -3
  24. data/lib/malt/formats/abstract_template.rb +45 -0
  25. data/lib/malt/formats/css.rb +1 -1
  26. data/lib/malt/formats/erb.rb +3 -3
  27. data/lib/malt/formats/haml.rb +2 -2
  28. data/lib/malt/formats/html.rb +1 -1
  29. data/lib/malt/formats/latex.rb +1 -1
  30. data/lib/malt/formats/less.rb +2 -2
  31. data/lib/malt/formats/liquid.rb +2 -2
  32. data/lib/malt/formats/markdown.rb +4 -4
  33. data/lib/malt/formats/pdf.rb +1 -1
  34. data/lib/malt/formats/radius.rb +2 -2
  35. data/lib/malt/formats/rbhtml.rb +52 -0
  36. data/lib/malt/formats/rdoc.rb +2 -2
  37. data/lib/malt/formats/rhtml.rb +86 -0
  38. data/lib/malt/formats/rtals.rb +2 -2
  39. data/lib/malt/formats/ruby.rb +2 -2
  40. data/lib/malt/formats/sass.rb +2 -2
  41. data/lib/malt/formats/scss.rb +57 -0
  42. data/lib/malt/formats/tenjin.rb +2 -2
  43. data/lib/malt/formats/text.rb +1 -1
  44. data/lib/malt/formats/textile.rb +2 -2
  45. data/lib/malt/formats/yaml.rb +1 -1
  46. data/lib/malt/markup.rb +9 -0
  47. data/lib/malt/meta/gemfile +2 -2
  48. data/lib/malt/render.rb +65 -0
  49. data/lib/malt/template.rb +12 -0
  50. data/meta/gemfile +2 -2
  51. data/qed/01_overview.rdoc +6 -42
  52. data/qed/02_formats.rdoc +39 -0
  53. data/qed/03_formats/01_overview.rdoc +7 -0
  54. data/qed/03_formats/02_rdoc.rdoc +83 -0
  55. data/qed/03_formats/03_textile.rdoc +48 -0
  56. data/qed/03_formats/04_markdown.rdoc +66 -0
  57. data/qed/03_formats/05_erb.rdoc +65 -0
  58. data/qed/03_formats/06_liquid.rdoc +54 -0
  59. data/qed/03_formats/07_haml.rdoc +44 -0
  60. data/qed/03_formats/08_rtal.rdoc +15 -0
  61. data/qed/03_formats/09_radius.rdoc +43 -0
  62. data/qed/03_formats/11_tenjin.rdoc +47 -0
  63. data/qed/03_formats/12_rbhtml.rdoc +55 -0
  64. data/qed/03_formats/13_sass.rdoc +55 -0
  65. data/qed/03_formats/14_scss.rdoc +58 -0
  66. data/qed/03_formats/15_less.rdoc +46 -0
  67. data/qed/03_formats/16_ruby.rdoc +48 -0
  68. data/qed/samples/data.yml +4 -0
  69. data/qed/samples/output-erb.txt +1 -0
  70. data/qed/samples/output-liquid.txt +1 -0
  71. data/qed/samples/output-mustache.txt +1 -0
  72. data/qed/samples/output-radius.txt +1 -0
  73. data/qed/samples/sample.erb +1 -0
  74. data/qed/samples/sample.liquid +1 -0
  75. data/qed/samples/sample.mustache +1 -0
  76. data/qed/samples/sample.radius +1 -0
  77. data/test/samples/sample.md +308 -0
  78. data/test/samples/sample.rdoc +8 -0
  79. metadata +40 -4
@@ -1,6 +1,20 @@
1
1
  = Release History
2
2
 
3
- == 0.1.0 | 2010-06-23
3
+ == 0.1.1 | 2010-09-21
4
+
5
+ This release simple fixes two bugs. One to handle variant arity
6
+ in format class #render methods. Currently the interface can vary
7
+ dependent on whether they accept interpolation data or not (this will
8
+ probably be uniform in the future). The other fix raises an error if
9
+ no engine exists to handle a given format.
10
+
11
+ Changes:
12
+
13
+ * Bug fix to raise error if format not handled by any engine.
14
+ * Bug fix to underlying #render calls to handle variant arities.
15
+
16
+
17
+ == 0.1.0 | 2010-08-23
4
18
 
5
19
  This if the initial release of Malt. I have no doubt the code base
6
20
  still needs some fine-tuning --hence the 0.1 version, but I have put
@@ -0,0 +1,80 @@
1
+ ---
2
+ box:
3
+ service: Box
4
+ types : [gem]
5
+ active : true
6
+
7
+ dnote:
8
+ service : DNote
9
+ loadpath : ~
10
+ labels : ~
11
+ output : ~
12
+ format : ~
13
+ active : true
14
+
15
+ stats:
16
+ service : Stats
17
+ title : ~
18
+ loadpath : ~
19
+ exclude : ~
20
+ output : ~
21
+ active : true
22
+
23
+ rdoc:
24
+ service : rdoc
25
+ template: newfish
26
+ exclude : [Syckfile]
27
+ output : site/docs/api
28
+ active : true
29
+
30
+ ridoc:
31
+ service : RIDoc
32
+ include : ~
33
+ exclude : ~
34
+ output : ri
35
+ active : true
36
+
37
+ qedoc:
38
+ service : Custom
39
+ cycle : main
40
+ document: |
41
+ system 'qedoc -o site/docs/qed -t "Malt Demonstrandum" qed/'
42
+
43
+ testrb:
44
+ service : testrb
45
+ tests : ~
46
+ exclude : ~
47
+ loadpath : ~
48
+ requires : ~
49
+ live : false
50
+ active : false
51
+
52
+ grancher:
53
+ service: Grancher
54
+ active: true
55
+
56
+ gemcutter:
57
+ active: true
58
+
59
+ email:
60
+ service : Email
61
+ file : ~
62
+ subject : ~
63
+ mailto : ruby-talk@ruby-lang.org
64
+ # from : transfire@gmail.com
65
+ # server : <%= ENV['EMAIL_SERVER'] %>
66
+ # port : <%= ENV['EMAIL_PORT'] %>
67
+ # account : <%= ENV['EMAIL_ACCOUNT'] %>
68
+ # domain : <%= ENV['EMAIL_DOMAIN'] %>
69
+ # login : <%= ENV['EMAIL_LOGIN'] %>
70
+ # secure : <%= ENV['EMAIL_SECURE'] %>
71
+ active : true
72
+
73
+ vclog:
74
+ service : VClog
75
+ format : html # xml, txt
76
+ layout : rel # gnu
77
+ typed : false
78
+ output : ~
79
+ active : false
80
+
@@ -38,7 +38,7 @@ module Malt
38
38
  end
39
39
  type = options[:type] || options[:format] || ext
40
40
  type = ext_to_type(type)
41
- malt_class = registry[type] || Formats::Text
41
+ malt_class = registry[type] || Format::Text
42
42
  #raise "unkown type -- #{type}" unless malt_class
43
43
  malt_class.new(options.merge(:text=>text,:file=>file,:type=>type))
44
44
  end
@@ -0,0 +1,12 @@
1
+ module Malt
2
+
3
+ class Config
4
+
5
+ #
6
+ def engine
7
+ @engine ||= {}
8
+ end
9
+
10
+ end
11
+
12
+ end
@@ -1,6 +1,6 @@
1
1
  module Malt
2
2
  #
3
- module Engines
3
+ module Engine
4
4
  end
5
5
  end
6
6
 
@@ -1,7 +1,7 @@
1
1
  require 'malt/kernel'
2
2
 
3
3
  module Malt
4
- module Engines
4
+ module Engine
5
5
 
6
6
  class << self
7
7
  include Malt::Kernel
@@ -31,7 +31,7 @@ module Engines
31
31
 
32
32
  # Register the class to an extension type.
33
33
  def self.register(*exts)
34
- Engines.register(self, *exts)
34
+ Engine.register(self, *exts)
35
35
  end
36
36
 
37
37
  # Register and set as the default for given extensions.
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  #
6
6
  class BlueCloth < Abstract
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # ERB template implementation.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Erubis template implementation.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Haml
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Discount Markdown implementation.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # LESS
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Liquid
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Radius Template
6
6
  #
@@ -2,7 +2,7 @@ require 'malt/engines/abstract'
2
2
  require 'malt/formats/rdoc'
3
3
  require 'malt/formats/html'
4
4
 
5
- module Malt::Engines
5
+ module Malt::Engine
6
6
 
7
7
  # Discount Markdown implementation.
8
8
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # RDoc template.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  #
6
6
  class RedCloth < Abstract
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # RTALS
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Ruby as a template engine.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Sass Malt Engine
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'malt/engines/abstract'
2
2
 
3
- module Malt::Engines
3
+ module Malt::Engine
4
4
 
5
5
  # Tenjin
6
6
  #
@@ -1,6 +1,6 @@
1
1
  module Malt
2
2
  #
3
- module Formats
3
+ module Format
4
4
  end
5
5
  end
6
6
 
@@ -1,7 +1,7 @@
1
1
  require 'malt/kernel'
2
2
 
3
3
  module Malt
4
- module Formats
4
+ module Format
5
5
 
6
6
  # Abstract format class serves as the base
7
7
  # class for all other format classes.
@@ -87,7 +87,9 @@ module Formats
87
87
  # it is taken to be the database for rendering template variables.
88
88
  def render(*type_and_data, &yld)
89
89
  type, data = parse_type_and_data(type_and_data)
90
- __send__(type || default, data, &yld)
90
+ meth = method(type || default)
91
+ #__send__(type || default, data, &yld)
92
+ meth.arity == 0 ? meth.call(&yld) : meth.call(data, &yld)
91
93
  end
92
94
 
93
95
  #
@@ -178,7 +180,7 @@ module Formats
178
180
 
179
181
  end
180
182
 
181
- #
183
+ # TODO: Is this needed anymore, if so where?
182
184
  class UnsupportedConversion < Exception
183
185
  def initialize(from_type, to_type)
184
186
  @from_type = from_type
@@ -0,0 +1,45 @@
1
+ require 'malt/formats/abstract'
2
+
3
+ module Malt
4
+ module Format
5
+
6
+ # An AbstractTemplate is a subclass of Abstract. It is used as the base class
7
+ # for general purpose template formats which can be used to render any other
8
+ # type of format.
9
+ class AbstractTemplate < Abstract
10
+
11
+ #
12
+ def to(type, data=nil, &yld)
13
+ new_class = Malt.registry[type.to_sym]
14
+ new_text = render(type, data, &yld)
15
+ new_file = refile(type)
16
+ new_options = options.merge(:text=>new_text, :file=>new_file, :type=>type)
17
+ new_class.new(new_options)
18
+ end
19
+
20
+ #
21
+ def render(*type_and_data, &yld)
22
+ type, data = parse_type_and_data(type_and_data)
23
+ opts = options.merge(:format=>type, :text=>text, :file=>file, :data=>data)
24
+ render_engine.render(opts, &yld)
25
+ #opts = options.merge(:format=>type, :text=>text, :file=>file, :data=>data, :engine=>engine)
26
+ #Malt.render(opts, &yld)
27
+ end
28
+
29
+ # ERB templates can be any type.
30
+ def method_missing(sym, *args, &yld)
31
+ if Malt.registry.key?(sym)
32
+ return render(sym, *args, &yld).to_s
33
+ elsif md = /^to_/.match(sym.to_s)
34
+ type = md.post_match.to_sym
35
+ if Malt.registry.key?(type)
36
+ return to(type, *args, &yld)
37
+ end
38
+ end
39
+ super(sym, *args, &yld)
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -1,6 +1,6 @@
1
1
  require 'malt/formats/abstract'
2
2
 
3
- module Malt::Formats
3
+ module Malt::Format
4
4
 
5
5
  #
6
6
  class CSS < Abstract
@@ -3,7 +3,7 @@ require 'malt/formats/html'
3
3
  require 'malt/engines/erb'
4
4
  require 'malt/engines/erubis'
5
5
 
6
- module Malt::Formats
6
+ module Malt::Format
7
7
 
8
8
  #
9
9
  class Erb < AbstractTemplate
@@ -90,9 +90,9 @@ module Malt::Formats
90
90
  @render_engine ||= (
91
91
  case engine
92
92
  when :erubis
93
- Malt::Engines::Erubis.new(options)
93
+ Malt::Engine::Erubis.new(options)
94
94
  else
95
- Malt::Engines::Erb.new(options)
95
+ Malt::Engine::Erb.new(options)
96
96
  end
97
97
  )
98
98
  end
@@ -2,7 +2,7 @@ require 'malt/formats/abstract'
2
2
  require 'malt/formats/html'
3
3
  require 'malt/engines/haml'
4
4
 
5
- module Malt::Formats
5
+ module Malt::Format
6
6
 
7
7
  # Haml looks like a Markup format, but it turns out to be
8
8
  # a template format too.
@@ -44,7 +44,7 @@ module Malt::Formats
44
44
 
45
45
  #
46
46
  def render_engine
47
- @render_engine ||= Malt::Engines::Haml.new(options)
47
+ @render_engine ||= Malt::Engine::Haml.new(options)
48
48
  end
49
49
 
50
50
  end
@@ -1,6 +1,6 @@
1
1
  require 'malt/formats/abstract'
2
2
 
3
- module Malt::Formats
3
+ module Malt::Format
4
4
 
5
5
  #
6
6
  class HTML < Abstract
@@ -1,7 +1,7 @@
1
1
  require 'malt/formats/abstract'
2
2
  require 'malt/formats/pdf'
3
3
 
4
- module Malt::Formats
4
+ module Malt::Format
5
5
 
6
6
  #
7
7
  class Latex < Abstract
@@ -1,7 +1,7 @@
1
1
  require 'malt/formats/abstract'
2
2
  require 'malt/engines/less'
3
3
 
4
- module Malt::Formats
4
+ module Malt::Format
5
5
 
6
6
  # = LESS
7
7
  #
@@ -37,7 +37,7 @@ module Malt::Formats
37
37
 
38
38
  #
39
39
  def render_engine
40
- @render_engine ||= Malt::Engines::Less.new(options)
40
+ @render_engine ||= Malt::Engine::Less.new(options)
41
41
  end
42
42
 
43
43
  # LESS default output type is CSS.