gohanlonllc-haml 2.1.0

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.
Files changed (173) hide show
  1. data/README.rdoc +332 -0
  2. data/Rakefile +250 -0
  3. data/VERSION.yml +4 -0
  4. data/bin/css2sass +7 -0
  5. data/bin/haml +9 -0
  6. data/bin/html2haml +7 -0
  7. data/bin/sass +8 -0
  8. data/lib/haml/buffer.rb +255 -0
  9. data/lib/haml/engine.rb +268 -0
  10. data/lib/haml/error.rb +22 -0
  11. data/lib/haml/exec.rb +403 -0
  12. data/lib/haml/filters.rb +275 -0
  13. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  14. data/lib/haml/helpers/action_view_mods.rb +181 -0
  15. data/lib/haml/helpers.rb +488 -0
  16. data/lib/haml/html.rb +219 -0
  17. data/lib/haml/precompiler.rb +904 -0
  18. data/lib/haml/shared.rb +47 -0
  19. data/lib/haml/template/patch.rb +58 -0
  20. data/lib/haml/template/plugin.rb +72 -0
  21. data/lib/haml/template.rb +42 -0
  22. data/lib/haml/util.rb +93 -0
  23. data/lib/haml/version.rb +46 -0
  24. data/lib/haml.rb +1044 -0
  25. data/lib/sass/css.rb +337 -0
  26. data/lib/sass/engine.rb +439 -0
  27. data/lib/sass/environment.rb +48 -0
  28. data/lib/sass/error.rb +42 -0
  29. data/lib/sass/files.rb +100 -0
  30. data/lib/sass/plugin/merb.rb +57 -0
  31. data/lib/sass/plugin/rails.rb +25 -0
  32. data/lib/sass/plugin.rb +203 -0
  33. data/lib/sass/repl.rb +51 -0
  34. data/lib/sass/script/bool.rb +13 -0
  35. data/lib/sass/script/color.rb +97 -0
  36. data/lib/sass/script/funcall.rb +29 -0
  37. data/lib/sass/script/functions.rb +134 -0
  38. data/lib/sass/script/lexer.rb +148 -0
  39. data/lib/sass/script/literal.rb +82 -0
  40. data/lib/sass/script/number.rb +231 -0
  41. data/lib/sass/script/operation.rb +30 -0
  42. data/lib/sass/script/parser.rb +142 -0
  43. data/lib/sass/script/string.rb +9 -0
  44. data/lib/sass/script/unary_operation.rb +21 -0
  45. data/lib/sass/script/variable.rb +20 -0
  46. data/lib/sass/script.rb +38 -0
  47. data/lib/sass/tree/attr_node.rb +72 -0
  48. data/lib/sass/tree/comment_node.rb +39 -0
  49. data/lib/sass/tree/debug_node.rb +22 -0
  50. data/lib/sass/tree/directive_node.rb +51 -0
  51. data/lib/sass/tree/file_node.rb +27 -0
  52. data/lib/sass/tree/for_node.rb +29 -0
  53. data/lib/sass/tree/if_node.rb +32 -0
  54. data/lib/sass/tree/mixin_def_node.rb +18 -0
  55. data/lib/sass/tree/mixin_node.rb +35 -0
  56. data/lib/sass/tree/node.rb +117 -0
  57. data/lib/sass/tree/rule_node.rb +161 -0
  58. data/lib/sass/tree/variable_node.rb +24 -0
  59. data/lib/sass/tree/while_node.rb +21 -0
  60. data/lib/sass.rb +1070 -0
  61. data/rails/init.rb +1 -0
  62. data/test/benchmark.rb +99 -0
  63. data/test/haml/engine_test.rb +795 -0
  64. data/test/haml/helper_test.rb +233 -0
  65. data/test/haml/html2haml_test.rb +108 -0
  66. data/test/haml/markaby/standard.mab +52 -0
  67. data/test/haml/mocks/article.rb +6 -0
  68. data/test/haml/results/content_for_layout.xhtml +15 -0
  69. data/test/haml/results/eval_suppressed.xhtml +9 -0
  70. data/test/haml/results/filters.xhtml +62 -0
  71. data/test/haml/results/helpers.xhtml +93 -0
  72. data/test/haml/results/helpful.xhtml +10 -0
  73. data/test/haml/results/just_stuff.xhtml +68 -0
  74. data/test/haml/results/list.xhtml +12 -0
  75. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  76. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  77. data/test/haml/results/original_engine.xhtml +20 -0
  78. data/test/haml/results/partial_layout.xhtml +5 -0
  79. data/test/haml/results/partials.xhtml +21 -0
  80. data/test/haml/results/render_layout.xhtml +3 -0
  81. data/test/haml/results/silent_script.xhtml +74 -0
  82. data/test/haml/results/standard.xhtml +162 -0
  83. data/test/haml/results/tag_parsing.xhtml +23 -0
  84. data/test/haml/results/very_basic.xhtml +5 -0
  85. data/test/haml/results/whitespace_handling.xhtml +89 -0
  86. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  87. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  88. data/test/haml/rhtml/action_view.rhtml +62 -0
  89. data/test/haml/rhtml/standard.rhtml +54 -0
  90. data/test/haml/template_test.rb +204 -0
  91. data/test/haml/templates/_av_partial_1.haml +9 -0
  92. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  93. data/test/haml/templates/_av_partial_2.haml +5 -0
  94. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  95. data/test/haml/templates/_layout.erb +3 -0
  96. data/test/haml/templates/_layout_for_partial.haml +3 -0
  97. data/test/haml/templates/_partial.haml +8 -0
  98. data/test/haml/templates/_text_area.haml +3 -0
  99. data/test/haml/templates/action_view.haml +47 -0
  100. data/test/haml/templates/action_view_ugly.haml +47 -0
  101. data/test/haml/templates/breakage.haml +8 -0
  102. data/test/haml/templates/content_for_layout.haml +10 -0
  103. data/test/haml/templates/eval_suppressed.haml +11 -0
  104. data/test/haml/templates/filters.haml +66 -0
  105. data/test/haml/templates/helpers.haml +95 -0
  106. data/test/haml/templates/helpful.haml +11 -0
  107. data/test/haml/templates/just_stuff.haml +83 -0
  108. data/test/haml/templates/list.haml +12 -0
  109. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  110. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  111. data/test/haml/templates/original_engine.haml +17 -0
  112. data/test/haml/templates/partial_layout.haml +3 -0
  113. data/test/haml/templates/partialize.haml +1 -0
  114. data/test/haml/templates/partials.haml +12 -0
  115. data/test/haml/templates/render_layout.haml +2 -0
  116. data/test/haml/templates/silent_script.haml +40 -0
  117. data/test/haml/templates/standard.haml +42 -0
  118. data/test/haml/templates/standard_ugly.haml +42 -0
  119. data/test/haml/templates/tag_parsing.haml +21 -0
  120. data/test/haml/templates/very_basic.haml +4 -0
  121. data/test/haml/templates/whitespace_handling.haml +87 -0
  122. data/test/haml/util_test.rb +92 -0
  123. data/test/linked_rails.rb +12 -0
  124. data/test/sass/css2sass_test.rb +215 -0
  125. data/test/sass/engine_test.rb +773 -0
  126. data/test/sass/functions_test.rb +109 -0
  127. data/test/sass/more_results/more1.css +9 -0
  128. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  129. data/test/sass/more_results/more_import.css +29 -0
  130. data/test/sass/more_templates/_more_partial.sass +2 -0
  131. data/test/sass/more_templates/more1.sass +23 -0
  132. data/test/sass/more_templates/more_import.sass +11 -0
  133. data/test/sass/plugin_test.rb +214 -0
  134. data/test/sass/results/alt.css +4 -0
  135. data/test/sass/results/basic.css +9 -0
  136. data/test/sass/results/compact.css +5 -0
  137. data/test/sass/results/complex.css +87 -0
  138. data/test/sass/results/compressed.css +1 -0
  139. data/test/sass/results/expanded.css +19 -0
  140. data/test/sass/results/import.css +29 -0
  141. data/test/sass/results/line_numbers.css +49 -0
  142. data/test/sass/results/mixins.css +95 -0
  143. data/test/sass/results/multiline.css +24 -0
  144. data/test/sass/results/nested.css +22 -0
  145. data/test/sass/results/parent_ref.css +13 -0
  146. data/test/sass/results/script.css +16 -0
  147. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  148. data/test/sass/results/subdir/subdir.css +3 -0
  149. data/test/sass/results/units.css +11 -0
  150. data/test/sass/script_test.rb +250 -0
  151. data/test/sass/templates/_partial.sass +2 -0
  152. data/test/sass/templates/alt.sass +16 -0
  153. data/test/sass/templates/basic.sass +23 -0
  154. data/test/sass/templates/bork.sass +2 -0
  155. data/test/sass/templates/bork2.sass +2 -0
  156. data/test/sass/templates/compact.sass +17 -0
  157. data/test/sass/templates/complex.sass +309 -0
  158. data/test/sass/templates/compressed.sass +15 -0
  159. data/test/sass/templates/expanded.sass +17 -0
  160. data/test/sass/templates/import.sass +11 -0
  161. data/test/sass/templates/importee.sass +19 -0
  162. data/test/sass/templates/line_numbers.sass +13 -0
  163. data/test/sass/templates/mixins.sass +76 -0
  164. data/test/sass/templates/multiline.sass +20 -0
  165. data/test/sass/templates/nested.sass +25 -0
  166. data/test/sass/templates/parent_ref.sass +25 -0
  167. data/test/sass/templates/script.sass +101 -0
  168. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  169. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  170. data/test/sass/templates/subdir/subdir.sass +6 -0
  171. data/test/sass/templates/units.sass +11 -0
  172. data/test/test_helper.rb +27 -0
  173. metadata +241 -0
data/README.rdoc ADDED
@@ -0,0 +1,332 @@
1
+ = Haml and Sass
2
+
3
+ Haml and Sass are templating engines
4
+ for the two most common types of documents on the web:
5
+ HTML and CSS, respectively.
6
+ They are designed to make it both easier and more pleasant
7
+ to code HTML and CSS documents,
8
+ by eliminating redundancy,
9
+ reflecting the underlying structure that the document represents,
10
+ and providing elegant, easily understandable, and powerful syntax.
11
+
12
+ == Using
13
+
14
+ There are several ways to use Haml and Sass.
15
+ They can be used as a plugin for Rails or Merb,
16
+ or embedded on their own in other applications.
17
+ The first step of all of these is to install the Haml gem:
18
+
19
+ gem install haml
20
+
21
+ To install Haml and Sass as a Rails plugin,
22
+ just run <tt>haml --rails path/to/rails/app</tt>
23
+ and both Haml and Sass will be installed.
24
+ Views with the <tt>.haml</tt> (or <tt>.html.haml</tt> for edge)
25
+ extension will automatically use Haml.
26
+ Sass is a little more complicated;
27
+ <tt>.sass</tt> files should be placed in public/stylesheets/sass,
28
+ where they'll be automatically compiled
29
+ to corresponding CSS files in public/stylesheets when needed
30
+ (the Sass template directory is customizable...
31
+ see the Sass module docs for details).
32
+
33
+ For Merb, <tt>.html.haml</tt> views will work without any further modification.
34
+ To enable Sass, you also need to add a dependency.
35
+ To do so, just add
36
+
37
+ dependency "merb-haml"
38
+
39
+ to config/dependencies.rb (or config/init.rb in a flat/very flat Merb application).
40
+ Then it'll work just like it does in Rails.
41
+
42
+ To use Haml and Sass programatically,
43
+ check out the RDocs for the Haml and Sass modules.
44
+
45
+ == Formatting
46
+
47
+ === Haml
48
+
49
+ The most basic element of Haml
50
+ is a shorthand for creating HTML tags:
51
+
52
+ %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents
53
+
54
+ No end-tag is needed; Haml handles that automatically.
55
+ Adding <tt>class</tt> and <tt>id</tt> attributes is even easier.
56
+ Haml uses the same syntax as the CSS that styles the document:
57
+
58
+ %tagname#id.class
59
+
60
+ In fact, when you're using the <tt><div></tt> tag,
61
+ it becomes <em>even easier</em>.
62
+ Because <tt><div></tt> is such a common element,
63
+ a tag without a name defaults to a div. So
64
+
65
+ #foo Hello!
66
+
67
+ becomes
68
+
69
+ <div id='foo'>Hello!</div>
70
+
71
+ Haml uses indentation
72
+ to bring the individual elements to represent the HTML structure.
73
+ A tag's children are indented beneath than the parent tag.
74
+ Again, a closing tag is automatically added.
75
+ For example:
76
+
77
+ %ul
78
+ %li Salt
79
+ %li Pepper
80
+
81
+ becomes:
82
+
83
+ <ul>
84
+ <li>Salt</li>
85
+ <li>Pepper</li>
86
+ </ul>
87
+
88
+ You can also put plain text as a child of an element:
89
+
90
+ %p
91
+ Hello,
92
+ World!
93
+
94
+ It's also possible to embed Ruby code into Haml documents.
95
+ An equals sign, <tt>=</tt>, will output the result of the code.
96
+ A hyphen, <tt>-</tt>, will run the code but not output the result.
97
+ You can even use control statements
98
+ like <tt>if</tt> and <tt>while</tt>:
99
+
100
+ %p
101
+ Date/Time:
102
+ - now = DateTime.now
103
+ %strong= now
104
+ - if now > DateTime.parse("December 31, 2006")
105
+ = "Happy new " + "year!"
106
+
107
+ Haml provides far more tools than those presented here.
108
+ Check out the reference documentation in the Haml module.
109
+
110
+ === Sass
111
+
112
+ At its most basic,
113
+ Sass is just another way of writing CSS.
114
+ Although it's very much like normal CSS,
115
+ the basic syntax offers a few helpful features:
116
+ tabulation indicates the attributes in a rule,
117
+ rather than non-DRY brackets;
118
+ and newlines indicate the end of an attribute,
119
+ rather than a semicolon.
120
+ For example:
121
+
122
+ #main
123
+ :background-color #f00
124
+ :width 98%
125
+
126
+ becomes:
127
+
128
+ #main {
129
+ background-color: #f00;
130
+ width: 98% }
131
+
132
+ However, Sass provides much more than a way to make CSS look nice.
133
+ In CSS, it's important to have accurate selectors,
134
+ so your styles don't just apply to everything.
135
+ However, in order to do this,
136
+ you need to use nested element selectors.
137
+ These get very ugly very quickly.
138
+ I'm sure everyone's had to write something like
139
+ "#main .sidebar .top p h1 a",
140
+ followed by
141
+ "#main .sidebar .top p h1 a:visited" and
142
+ "#main .sidebar .top p h1 a:hover".
143
+ Well, Sass gets rid of that.
144
+ Like Haml, it uses indentation to indicate the structure of the document.
145
+ So, what was:
146
+
147
+ #main {
148
+ width: 90%;
149
+ }
150
+ #main p {
151
+ border-style: solid;
152
+ border-width: 1px;
153
+ border-color: #00f;
154
+ }
155
+ #main p a {
156
+ text-decoration: none;
157
+ font-weight: bold;
158
+ }
159
+ #main p a:hover {
160
+ text-decoration: underline;
161
+ }
162
+
163
+ becomes:
164
+
165
+ #main
166
+ :width 90%
167
+ p
168
+ :border-style solid
169
+ :border-width 1px
170
+ :border-color #00f
171
+ a
172
+ :text-decoration none
173
+ :font-weight bold
174
+ a:hover
175
+ :text-decoration underline
176
+
177
+ Pretty nice, no? Well, it gets better.
178
+ One of the main complaints against CSS is that it doesn't allow variables.
179
+ What if have a color or a width you re-use all the time?
180
+ In CSS, you just have to re-type it each time,
181
+ which is a nightmare when you decide to change it later.
182
+ Not so for Sass!
183
+ You can use the "!" character to set variables.
184
+ Then, if you put "=" after your attribute name,
185
+ you can set it to a variable.
186
+ For example:
187
+
188
+ !note_bg= #55aaff
189
+
190
+ #main
191
+ :width 70%
192
+ .note
193
+ :background-color= !note_bg
194
+ p
195
+ :width 5em
196
+ :background-color= !note_bg
197
+
198
+ becomes:
199
+
200
+ #main {
201
+ width: 70%; }
202
+ #main .note {
203
+ background-color: #55aaff; }
204
+ #main p {
205
+ width: 5em;
206
+ background-color: #55aaff; }
207
+
208
+ You can even do simple arithmetic operations with variables,
209
+ adding numbers and even colors together:
210
+
211
+ !main_bg= #46ar12
212
+ !main_width= 40em
213
+
214
+ #main
215
+ :background-color= !main_bg
216
+ :width= !main_width
217
+ .sidebar
218
+ :background-color= !main_bg + #333333
219
+ :width= !main_width - 25em
220
+
221
+ becomes:
222
+
223
+ #main {
224
+ background-color: #46a312;
225
+ width: 40em; }
226
+ #main .sidebar {
227
+ background-color: #79d645;
228
+ width: 15em; }
229
+
230
+ Taking the idea of variables a bit further are mixins.
231
+ These let you group whole swathes of CSS attributes into a single
232
+ directive and then include those anywhere you want:
233
+
234
+ =blue-border
235
+ :border
236
+ :color blue
237
+ :width 2px
238
+ :style dotted
239
+
240
+ .comment
241
+ +blue-border
242
+ :padding 2px
243
+ :margin 10px 0
244
+
245
+ .reply
246
+ +blue-border
247
+
248
+ becomes:
249
+
250
+ .comment {
251
+ border-color: blue;
252
+ border-width: 2px;
253
+ border-style: dotted;
254
+ padding: 2px;
255
+ margin: 10px 0;
256
+ }
257
+
258
+ .reply {
259
+ border-color: blue;
260
+ border-width: 2px;
261
+ border-style: dotted;
262
+ }
263
+
264
+ A comprehensive list of features is in
265
+ the documentation for the Sass module.
266
+
267
+ == Indentation
268
+
269
+ Indentation can be made up of one or more tabs or spaces.
270
+ However, indentation must be consistent within a given document.
271
+ Hard tabs and spaces can't be mixed,
272
+ and the same number of tabs or spaces must be used throughout.
273
+
274
+ == Executables
275
+
276
+ The Haml gem includes several executables that are useful
277
+ for dealing with Haml and Sass from the command line.
278
+
279
+ === +haml+
280
+
281
+ The +haml+ executable transforms a source Haml file into HTML.
282
+ See <tt>haml --help</tt> for further information and options.
283
+
284
+ === +sass+
285
+
286
+ The +sass+ executable transforms a source Sass file into CSS.
287
+ See <tt>sass --help</tt> for further information and options.
288
+
289
+ === <tt>html2haml</tt>
290
+
291
+ The <tt>html2haml</tt> executable attempts to transform HTML,
292
+ optionally with ERB markup, into Haml code.
293
+ Since HTML is so variable, this transformation is not always perfect;
294
+ it's a good idea to have a human check the output of this tool.
295
+ See <tt>html2haml --help</tt> for further information and options.
296
+
297
+ === <tt>css2sass</tt>
298
+
299
+ The <tt>css2sass</tt> executable attempts to transform CSS into Sass code.
300
+ This transformation attempts to use Sass nesting where possible.
301
+ See <tt>css2sass --help</tt> for further information and options.
302
+
303
+ == Authors
304
+
305
+ Haml and Sass are designed by Hampton Catlin (hcatlin) and he is the author
306
+ of the original implementation. However, Hampton doesn't even know his way
307
+ around the code anymore and mostly just concentrates on the language issues.
308
+ Hampton lives in Toronto, Ontario (though he's an American by birth) and
309
+ is a partner at Unspace Interactive.
310
+
311
+ Nathan Weizenbaum is the primary maintainer and architect of the "modern" Ruby
312
+ implementation of Haml. His hard work has kept the project alive by endlessly
313
+ answering forum posts, fixing bugs, refactoring, finding speed improvements,
314
+ writing documentation, implementing new features, and getting Hampton
315
+ coffee (a fitting task for a boy-genius). Nathan lives in Seattle, Washington and
316
+ while not being a student at University of Washington he consults for
317
+ Unspace Interactive and Microsoft.
318
+
319
+ Chris Eppstein is a core contributor to Sass and the creator of Compass, the first
320
+ Sass-based framework. Chris focuses on making Sass more powerful, easy to use, and
321
+ on ways to speed its adoption through the web development community. Chris lives in
322
+ San Jose, CA with his wife and daughter. He is the Software Architect for Caring.com,
323
+ a website devoted to the 34 Million caregivers whose parents are sick or elderly,
324
+ that uses Haml and Sass.
325
+
326
+ If you use this software, you must pay Hampton a compliment. And
327
+ buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty.
328
+
329
+ Some of the work on Haml was supported by Unspace Interactive.
330
+
331
+ Beyond that, the implementation is licensed under the MIT License.
332
+ Ok, fine, I guess that means compliments aren't *required*.
data/Rakefile ADDED
@@ -0,0 +1,250 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |spec|
7
+ spec.name = 'haml'
8
+ spec.summary = "An elegant, structured XHTML/XML templating engine.\nComes with Sass, a similar CSS templating engine."
9
+ spec.authors = ['Nathan Weizenbaum', 'Hampton Catlin']
10
+ spec.email = 'haml@googlegroups.com'
11
+ spec.description = <<-END
12
+ Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML
13
+ that's designed to express the structure of XHTML or XML documents
14
+ in a non-repetitive, elegant, easy way,
15
+ using indentation rather than closing tags
16
+ and allowing Ruby to be embedded with ease.
17
+ It was originally envisioned as a plugin for Ruby on Rails,
18
+ but it can function as a stand-alone templating engine.
19
+ END
20
+
21
+ spec.executables = ['haml', 'html2haml', 'sass', 'css2sass']
22
+ spec.homepage = 'http://haml.hamptoncatlin.com/'
23
+ end
24
+ rescue LoadError
25
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
26
+ end
27
+
28
+ # ----- Benchmarking -----
29
+
30
+ desc <<END
31
+ Benchmark haml against ERb.
32
+ TIMES=n sets the number of runs. Defaults to 1000.
33
+ END
34
+ task :benchmark do
35
+ sh "ruby test/benchmark.rb #{ENV['TIMES']}"
36
+ end
37
+
38
+ # ----- Default: Testing ------
39
+
40
+ if ENV["RUN_CODE_RUN"] == "true"
41
+ task :default => :"test:rails_compatibility"
42
+ else
43
+ task :default => :test
44
+ end
45
+
46
+ require 'rake/testtask'
47
+
48
+ Rake::TestTask.new do |t|
49
+ t.libs << 'lib'
50
+ test_files = FileList['test/**/*_test.rb']
51
+ test_files.exclude('test/rails/*')
52
+ t.test_files = test_files
53
+ t.verbose = true
54
+ end
55
+ Rake::Task[:test].send(:add_comment, <<END)
56
+ To run with an alternate version of Rails, make test/rails a symlink to that version.
57
+ END
58
+
59
+ # ----- Packaging -----
60
+
61
+ # require 'rake/gempackagetask'
62
+ # load 'haml.gemspec'
63
+ #
64
+ # Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
65
+ # if Rake.application.top_level_tasks.include?('release')
66
+ # pkg.need_tar_gz = true
67
+ # pkg.need_tar_bz2 = true
68
+ # pkg.need_zip = true
69
+ # end
70
+ # end
71
+ #
72
+ # task :revision_file do
73
+ # require 'lib/haml'
74
+ #
75
+ # release = Rake.application.top_level_tasks.include?('release') || File.exist?('EDGE_GEM_VERSION')
76
+ # if Haml.version[:rev] && !release
77
+ # File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] }
78
+ # elsif release
79
+ # File.open('REVISION', 'w') { |f| f.puts "(release)" }
80
+ # else
81
+ # File.open('REVISION', 'w') { |f| f.puts "(unknown)" }
82
+ # end
83
+ # end
84
+ # Rake::Task[:package].prerequisites.insert(0, :revision_file)
85
+
86
+ # We also need to get rid of this file after packaging.
87
+ at_exit { File.delete('REVISION') rescue nil }
88
+
89
+ desc "Install Haml as a gem."
90
+ task :install => [:package] do
91
+ sudo = RUBY_PLATFORM =~ /win32/ ? '' : 'sudo'
92
+ gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
93
+ sh %{#{sudo} #{gem} install --no-ri pkg/haml-#{File.read('VERSION').strip}}
94
+ end
95
+
96
+ desc "Release a new Haml package to Rubyforge. Requires the NAME and VERSION flags."
97
+ task :release => [:package] do
98
+ name, version = ENV['NAME'], ENV['VERSION']
99
+ raise "Must supply NAME and VERSION for release task." unless name && version
100
+ sh %{rubyforge login}
101
+ sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
102
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
103
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
104
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
105
+ end
106
+
107
+ task :release_edge do
108
+ sh %{git checkout edge-gem}
109
+ sh %{git fetch origin}
110
+ sh %{git merge origin/edge-gem}
111
+ sh %{git merge origin/master}
112
+
113
+ # Get the current master branch version
114
+ version = File.read('VERSION').strip.split('.').map {|n| n.to_i}
115
+ unless version[1] % 2 == 1 && version[2] == 0
116
+ raise "#{version.join('.')} is not a development version"
117
+ end
118
+
119
+ # Bump the edge gem version
120
+ edge_version = File.read('EDGE_GEM_VERSION').strip.split('.').map {|n| n.to_i}
121
+ if edge_version[0..1] != version[0..1]
122
+ # A new master branch version was released, reset the edge gem version
123
+ edge_version[0..1] = version[0..1]
124
+ edge_version[2] = 0
125
+ else
126
+ # Just bump the teeny version
127
+ edge_version[2] += 1
128
+ end
129
+ edge_version = edge_version.join('.')
130
+ File.open('EDGE_GEM_VERSION', 'w') {|f| f.puts(edge_version)}
131
+ sh %{git commit -m "Bump edge gem version." EDGE_GEM_VERSION}
132
+ sh %{git push origin edge-gem}
133
+
134
+ # Package the edge gem with the proper version
135
+ File.open('VERSION', 'w') {|f| f.puts(edge_version)}
136
+ sh %{rake package}
137
+ sh %{git checkout VERSION}
138
+
139
+ sh %{rubyforge login}
140
+ sh %{rubyforge add_release haml haml-edge "Bleeding Edge (v#{edge_version})" pkg/haml-edge-#{edge_version}.gem}
141
+ end
142
+
143
+ task :watch_for_edge_update do
144
+ sh %{ruby extra/edge_gem_watch.rb}
145
+ end
146
+
147
+ # ----- Documentation -----
148
+
149
+ begin
150
+ require 'hanna/rdoctask'
151
+ rescue LoadError
152
+ require 'rake/rdoctask'
153
+ end
154
+
155
+ Rake::RDocTask.new do |rdoc|
156
+ rdoc.title = 'Haml/Sass'
157
+ rdoc.options << '--line-numbers' << '--inline-source'
158
+ rdoc.rdoc_files.include(*FileList.new('*') do |list|
159
+ list.exclude(/(^|[^.a-z])[a-z]+/)
160
+ list.exclude('TODO')
161
+ end.to_a)
162
+ rdoc.rdoc_files.include('lib/**/*.rb')
163
+ rdoc.rdoc_files.exclude('TODO')
164
+ rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
165
+ rdoc.rdoc_files.exclude('lib/sass/tree/*')
166
+ rdoc.rdoc_dir = 'rdoc'
167
+ rdoc.main = 'README.rdoc'
168
+ end
169
+
170
+ # ----- Coverage -----
171
+
172
+ begin
173
+ require 'rcov/rcovtask'
174
+
175
+ Rcov::RcovTask.new do |t|
176
+ t.test_files = FileList['test/**/*_test.rb']
177
+ t.rcov_opts << '-x' << '"^\/"'
178
+ if ENV['NON_NATIVE']
179
+ t.rcov_opts << "--no-rcovrt"
180
+ end
181
+ t.verbose = true
182
+ end
183
+ rescue LoadError; end
184
+
185
+ # ----- Profiling -----
186
+
187
+ begin
188
+ require 'ruby-prof'
189
+
190
+ desc <<END
191
+ Run a profile of haml.
192
+ ENGINE=str sets the engine to be profiled. Defaults to Haml.
193
+ TIMES=n sets the number of runs. Defaults to 1000.
194
+ FILE=str sets the file to profile.
195
+ Defaults to 'standard' for Haml and 'complex' for Sass.
196
+ OUTPUT=str sets the ruby-prof output format.
197
+ Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
198
+ END
199
+ task :profile do
200
+ engine = (ENV['ENGINE'] || 'haml').downcase
201
+ times = (ENV['TIMES'] || '1000').to_i
202
+ file = ENV['FILE']
203
+
204
+ if engine == 'sass'
205
+ require 'lib/sass'
206
+
207
+ file = File.read("#{File.dirname(__FILE__)}/test/sass/templates/#{file || 'complex'}.sass")
208
+ result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
209
+ else
210
+ require 'lib/haml'
211
+
212
+ file = File.read("#{File.dirname(__FILE__)}/test/haml/templates/#{file || 'standard'}.haml")
213
+ obj = Object.new
214
+ Haml::Engine.new(file).def_method(obj, :render)
215
+ result = RubyProf.profile { times.times { obj.render } }
216
+ end
217
+
218
+ RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
219
+ end
220
+ rescue LoadError; end
221
+
222
+ # ----- Testing Multiple Rails Versions -----
223
+
224
+ rails_versions = [
225
+ "v2.3.0",
226
+ "v2.2.2",
227
+ "v2.1.2",
228
+ "v2.0.5"
229
+ ]
230
+
231
+ namespace :test do
232
+ desc "Test all supported versions of rails. This takes a while."
233
+ task :rails_compatibility do
234
+ `rm -rf test/rails`
235
+ puts "Checking out rails. Please wait."
236
+ `git clone git://github.com/rails/rails.git test/rails` rescue nil
237
+ begin
238
+ rails_versions.each do |version|
239
+ Dir.chdir "test/rails" do
240
+ `git checkout #{version}`
241
+ end
242
+ puts "Testing Rails #{version}"
243
+ Rake::Task['test'].reenable
244
+ Rake::Task['test'].execute
245
+ end
246
+ ensure
247
+ `rm -rf test/rails`
248
+ end
249
+ end
250
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 2
3
+ :minor: 1
4
+ :patch: 0
data/bin/css2sass ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../lib/haml'
4
+ require 'haml/exec'
5
+
6
+ opts = Haml::Exec::CSS2Sass.new(ARGV)
7
+ opts.parse!
data/bin/haml ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # The command line Haml parser.
3
+
4
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
5
+ require 'haml'
6
+ require 'haml/exec'
7
+
8
+ opts = Haml::Exec::Haml.new(ARGV)
9
+ opts.parse!
data/bin/html2haml ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../lib/haml'
4
+ require 'haml/exec'
5
+
6
+ opts = Haml::Exec::HTML2Haml.new(ARGV)
7
+ opts.parse!
data/bin/sass ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # The command line Sass parser.
3
+
4
+ require File.dirname(__FILE__) + '/../lib/haml'
5
+ require 'haml/exec'
6
+
7
+ opts = Haml::Exec::Sass.new(ARGV)
8
+ opts.parse!