haml-edge 3.1.11 → 3.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.11
1
+ 3.1.12
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.11
1
+ 3.1.12
data/lib/haml/railtie.rb CHANGED
@@ -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
data/lib/haml/util.rb CHANGED
@@ -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)]
data/lib/sass/scss/rx.rb CHANGED
@@ -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
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml-edge
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.11
4
+ version: 3.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-05-12 00:00:00 -04:00
14
+ date: 2010-05-14 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency