haml-edge 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/EDGE_GEM_VERSION +1 -0
  2. data/FAQ +138 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +332 -0
  5. data/REVISION +1 -0
  6. data/Rakefile +226 -0
  7. data/VERSION +1 -0
  8. data/bin/css2sass +7 -0
  9. data/bin/haml +9 -0
  10. data/bin/html2haml +7 -0
  11. data/bin/sass +8 -0
  12. data/extra/edge_gem_watch.rb +13 -0
  13. data/extra/haml-mode.el +596 -0
  14. data/extra/sass-mode.el +200 -0
  15. data/init.rb +8 -0
  16. data/lib/haml/buffer.rb +255 -0
  17. data/lib/haml/engine.rb +268 -0
  18. data/lib/haml/error.rb +22 -0
  19. data/lib/haml/exec.rb +395 -0
  20. data/lib/haml/filters.rb +275 -0
  21. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  22. data/lib/haml/helpers/action_view_mods.rb +181 -0
  23. data/lib/haml/helpers.rb +488 -0
  24. data/lib/haml/html.rb +222 -0
  25. data/lib/haml/precompiler.rb +904 -0
  26. data/lib/haml/shared.rb +45 -0
  27. data/lib/haml/template/patch.rb +58 -0
  28. data/lib/haml/template/plugin.rb +72 -0
  29. data/lib/haml/template.rb +42 -0
  30. data/lib/haml/util.rb +88 -0
  31. data/lib/haml/version.rb +47 -0
  32. data/lib/haml.rb +1044 -0
  33. data/lib/sass/css.rb +388 -0
  34. data/lib/sass/engine.rb +495 -0
  35. data/lib/sass/environment.rb +46 -0
  36. data/lib/sass/error.rb +35 -0
  37. data/lib/sass/plugin/merb.rb +56 -0
  38. data/lib/sass/plugin/rails.rb +24 -0
  39. data/lib/sass/plugin.rb +204 -0
  40. data/lib/sass/repl.rb +51 -0
  41. data/lib/sass/script/bool.rb +13 -0
  42. data/lib/sass/script/color.rb +97 -0
  43. data/lib/sass/script/funcall.rb +29 -0
  44. data/lib/sass/script/functions.rb +134 -0
  45. data/lib/sass/script/lexer.rb +148 -0
  46. data/lib/sass/script/literal.rb +82 -0
  47. data/lib/sass/script/number.rb +231 -0
  48. data/lib/sass/script/operation.rb +30 -0
  49. data/lib/sass/script/parser.rb +142 -0
  50. data/lib/sass/script/string.rb +9 -0
  51. data/lib/sass/script/unary_operation.rb +21 -0
  52. data/lib/sass/script/variable.rb +20 -0
  53. data/lib/sass/script.rb +38 -0
  54. data/lib/sass/tree/attr_node.rb +64 -0
  55. data/lib/sass/tree/comment_node.rb +30 -0
  56. data/lib/sass/tree/debug_node.rb +22 -0
  57. data/lib/sass/tree/directive_node.rb +50 -0
  58. data/lib/sass/tree/file_node.rb +27 -0
  59. data/lib/sass/tree/for_node.rb +29 -0
  60. data/lib/sass/tree/if_node.rb +27 -0
  61. data/lib/sass/tree/mixin_def_node.rb +18 -0
  62. data/lib/sass/tree/mixin_node.rb +35 -0
  63. data/lib/sass/tree/node.rb +99 -0
  64. data/lib/sass/tree/rule_node.rb +161 -0
  65. data/lib/sass/tree/variable_node.rb +24 -0
  66. data/lib/sass/tree/while_node.rb +21 -0
  67. data/lib/sass.rb +1062 -0
  68. data/rails/init.rb +1 -0
  69. data/test/benchmark.rb +99 -0
  70. data/test/haml/engine_test.rb +795 -0
  71. data/test/haml/helper_test.rb +228 -0
  72. data/test/haml/html2haml_test.rb +108 -0
  73. data/test/haml/markaby/standard.mab +52 -0
  74. data/test/haml/mocks/article.rb +6 -0
  75. data/test/haml/results/content_for_layout.xhtml +15 -0
  76. data/test/haml/results/eval_suppressed.xhtml +9 -0
  77. data/test/haml/results/filters.xhtml +62 -0
  78. data/test/haml/results/helpers.xhtml +93 -0
  79. data/test/haml/results/helpful.xhtml +10 -0
  80. data/test/haml/results/just_stuff.xhtml +68 -0
  81. data/test/haml/results/list.xhtml +12 -0
  82. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  83. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  84. data/test/haml/results/original_engine.xhtml +20 -0
  85. data/test/haml/results/partial_layout.xhtml +5 -0
  86. data/test/haml/results/partials.xhtml +21 -0
  87. data/test/haml/results/render_layout.xhtml +3 -0
  88. data/test/haml/results/silent_script.xhtml +74 -0
  89. data/test/haml/results/standard.xhtml +162 -0
  90. data/test/haml/results/tag_parsing.xhtml +23 -0
  91. data/test/haml/results/very_basic.xhtml +5 -0
  92. data/test/haml/results/whitespace_handling.xhtml +89 -0
  93. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  94. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  95. data/test/haml/rhtml/action_view.rhtml +62 -0
  96. data/test/haml/rhtml/standard.rhtml +54 -0
  97. data/test/haml/template_test.rb +204 -0
  98. data/test/haml/templates/_av_partial_1.haml +9 -0
  99. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  100. data/test/haml/templates/_av_partial_2.haml +5 -0
  101. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  102. data/test/haml/templates/_layout.erb +3 -0
  103. data/test/haml/templates/_layout_for_partial.haml +3 -0
  104. data/test/haml/templates/_partial.haml +8 -0
  105. data/test/haml/templates/_text_area.haml +3 -0
  106. data/test/haml/templates/action_view.haml +47 -0
  107. data/test/haml/templates/action_view_ugly.haml +47 -0
  108. data/test/haml/templates/breakage.haml +8 -0
  109. data/test/haml/templates/content_for_layout.haml +10 -0
  110. data/test/haml/templates/eval_suppressed.haml +11 -0
  111. data/test/haml/templates/filters.haml +66 -0
  112. data/test/haml/templates/helpers.haml +95 -0
  113. data/test/haml/templates/helpful.haml +11 -0
  114. data/test/haml/templates/just_stuff.haml +83 -0
  115. data/test/haml/templates/list.haml +12 -0
  116. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  117. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  118. data/test/haml/templates/original_engine.haml +17 -0
  119. data/test/haml/templates/partial_layout.haml +3 -0
  120. data/test/haml/templates/partialize.haml +1 -0
  121. data/test/haml/templates/partials.haml +12 -0
  122. data/test/haml/templates/render_layout.haml +2 -0
  123. data/test/haml/templates/silent_script.haml +40 -0
  124. data/test/haml/templates/standard.haml +42 -0
  125. data/test/haml/templates/standard_ugly.haml +42 -0
  126. data/test/haml/templates/tag_parsing.haml +21 -0
  127. data/test/haml/templates/very_basic.haml +4 -0
  128. data/test/haml/templates/whitespace_handling.haml +87 -0
  129. data/test/haml/util_test.rb +87 -0
  130. data/test/linked_rails.rb +12 -0
  131. data/test/sass/css2sass_test.rb +193 -0
  132. data/test/sass/engine_test.rb +709 -0
  133. data/test/sass/functions_test.rb +109 -0
  134. data/test/sass/more_results/more1.css +9 -0
  135. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  136. data/test/sass/more_results/more_import.css +29 -0
  137. data/test/sass/more_templates/_more_partial.sass +2 -0
  138. data/test/sass/more_templates/more1.sass +23 -0
  139. data/test/sass/more_templates/more_import.sass +11 -0
  140. data/test/sass/plugin_test.rb +213 -0
  141. data/test/sass/results/alt.css +4 -0
  142. data/test/sass/results/basic.css +9 -0
  143. data/test/sass/results/compact.css +5 -0
  144. data/test/sass/results/complex.css +87 -0
  145. data/test/sass/results/compressed.css +1 -0
  146. data/test/sass/results/expanded.css +19 -0
  147. data/test/sass/results/import.css +29 -0
  148. data/test/sass/results/line_numbers.css +49 -0
  149. data/test/sass/results/mixins.css +95 -0
  150. data/test/sass/results/multiline.css +24 -0
  151. data/test/sass/results/nested.css +22 -0
  152. data/test/sass/results/parent_ref.css +13 -0
  153. data/test/sass/results/script.css +16 -0
  154. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  155. data/test/sass/results/subdir/subdir.css +3 -0
  156. data/test/sass/results/units.css +11 -0
  157. data/test/sass/script_test.rb +250 -0
  158. data/test/sass/templates/_partial.sass +2 -0
  159. data/test/sass/templates/alt.sass +16 -0
  160. data/test/sass/templates/basic.sass +23 -0
  161. data/test/sass/templates/bork.sass +2 -0
  162. data/test/sass/templates/bork2.sass +2 -0
  163. data/test/sass/templates/compact.sass +17 -0
  164. data/test/sass/templates/complex.sass +309 -0
  165. data/test/sass/templates/compressed.sass +15 -0
  166. data/test/sass/templates/expanded.sass +17 -0
  167. data/test/sass/templates/import.sass +11 -0
  168. data/test/sass/templates/importee.sass +19 -0
  169. data/test/sass/templates/line_numbers.sass +13 -0
  170. data/test/sass/templates/mixins.sass +76 -0
  171. data/test/sass/templates/multiline.sass +20 -0
  172. data/test/sass/templates/nested.sass +25 -0
  173. data/test/sass/templates/parent_ref.sass +25 -0
  174. data/test/sass/templates/script.sass +101 -0
  175. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  176. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  177. data/test/sass/templates/subdir/subdir.sass +6 -0
  178. data/test/sass/templates/units.sass +11 -0
  179. data/test/test_helper.rb +21 -0
  180. metadata +278 -0
