haml 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

data/Rakefile CHANGED
@@ -382,7 +382,7 @@ rails_versions << "v2.0.5" if RUBY_VERSION =~ /^1\.8/
382
382
 
383
383
  def test_rails_version(version)
384
384
  Dir.chdir "test/rails" do
385
- `git checkout #{version}`
385
+ sh %{git checkout #{version}}
386
386
  end
387
387
  puts "Testing Rails #{version}"
388
388
  Rake::Task['test'].reenable
@@ -392,14 +392,14 @@ end
392
392
  namespace :test do
393
393
  desc "Test all supported versions of rails. This takes a while."
394
394
  task :rails_compatibility do
395
- `rm -rf test/rails`
395
+ sh %{rm -rf test/rails}
396
396
  puts "Checking out rails. Please wait."
397
- system("git clone git://github.com/rails/rails.git test/rails") rescue nil
397
+ sh %{git clone git://github.com/rails/rails.git test/rails}
398
398
  begin
399
399
  rails_versions.each {|version| test_rails_version version}
400
400
 
401
401
  puts "Checking out rails_xss. Please wait."
402
- system("git clone git://github.com/NZKoz/rails_xss.git test/plugins/rails_xss")
402
+ sh %{git clone git://github.com/NZKoz/rails_xss.git test/plugins/rails_xss}
403
403
  test_rails_version(rails_versions.find {|s| s =~ /^v2\.3/})
404
404
  ensure
405
405
  `rm -rf test/rails`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.0.3
@@ -1,11 +1,29 @@
1
- # This file is here to integrate with Rails 3,
2
- # since there's no better way to do so as of 14 March 2010.
3
- # Yehuda promises there will be soon,
4
- # and once there is we should switch to that.
5
-
6
1
  # Rails 3.0.0.beta.2+
7
2
  if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
8
3
  require 'haml/template/options'
9
4
  require 'sass/plugin/configuration'
10
- ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
5
+ ActiveSupport.on_load(:action_view) do
6
+ if Rails.application
7
+ Haml.init_rails(binding)
8
+ else
9
+ # I can't believe we have to do this, but we do.
10
+ # Rails 3's lovely lazy-loading means that it's possible to load ActionView
11
+ # before the application has even begin loading.
12
+ # This means that Rails.root doesn't exist yet.
13
+ # So if the application isn't loaded, we use this arcane initializer stuff
14
+ # to load Haml/Sass *after* the application loads.
15
+ #
16
+ # Of course, it's also possible that the application is loaded before ActionView,
17
+ # so we can't *just* rely on this method of loading.
18
+ #
19
+ # Ugh.
20
+ module Haml
21
+ class Railtie < Rails::Railtie
22
+ initializer :haml do
23
+ Haml.init_rails(binding)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
11
29
  end
@@ -260,7 +260,10 @@ module Haml
260
260
  #
261
261
  # @return [String, nil]
262
262
  def rails_root
263
- return Rails.root.to_s if defined?(Rails.root)
263
+ if defined?(Rails.root)
264
+ return Rails.root.to_s if Rails.root
265
+ raise "ERROR: Rails.root is nil!"
266
+ end
264
267
  return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
265
268
  return nil
266
269
  end
@@ -25,6 +25,13 @@ unless defined?(Sass::MERB_LOADED)
25
25
  Sass::Plugin.options.merge!(config)
26
26
 
27
27
  require 'sass/plugin/rack'
28
- # Merb::Config is used in Merb >= 1.1.0
29
- (Merb::Config[:app] || Merb::Config).use Sass::Plugin::Rack
28
+ class Sass::Plugin::MerbBootLoader < Merb::BootLoader
29
+ after Merb::BootLoader::RackUpApplication
30
+
31
+ def self.run
32
+ # Apparently there's no better way than this to add Sass
33
+ # to Merb's Rack stack.
34
+ Merb::Config[:app] = Sass::Plugin::Rack.new(Merb::Config[:app])
35
+ end
36
+ end
30
37
  end
@@ -273,6 +273,9 @@ module Sass
273
273
 
274
274
  def color
275
275
  return unless s = scan(REGULAR_EXPRESSIONS[:color])
276
+ raise Sass::SyntaxError.new(<<MESSAGE) unless s.size == 4 || s.size == 7
277
+ Colors must have either three or six digits: '#{s}'
278
+ MESSAGE
276
279
  value = s.scan(/^#(..?)(..?)(..?)$/).first.
277
280
  map {|num| num.ljust(2, num).to_i(16)}
278
281
  [:color, Script::Color.new(value)]
@@ -271,7 +271,7 @@ RUBY
271
271
  def arglist
272
272
  return unless e = interpolation
273
273
  return [e] unless try_tok(:comma)
274
- [e, *arglist]
274
+ [e, *assert_expr(:arglist)]
275
275
  end
276
276
 
277
277
  def raw
@@ -333,6 +333,7 @@ RUBY
333
333
  EXPR_NAMES = {
334
334
  :string => "string",
335
335
  :default => "expression (e.g. 1px, bold)",
336
+ :arglist => "mixin argument",
336
337
  }
337
338
 
338
339
  def assert_expr(name)
@@ -107,13 +107,17 @@ module Sass
107
107
  NOT = quote(":not(", Regexp::IGNORECASE)
108
108
 
109
109
  # Custom
110
- HEXCOLOR = /\#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?/
110
+ HEXCOLOR = /\#[0-9a-fA-F]+/
111
111
  INTERP_START = /#\{/
112
112
 
113
113
  STRING1_NOINTERP = /\"((?:[^\n\r\f\\"#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\"/
114
114
  STRING2_NOINTERP = /\'((?:[^\n\r\f\\'#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\'/
115
115
  STRING_NOINTERP = /#{STRING1_NOINTERP}|#{STRING2_NOINTERP}/
116
- STATIC_VALUE = /(#{NMCHAR}|#{STRING1_NOINTERP}|\s(?!%)|#[a-f0-9]|[,%]|\.[0-9]|\!important)+(?=[;}])/i
116
+ # Can't use IDENT here, because it seems to take exponential time on 1.8.
117
+ # We could use it for 1.9 only, but I don't want to introduce a cross-version
118
+ # behavior difference.
119
+ # There aren't really any plain-CSS single-character identifiers anyway.
120
+ STATIC_VALUE = /(-?#{NMSTART}#{NMCHAR}+|#{STRING_NOINTERP}|\s(?!%)|#[a-f0-9]|[,%]|#{NUM}|\!important)+(?=[;}])/i
117
121
 
118
122
  STATIC_SELECTOR = /(#{NMCHAR}|\s|[,>+*]|[:#.]#{NMSTART})+(?=[{])/i
119
123
  end
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
- require 'haml/template'
4
3
 
5
4
  class ActionView::Base
6
5
  def nested_tag
@@ -388,7 +387,7 @@ MESSAGE
388
387
  render("- something_that_uses_haml_concat")
389
388
  assert false, "Expected Haml::Error"
390
389
  rescue Haml::Error => e
391
- assert_equal 13, e.backtrace[0].scan(/:(\d+)/).first.first.to_i
390
+ assert_equal 12, e.backtrace[0].scan(/:(\d+)/).first.first.to_i
392
391
  end
393
392
 
394
393
  class ActsLikeTag
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
- require 'haml/template'
4
3
  require 'sass/plugin'
5
4
  require File.dirname(__FILE__) + '/mocks/article'
6
5
 
@@ -5,11 +5,18 @@ if File.exists?(linked_rails) && !$:.include?(linked_rails + '/activesupport/lib
5
5
  puts "[ using linked Rails ]"
6
6
  $:.unshift linked_rails + '/activesupport/lib'
7
7
  $:.unshift linked_rails + '/actionpack/lib'
8
+ $:.unshift linked_rails + '/railties/lib'
8
9
  end
9
10
  require 'rubygems'
10
11
  require 'action_controller'
11
12
  require 'action_view'
12
13
 
14
+ begin
15
+ # Necessary for Rails 3
16
+ require 'rails'
17
+ rescue LoadError
18
+ end
19
+
13
20
  ActionController::Base.logger = Logger.new(nil)
14
21
 
15
22
  # Load plugins from test/plugins.
@@ -303,6 +303,19 @@ SASS
303
303
  assert_equal "0.5", resolve("$var", {}, env("var" => eval("1px/2px")))
304
304
  end
305
305
 
306
+ def test_colors_with_wrong_number_of_digits
307
+ assert_raise(Sass::SyntaxError,
308
+ "Colors must have either three or six digits: '#0'") {eval("#0")}
309
+ assert_raise(Sass::SyntaxError,
310
+ "Colors must have either three or six digits: '#12'") {eval("#12")}
311
+ assert_raise(Sass::SyntaxError,
312
+ "Colors must have either three or six digits: '#abcd'") {eval("#abcd")}
313
+ assert_raise(Sass::SyntaxError,
314
+ "Colors must have either three or six digits: '#abcdE'") {eval("#abcdE")}
315
+ assert_raise(Sass::SyntaxError,
316
+ "Colors must have either three or six digits: '#abcdEFA'") {eval("#abcdEFA")}
317
+ end
318
+
306
319
  # Regression Tests
307
320
 
308
321
  def test_funcall_has_higher_precedence_than_color_name
@@ -390,7 +390,7 @@ SCSS
390
390
  assert_equal <<CSS, render(<<SCSS)
391
391
  foo {
392
392
  a: -0.5em;
393
- b: 0.5em;
393
+ b: +0.5em;
394
394
  c: -foo(12px);
395
395
  d: +foo(12px); }
396
396
  CSS
@@ -87,13 +87,15 @@ SCSS
87
87
  assert_equal <<CSS, render(<<SCSS)
88
88
  foo {
89
89
  a: 3;
90
- b: foobar;
91
- c: 12px; }
90
+ b: -1;
91
+ c: foobar;
92
+ d: 12px; }
92
93
  CSS
93
94
  foo {
94
95
  a: 1 + 2;
95
- b: foo + bar;
96
- c: floor(12.3px); }
96
+ b: 1 - 2;
97
+ c: foo + bar;
98
+ d: floor(12.3px); }
97
99
  SCSS
98
100
  end
99
101
 
@@ -1022,6 +1024,20 @@ $value : bip;
1022
1024
  foo {
1023
1025
  bar: -moz-\#{$value};
1024
1026
  }
1027
+ SCSS
1028
+ end
1029
+
1030
+ def test_extra_comma_in_mixin_arglist_error
1031
+ assert_raise(Sass::SyntaxError, <<MESSAGE) {render <<SCSS}
1032
+ Invalid CSS after "@include foo(bar, ": expected mixin argument, was ")"
1033
+ MESSAGE
1034
+ @mixin foo($a1, $a2) {
1035
+ baz: $a1 $a2;
1036
+ }
1037
+
1038
+ .bar {
1039
+ @include foo(bar, );
1040
+ }
1025
1041
  SCSS
1026
1042
  end
1027
1043
  end
@@ -7,6 +7,7 @@ $:.unshift lib_dir unless $:.include?(lib_dir)
7
7
  require 'haml'
8
8
  require 'sass'
9
9
 
10
+ require 'haml/template'
10
11
  Haml::Template.options[:ugly] = false
11
12
 
12
13
  Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 0
8
- - 2
9
- version: 3.0.2
8
+ - 3
9
+ version: 3.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nathan Weizenbaum
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-11 00:00:00 -07:00
19
+ date: 2010-05-14 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency