haml 3.0.0.rc.2 → 3.0.0.rc.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
@@ -39,15 +39,19 @@ END
39
39
 
40
40
  # ----- Packaging -----
41
41
 
42
- require 'rake/gempackagetask'
43
- load scope('haml.gemspec')
44
-
45
- Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
46
- if Rake.application.top_level_tasks.include?('release')
47
- pkg.need_tar_gz = true
48
- pkg.need_tar_bz2 = true
49
- pkg.need_zip = true
50
- end
42
+ # Don't use Rake::GemPackageTast because we want prerequisites to run
43
+ # before we load the gemspec.
44
+ desc "Build all the packages."
45
+ task :package => [:revision_file, :submodules] do
46
+ load scope('haml.gemspec')
47
+ Gem::Builder.new(HAML_GEMSPEC).build
48
+ pkg = "#{HAML_GEMSPEC.name}-#{HAML_GEMSPEC.version}"
49
+ mkdir_p "pkg"
50
+ verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
51
+
52
+ sh %{rm -f pkg/#{pkg}.tar.gz}
53
+ verbose(false) {HAML_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
54
+ sh %{gzip pkg/#{pkg}.tar}
51
55
  end
52
56
 
53
57
  task :revision_file do
@@ -62,8 +66,6 @@ task :revision_file do
62
66
  File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
63
67
  end
64
68
  end
65
- Rake::Task[:package].prerequisites.insert(0, :revision_file)
66
- Rake::Task[:package].prerequisites.insert(0, :submodules)
67
69
 
68
70
  # We also need to get rid of this file after packaging.
69
71
  at_exit { File.delete(scope('REVISION')) rescue nil }
@@ -81,8 +83,6 @@ task :release => [:check_release, :release_elpa, :package] do
81
83
  version = File.read(scope("VERSION")).strip
82
84
  sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
83
85
  sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
84
- sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
85
- sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
86
86
  sh %{gem push pkg/haml-#{version}.gem}
87
87
  end
88
88
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0.rc.2
1
+ 3.0.0.rc.3
@@ -23,7 +23,8 @@ module Haml
23
23
  rescue Exception => e
24
24
  raise e if @options[:trace] || e.is_a?(SystemExit)
25
25
 
26
- $stderr.puts e.message
26
+ $stderr.puts "#{e.class}: #{e.message}"
27
+ $stderr.puts " Use --trace for backtrace."
27
28
  exit 1
28
29
  end
29
30
  exit 0
@@ -559,7 +560,11 @@ END
559
560
  rescue LoadError => err
560
561
  dep = err.message.scan(/^no such file to load -- (.*)/)[0]
561
562
  raise err if @options[:trace] || dep.nil? || dep.empty?
562
- $stderr.puts "Required dependency #{dep} not found!\n Use --trace for backtrace."
563
+ $stderr.puts <<MESSAGE
564
+ Required dependency #{dep} not found!
565
+ Run "gem install #{dep}" to get it.
566
+ Use --trace for backtrace.
567
+ MESSAGE
563
568
  exit 1
564
569
  end
565
570
  end
@@ -3,16 +3,7 @@
3
3
  # Yehuda promises there will be soon,
4
4
  # and once there is we should switch to that.
5
5
 
6
+ # Rails 3.0.0.beta.2+
6
7
  if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
7
- # Rails 3.0.0.beta.2+
8
8
  ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
9
- elsif defined?(Rails::Railtie)
10
- # Rails 3.0.0.beta1
11
- module Haml
12
- class Railtie < Rails::Railtie
13
- ActiveSupport.on_load(:action_view) do
14
- Haml.init_rails(binding)
15
- end
16
- end
17
- end
18
9
  end
@@ -19,7 +19,11 @@ module Haml
19
19
  #
20
20
  # @return [Boolean] Whether the XSS integration was enabled.
21
21
  def try_enabling_xss_integration
22
- return false unless ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?
22
+ return false unless (ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?) ||
23
+ # We check for ActiveSupport#on_load here because if we're loading Haml that way, it means:
24
+ # A) we're in Rails 3 so XSS support is always on, and
25
+ # B) we might be in Rails 3 beta 3 where the load order is broken and xss_safe? is undefined
26
+ (defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load))
23
27
 
24
28
  Haml::Template.options[:escape_html] = true
25
29
 
@@ -55,10 +59,14 @@ else
55
59
  require 'haml/template/patch'
56
60
  end
57
61
 
58
- # Enable XSS integration. Use Rails' after_initialize method if possible
62
+ # Enable XSS integration. Use Rails' after_initialize method
59
63
  # so that integration will be checked after the rails_xss plugin is loaded
60
64
  # (for Rails 2.3.* where it's not enabled by default).
61
- if defined?(Rails.configuration.after_initialize)
65
+ #
66
+ # If we're running under Rails 3, though, we don't want to use after_intialize,
67
+ # since Haml loading has already been deferred via ActiveSupport.on_load.
68
+ if defined?(Rails.configuration.after_initialize) &&
69
+ !(defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load))
62
70
  Rails.configuration.after_initialize {Haml::Template.try_enabling_xss_integration}
63
71
  else
64
72
  Haml::Template.try_enabling_xss_integration
@@ -274,13 +274,7 @@ module Haml
274
274
  ActionPack::VERSION::Major
275
275
  end
276
276
 
277
- # 3.0.0.beta1 acts more like ActionPack 2
278
- # for purposes of this method
279
- # (checking whether block helpers require = or -).
280
- # This extra check can be removed when beta2 is out.
281
- version >= 3 &&
282
- !(defined?(ActionPack::VERSION::TINY) &&
283
- ActionPack::VERSION::TINY == "0.beta")
277
+ version >= 3
284
278
  end
285
279
 
286
280
  # Returns whether this environment is using ActionPack
@@ -291,6 +291,15 @@ module Sass
291
291
  raise e
292
292
  end
293
293
 
294
+ unless individual_files.empty? && FSSM::Backends::Default.name == "FSSM::Backends::FSEvents"
295
+ # As of FSSM 0.1.4, it doesn't support FSevents on individual files,
296
+ # but it also isn't smart enough to switch to polling itself.
297
+ require 'fssm/backends/polling'
298
+ Haml::Util.silence_warnings do
299
+ FSSM::Backends.const_set(:Default, FSSM::Backends::Polling)
300
+ end
301
+ end
302
+
294
303
  # TODO: Keep better track of what depends on what
295
304
  # so we don't have to run a global update every time anything changes.
296
305
  FSSM.monitor do |mon|
@@ -24,27 +24,6 @@ unless defined?(Sass::MERB_LOADED)
24
24
 
25
25
  Sass::Plugin.options.merge!(config)
26
26
 
27
- if version[0] > 0 || version[1] >= 9
28
-
29
- class Merb::Rack::Application
30
- def call_with_sass(env)
31
- Sass::Plugin.check_for_updates
32
- call_without_sass(env)
33
- end
34
- alias_method :call_without_sass, :call
35
- alias_method :call, :call_with_sass
36
- end
37
-
38
- else
39
-
40
- class MerbHandler
41
- def process_with_sass(request, response)
42
- Sass::Plugin.check_for_updates
43
- process_without_sass(request, response)
44
- end
45
- alias_method :process_without_sass, :process
46
- alias_method :process, :process_with_sass
47
- end
48
-
49
- end
27
+ require 'sass/plugin/rack'
28
+ Merb::Config[:app].use Sass::Plugin::Rack
50
29
  end
@@ -31,7 +31,6 @@ module Sass
31
31
  # @param app [#call] The Rack application
32
32
  def initialize(app)
33
33
  @app = app
34
- self.class.disable_native_plugin!
35
34
  end
36
35
 
37
36
  # Process a request, checking the Sass stylesheets for changes
@@ -43,23 +42,6 @@ module Sass
43
42
  Sass::Plugin.check_for_updates
44
43
  @app.call(env)
45
44
  end
46
-
47
- # Disable the native Rails or Merb plugins, if they're enabled.
48
- # This is automatically done once the Rack plugin is activated.
49
- # This is done so that the stylesheets aren't checked twice for each request.
50
- def self.disable_native_plugin!
51
- if defined?(Merb::Rack) && defined?(Merb::Rack::Application) &&
52
- Haml::Util.has?(:instance_method, Merb::Rack::Application, :call_without_sass)
53
- Merb::Rack::Application.instance_eval {alias_method :call, :call_without_sass}
54
- end
55
-
56
- if defined?(ActionDispatch::Callbacks) && defined?(ActionDispatch::Callbacks.to_prepare)
57
- ActionDispatch::Callbacks.skip_callback(:prepare, :__sass_process)
58
- elsif defined?(ActionController::Base) &&
59
- Haml::Util.has?(:instance_method, ActionController::Base, :sass_old_process)
60
- ActionController::Base.instance_eval {alias_method :process, :sass_old_process}
61
- end
62
- end
63
45
  end
64
46
  end
65
47
  end
@@ -8,10 +8,10 @@ unless defined?(Sass::RAILS_LOADED)
8
8
  :quiet => Haml::Util.rails_env != "production",
9
9
  :full_exception => Haml::Util.rails_env != "production")
10
10
 
11
- if defined?(Rails.configuration) && defined?(Rails.configuration.middleware)
11
+ if defined?(ActionController::Metal)
12
12
  # Rails >= 3.0
13
13
  require 'sass/plugin/rack'
14
- Rails.configuration.middleware.use(Sass::Plugin::Rack)
14
+ ActionController::Metal.use(Sass::Plugin::Rack)
15
15
  elsif defined?(ActionController::Dispatcher) &&
16
16
  defined?(ActionController::Dispatcher.middleware)
17
17
  # Rails >= 2.3
@@ -99,7 +99,7 @@ module Sass
99
99
  class << self
100
100
  private
101
101
  def string_re(open, close)
102
- /#{open}((?:\\.|\#(?!\{)|[^#{close}\\#])*)(#{close}|(?=#\{))/
102
+ /#{open}((?:\\.|\#(?!\{)|[^#{close}\\#])*)(#{close}|#\{)/
103
103
  end
104
104
  end
105
105
 
@@ -114,8 +114,8 @@ module Sass
114
114
  [:single, false] => string_re("'", "'"),
115
115
  [:double, true] => string_re('', '"'),
116
116
  [:single, true] => string_re('', "'"),
117
- [:uri, false] => /url\(#{W}(#{URLCHAR}*?)(#{W}\)|(?=#\{))/,
118
- [:uri, true] => /(#{URLCHAR}*?)(#{W}\)|(?=#\{))/,
117
+ [:uri, false] => /url\(#{W}(#{URLCHAR}*?)(#{W}\)|#\{)/,
118
+ [:uri, true] => /(#{URLCHAR}*?)(#{W}\)|#\{)/,
119
119
  }
120
120
 
121
121
  # @param str [String, StringScanner] The source text to lex
@@ -251,10 +251,13 @@ module Sass
251
251
 
252
252
  def string(re, open)
253
253
  return unless scan(STRING_REGULAR_EXPRESSIONS[[re, open]])
254
- @interpolation_stack << re if @scanner[2].empty? # Started an interpolated section
254
+ if @scanner[2] == '#{' #'
255
+ @scanner.pos -= 2 # Don't actually consume the #{
256
+ @interpolation_stack << re
257
+ end
255
258
  str =
256
259
  if re == :uri
257
- Script::String.new("#{'url(' unless open}#{@scanner[1]}#{')' unless @scanner[2].empty?}")
260
+ Script::String.new("#{'url(' unless open}#{@scanner[1]}#{')' unless @scanner[2] == '#{'}")
258
261
  else
259
262
  Script::String.new(@scanner[1].gsub(/\\(['"]|\#\{)/, '\1'), :string)
260
263
  end
@@ -645,7 +645,11 @@ MESSAGE
645
645
 
646
646
  mid_re = Sass::Script::Lexer::STRING_REGULAR_EXPRESSIONS[[type, true]]
647
647
  # @scanner[2].empty? means we've started an interpolated section
648
- res << expr!(:interpolation) << tok(mid_re) while @scanner[2].empty?
648
+ while @scanner[2] == '#{'
649
+ @scanner.pos -= 2 # Don't consume the #{
650
+ res.last.slice!(-2..-1)
651
+ res << expr!(:interpolation) << tok(mid_re)
652
+ end
649
653
  res
650
654
  end
651
655
 
@@ -76,10 +76,10 @@ module Sass
76
76
  # by extending this selector with `extends`.
77
77
  # These correspond to a {CommaSequence}'s {CommaSequence#members members array}.
78
78
  # @see CommaSequence#do_extend
79
- def do_extend(extends, supers = [])
79
+ def do_extend(extends, seen = Set.new)
80
80
  paths = Haml::Util.paths(members.map do |sseq_or_op|
81
81
  next [[sseq_or_op]] unless sseq_or_op.is_a?(SimpleSequence)
82
- extended = sseq_or_op.do_extend(extends, supers)
82
+ extended = sseq_or_op.do_extend(extends, seen)
83
83
  choices = extended.map {|seq| seq.members}
84
84
  choices.unshift([sseq_or_op]) unless extended.any? {|seq| seq.superselector?(sseq_or_op)}
85
85
  choices
@@ -87,6 +87,16 @@ module Sass
87
87
  Haml::Util.flatten(paths.map {|path| weave(path)}, 1).map {|p| Sequence.new(p)}
88
88
  end
89
89
 
90
+ # Returns whether or not this selector matches all elements
91
+ # that the given selector matches (as well as possibly more).
92
+ #
93
+ # @example
94
+ # (.foo).superselector?(.foo.bar) #=> true
95
+ # (.foo).superselector?(.bar) #=> false
96
+ # (.bar .foo).superselector?(.foo) #=> false
97
+ #
98
+ # @param sseq [SimpleSequence]
99
+ # @return [Boolean]
90
100
  def superselector?(sseq)
91
101
  return false unless members.size == 1
92
102
  members.last.superselector?(sseq)
@@ -61,7 +61,7 @@ module Sass
61
61
  # @return [Array<Sequence>] A list of selectors generated
62
62
  # by extending this selector with `extends`.
63
63
  # @see CommaSequence#do_extend
64
- def do_extend(extends, supers = [])
64
+ def do_extend(extends, seen = Set.new)
65
65
  extends.get(members.to_set).map do |seq, sels|
66
66
  # If A {@extend B} and C {...},
67
67
  # seq is A, sels is B, and self is C
@@ -69,13 +69,10 @@ module Sass
69
69
  self_without_sel = self.members - sels
70
70
  next unless unified = seq.members.last.unify(self_without_sel)
71
71
  [sels, seq.members[0...-1] + [unified]]
72
- end.compact.map {|sels, seq| [sels, Sequence.new(seq)]}.map do |sels, seq|
73
- seqs = seq.do_extend(extends, supers.unshift(sels))
74
- supers.shift
75
- seqs
72
+ end.compact.map do |sels, seq|
73
+ seq = Sequence.new(seq)
74
+ seen.include?(sels) ? [] : seq.do_extend(extends, seen + [sels])
76
75
  end.flatten.uniq
77
- rescue SystemStackError
78
- handle_extend_loop(supers)
79
76
  end
80
77
 
81
78
  # Unifies this selector with another {SimpleSequence}'s {SimpleSequence#members members array},
@@ -99,6 +96,15 @@ module Sass
99
96
  SimpleSequence.new(sseq)
100
97
  end
101
98
 
99
+ # Returns whether or not this selector matches all elements
100
+ # that the given selector matches (as well as possibly more).
101
+ #
102
+ # @example
103
+ # (.foo).superselector?(.foo.bar) #=> true
104
+ # (.foo).superselector?(.bar) #=> false
105
+ #
106
+ # @param sseq [SimpleSequence]
107
+ # @return [Boolean]
102
108
  def superselector?(sseq)
103
109
  (base.nil? || base.eql?(sseq.base)) && rest.subset?(sseq.rest)
104
110
  end
@@ -131,33 +137,6 @@ module Sass
131
137
  other.class == self.class && other.base.eql?(self.base) &&
132
138
  Haml::Util.set_eql?(other.rest, self.rest)
133
139
  end
134
-
135
- private
136
-
137
- # Raise a {Sass::SyntaxError} describing a loop of `@extend` directives.
138
- #
139
- # @param supers [Array<Simple>] The stack of selectors that contains the loop,
140
- # ordered from deepest to most shallow.
141
- # @raise [Sass::SyntaxError] Describing the loop
142
- def handle_extend_loop(supers)
143
- supers.inject([]) do |sseqs, sseq|
144
- next sseqs.push(sseq) unless sseqs.first.eql?(sseq)
145
- conses = Haml::Util.enum_cons(sseqs.push(sseq), 2).to_a
146
- _, i = Haml::Util.enum_with_index(conses).max do |((_, sseq1), _), ((_, sseq2), _)|
147
- sseq1.first.line <=> sseq2.first.line
148
- end
149
- loop = (conses[i..-1] + conses[0...i]).map do |sseq1, sseq2|
150
- sel1 = SimpleSequence.new(sseq1).inspect
151
- sel2 = SimpleSequence.new(sseq2).inspect
152
- str = " #{sel1} extends #{sel2} on line #{sseq2.first.line}"
153
- str << " of " << sseq2.first.filename if sseq2.first.filename
154
- str
155
- end.join(",\n")
156
- raise Sass::SyntaxError.new("An @extend loop was found:\n#{loop}")
157
- end
158
- # Should never get here
159
- raise Sass::SyntaxError.new("An @extend loop exists, but the exact loop couldn't be found")
160
- end
161
140
  end
162
141
  end
163
142
  end
@@ -1100,6 +1100,61 @@ CSS
1100
1100
  SCSS
1101
1101
  end
1102
1102
 
1103
+ # Loops
1104
+
1105
+ def test_extend_self_loop
1106
+ assert_equal <<CSS, render(<<SCSS)
1107
+ .foo {
1108
+ a: b; }
1109
+ CSS
1110
+ .foo {a: b; @extend .foo}
1111
+ SCSS
1112
+ end
1113
+
1114
+ def test_basic_extend_loop
1115
+ assert_equal <<CSS, render(<<SCSS)
1116
+ .bar, .foo {
1117
+ a: b; }
1118
+
1119
+ .foo, .bar {
1120
+ c: d; }
1121
+ CSS
1122
+ .foo {a: b; @extend .bar}
1123
+ .bar {c: d; @extend .foo}
1124
+ SCSS
1125
+ end
1126
+
1127
+ def test_three_level_extend_loop
1128
+ assert_equal <<CSS, render(<<SCSS)
1129
+ .baz, .bar, .foo {
1130
+ a: b; }
1131
+
1132
+ .foo, .baz, .bar {
1133
+ c: d; }
1134
+
1135
+ .bar, .foo, .baz {
1136
+ e: f; }
1137
+ CSS
1138
+ .foo {a: b; @extend .bar}
1139
+ .bar {c: d; @extend .baz}
1140
+ .baz {e: f; @extend .foo}
1141
+ SCSS
1142
+ end
1143
+
1144
+ def test_nested_extend_loop
1145
+ assert_equal <<CSS, render(<<SCSS)
1146
+ .bar, .bar .foo {
1147
+ a: b; }
1148
+ .bar .foo, .bar .foo .foo {
1149
+ c: d; }
1150
+ CSS
1151
+ .bar {
1152
+ a: b;
1153
+ .foo {c: d; @extend .bar}
1154
+ }
1155
+ SCSS
1156
+ end
1157
+
1103
1158
  def test_multiple_extender_merges_with_superset_selector
1104
1159
  assert_equal <<CSS, render(<<SCSS)
1105
1160
  a.bar.baz, a.foo {
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 3
4
+ :patch: 4
5
5
  :build:
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fssm}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Travis Tilley"]
12
- s.date = %q{2010-01-30}
12
+ s.date = %q{2010-03-10}
13
13
  s.description = %q{file system state monitor}
14
14
  s.email = %q{ttilley@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -53,12 +53,12 @@ Gem::Specification.new do |s|
53
53
  s.homepage = %q{http://github.com/ttilley/fssm}
54
54
  s.rdoc_options = ["--charset=UTF-8"]
55
55
  s.require_paths = ["lib"]
56
- s.rubygems_version = %q{1.3.5}
56
+ s.rubygems_version = %q{1.3.6}
57
57
  s.summary = %q{file system state monitor}
58
58
  s.test_files = [
59
59
  "spec/path_spec.rb",
60
- "spec/root/file.rb",
61
- "spec/spec_helper.rb"
60
+ "spec/spec_helper.rb",
61
+ "spec/root/file.rb"
62
62
  ]
63
63
 
64
64
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 0
8
8
  - 0
9
9
  - rc
10
- - 2
11
- version: 3.0.0.rc.2
10
+ - 3
11
+ version: 3.0.0.rc.3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Nathan Weizenbaum
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-04-27 00:00:00 -07:00
20
+ date: 2010-04-30 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -62,7 +62,6 @@ extra_rdoc_files:
62
62
  - VERSION_NAME
63
63
  - CONTRIBUTING
64
64
  - README.md
65
- - REMEMBER
66
65
  - MIT-LICENSE
67
66
  - VERSION
68
67
  - REVISION
@@ -340,7 +339,6 @@ files:
340
339
  - VERSION_NAME
341
340
  - CONTRIBUTING
342
341
  - README.md
343
- - REMEMBER
344
342
  - MIT-LICENSE
345
343
  - VERSION
346
344
  - REVISION
data/REMEMBER DELETED
@@ -1,5 +0,0 @@
1
- Be smart about default namespaces (http://www.w3.org/TR/css3-namespace/#declaration)
2
- Extending nested selectors?
3
-
4
- Less
5
- including mixins across imports