data/Rakefile ADDED
@@ -0,0 +1,226 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ # ----- Benchmarking -----
5
+
6
+ desc <<END
7
+ Benchmark haml against ERb.
8
+ TIMES=n sets the number of runs. Defaults to 1000.
9
+ END
10
+ task :benchmark do
11
+ sh "ruby test/benchmark.rb #{ENV['TIMES']}"
12
+ end
13
+
14
+ # ----- Default: Testing ------
15
+
16
+ if ENV["RUN_CODE_RUN"] == "true"
17
+ task :default => :"test:rails_compatibility"
18
+ else
19
+ task :default => :test
20
+ end
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new do |t|
25
+ t.libs << 'lib'
26
+ test_files = FileList['test/**/*_test.rb']
27
+ test_files.exclude('test/rails/*')
28
+ t.test_files = test_files
29
+ t.verbose = true
30
+ end
31
+ Rake::Task[:test].send(:add_comment, <<END)
32
+ To run with an alternate version of Rails, make test/rails a symlink to that version.
33
+ END
34
+
35
+ # ----- Packaging -----
36
+
37
+ require 'rake/gempackagetask'
38
+ load 'haml.gemspec'
39
+
40
+ Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
41
+ if Rake.application.top_level_tasks.include?('release')
42
+ pkg.need_tar_gz = true
43
+ pkg.need_tar_bz2 = true
44
+ pkg.need_zip = true
45
+ end
46
+ end
47
+
48
+ task :revision_file do
49
+ require 'lib/haml'
50
+
51
+ release = Rake.application.top_level_tasks.include?('release') || File.exist?('EDGE_GEM_VERSION')
52
+ if Haml.version[:rev] && !release
53
+ File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] }
54
+ elsif release
55
+ File.open('REVISION', 'w') { |f| f.puts "(release)" }
56
+ else
57
+ File.open('REVISION', 'w') { |f| f.puts "(unknown)" }
58
+ end
59
+ end
60
+ Rake::Task[:package].prerequisites.insert(0, :revision_file)
61
+
62
+ # We also need to get rid of this file after packaging.
63
+ at_exit { File.delete('REVISION') rescue nil }
64
+
65
+ desc "Install Haml as a gem."
66
+ task :install => [:package] do
67
+ sudo = RUBY_PLATFORM =~ /win32/ ? '' : 'sudo'
68
+ gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
69
+ sh %{#{sudo} #{gem} install --no-ri pkg/haml-#{File.read('VERSION').strip}}
70
+ end
71
+
72
+ desc "Release a new Haml package to Rubyforge. Requires the NAME and VERSION flags."
73
+ task :release => [:package] do
74
+ name, version = ENV['NAME'], ENV['VERSION']
75
+ raise "Must supply NAME and VERSION for release task." unless name && version
76
+ sh %{rubyforge login}
77
+ sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
78
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
79
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
80
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
81
+ end
82
+
83
+ task :release_edge do
84
+ sh %{git checkout edge-gem}
85
+ sh %{git fetch origin}
86
+ sh %{git merge origin/edge-gem}
87
+ sh %{git merge origin/master}
88
+
89
+ # Get the current master branch version
90
+ version = File.read('VERSION').strip.split('.').map {|n| n.to_i}
91
+ unless version[1] % 2 == 1 && version[2] == 0
92
+ raise "#{version.join('.')} is not a development version"
93
+ end
94
+
95
+ # Bump the edge gem version
96
+ edge_version = File.read('EDGE_GEM_VERSION').strip.split('.').map {|n| n.to_i}
97
+ if edge_version[0..1] != version[0..1]
98
+ # A new master branch version was released, reset the edge gem version
99
+ edge_version[0..1] = version[0..1]
100
+ edge_version[2] = 0
101
+ else
102
+ # Just bump the teeny version
103
+ edge_version[2] += 1
104
+ end
105
+ edge_version = edge_version.join('.')
106
+ File.open('EDGE_GEM_VERSION', 'w') {|f| f.puts(edge_version)}
107
+ sh %{git commit -m "Bump edge gem version." EDGE_GEM_VERSION}
108
+ sh %{git push origin edge-gem}
109
+
110
+ # Package the edge gem with the proper version
111
+ File.open('VERSION', 'w') {|f| f.puts(edge_version)}
112
+ sh %{rake package}
113
+ sh %{git checkout VERSION}
114
+
115
+ sh %{rubyforge login}
116
+ sh %{rubyforge add_release haml haml-edge "Bleeding Edge (v#{edge_version})" pkg/haml-edge-#{edge_version}.gem}
117
+ end
118
+
119
+ task :watch_for_edge_update do
120
+ sh %{ruby extra/edge_gem_watch.rb}
121
+ end
122
+
123
+ # ----- Documentation -----
124
+
125
+ begin
126
+ require 'hanna/rdoctask'
127
+ rescue LoadError
128
+ require 'rake/rdoctask'
129
+ end
130
+
131
+ Rake::RDocTask.new do |rdoc|
132
+ rdoc.title = 'Haml/Sass'
133
+ rdoc.options << '--line-numbers' << '--inline-source'
134
+ rdoc.rdoc_files.include(*FileList.new('*') do |list|
135
+ list.exclude(/(^|[^.a-z])[a-z]+/)
136
+ list.exclude('TODO')
137
+ end.to_a)
138
+ rdoc.rdoc_files.include('lib/**/*.rb')
139
+ rdoc.rdoc_files.exclude('TODO')
140
+ rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
141
+ rdoc.rdoc_files.exclude('lib/sass/tree/*')
142
+ rdoc.rdoc_dir = 'rdoc'
143
+ rdoc.main = 'README.rdoc'
144
+ end
145
+
146
+ # ----- Coverage -----
147
+
148
+ begin
149
+ require 'rcov/rcovtask'
150
+
151
+ Rcov::RcovTask.new do |t|
152
+ t.test_files = FileList['test/**/*_test.rb']
153
+ t.rcov_opts << '-x' << '"^\/"'
154
+ if ENV['NON_NATIVE']
155
+ t.rcov_opts << "--no-rcovrt"
156
+ end
157
+ t.verbose = true
158
+ end
159
+ rescue LoadError; end
160
+
161
+ # ----- Profiling -----
162
+
163
+ begin
164
+ require 'ruby-prof'
165
+
166
+ desc <<END
167
+ Run a profile of haml.
168
+ ENGINE=str sets the engine to be profiled. Defaults to Haml.
169
+ TIMES=n sets the number of runs. Defaults to 1000.
170
+ FILE=str sets the file to profile.
171
+ Defaults to 'standard' for Haml and 'complex' for Sass.
172
+ OUTPUT=str sets the ruby-prof output format.
173
+ Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
174
+ END
175
+ task :profile do
176
+ engine = (ENV['ENGINE'] || 'haml').downcase
177
+ times = (ENV['TIMES'] || '1000').to_i
178
+ file = ENV['FILE']
179
+
180
+ if engine == 'sass'
181
+ require 'lib/sass'
182
+
183
+ file = File.read("#{File.dirname(__FILE__)}/test/sass/templates/#{file || 'complex'}.sass")
184
+ result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
185
+ else
186
+ require 'lib/haml'
187
+
188
+ file = File.read("#{File.dirname(__FILE__)}/test/haml/templates/#{file || 'standard'}.haml")
189
+ obj = Object.new
190
+ Haml::Engine.new(file).def_method(obj, :render)
191
+ result = RubyProf.profile { times.times { obj.render } }
192
+ end
193
+
194
+ RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
195
+ end
196
+ rescue LoadError; end
197
+
198
+ # ----- Testing Multiple Rails Versions -----
199
+
200
+ rails_versions = [
201
+ "v2.3.0",
202
+ "v2.2.2",
203
+ "v2.1.2",
204
+ "v2.0.5"
205
+ ]
206
+
207
+ namespace :test do
208
+ desc "Test all supported versions of rails. This takes a while."
209
+ task :rails_compatibility do
210
+ `rm -rf test/rails`
211
+ puts "Checking out rails. Please wait."
212
+ `git clone git://github.com/rails/rails.git test/rails` rescue nil
213
+ begin
214
+ rails_versions.each do |version|
215
+ Dir.chdir "test/rails" do
216
+ `git checkout #{version}`
217
+ end
218
+ puts "Testing Rails #{version}"
219
+ Rake::Task['test'].reenable
220
+ Rake::Task['test'].execute
221
+ end
222
+ ensure
223
+ `rm -rf test/rails`
224
+ end
225
+ end
226
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.1.1
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!
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+ require 'json'
4
+ set :port, 3123
5
+ set :environment, :production
6
+ Dir.chdir(File.dirname(__FILE__) + "/..")
7
+
8
+ post "/" do
9
+ payload = JSON.parse(params["payload"])
10
+
11
+ break unless payload["ref"] == "refs/heads/master"
12
+ system("rake release_edge &> edge-gem-output.log")
13
+ end