haml-edge 3.1.69 → 3.1.70

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.69
1
+ 3.1.70
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.69
1
+ 3.1.70
data/lib/haml/exec.rb CHANGED
@@ -168,118 +168,33 @@ MESSAGE
168
168
  end
169
169
  end
170
170
 
171
- # An abstrac class that encapsulates the code
172
- # specific to the `haml` and `sass` executables.
173
- class HamlSass < Generic
171
+ # The `sass` executable.
172
+ class Sass < Generic
174
173
  # @param args [Array<String>] The command-line arguments
175
174
  def initialize(args)
176
175
  super
177
- @options[:for_engine] = {}
176
+ @options[:for_engine] = {
177
+ :load_paths => ['.'] + (ENV['SASSPATH'] || '').split(File::PATH_SEPARATOR)
178
+ }
178
179
  end
179
180
 
180
181
  protected
181
182
 
182
- # Tells optparse how to parse the arguments
183
- # available for the `haml` and `sass` executables.
184
- #
185
- # This is meant to be overridden by subclasses
186
- # so they can add their own options.
183
+ # Tells optparse how to parse the arguments.
187
184
  #
188
185
  # @param opts [OptionParser]
189
186
  def set_opts(opts)
187
+ super
188
+
190
189
  opts.banner = <<END
191
- Usage: #{@name.downcase} [options] [INPUT] [OUTPUT]
190
+ Usage: sass [options] [INPUT] [OUTPUT]
192
191
 
193
192
  Description:
194
- Uses the #{@name} engine to parse the specified template
195
- and outputs the result to the specified file.
193
+ Converts SCSS or Sass files to CSS.
196
194
 
197
195
  Options:
198
196
  END
199
197
 
200
- opts.on('--rails RAILS_DIR', "Install Haml and Sass from the Gem to a Rails project") do |dir|
201
- original_dir = dir
202
-
203
- env = File.join(dir, "config", "environment.rb")
204
- if File.exists?(File.join(dir, "Gemfile"))
205
- puts("haml --rails isn't needed for Rails 3 or greater.",
206
- "Add 'gem \"haml\"' to your Gemfile instead.", "",
207
- "haml --rails will no longer work in the next version of #{@name}.", "")
208
- elsif File.exists?(env) && File.open(env) {|env| env.grep(/config\.gem/)}
209
- puts("haml --rails isn't needed for Rails 2.1 or greater.",
210
- "Add 'config.gem \"haml\"' to config/environment.rb instead.", "",
211
- "haml --rails will no longer work in the next version of #{@name}.", "")
212
- end
213
-
214
- dir = File.join(dir, 'vendor', 'plugins')
215
-
216
- unless File.exists?(dir)
217
- puts "Directory #{dir} doesn't exist"
218
- exit 1
219
- end
220
-
221
- dir = File.join(dir, 'haml')
222
-
223
- if File.exists?(dir)
224
- print "Directory #{dir} already exists, overwrite [y/N]? "
225
- exit 2 if gets !~ /y/i
226
- FileUtils.rm_rf(dir)
227
- end
228
-
229
- begin
230
- Dir.mkdir(dir)
231
- rescue SystemCallError
232
- puts "Cannot create #{dir}"
233
- exit 1
234
- end
235
-
236
- File.open(File.join(dir, 'init.rb'), 'w') do |file|
237
- file << File.read(File.dirname(__FILE__) + "/../../init.rb")
238
- end
239
-
240
- puts "Haml plugin added to #{original_dir}"
241
- exit
242
- end
243
-
244
- opts.on('-c', '--check', "Just check syntax, don't evaluate.") do
245
- require 'stringio'
246
- @options[:check_syntax] = true
247
- @options[:output] = StringIO.new
248
- end
249
-
250
- super
251
- end
252
-
253
- # Processes the options set by the command-line arguments.
254
- # In particular, sets `@options[:for_engine][:filename]` to the input filename
255
- # and requires the appropriate file.
256
- #
257
- # This is meant to be overridden by subclasses
258
- # so they can run their respective programs.
259
- def process_result
260
- super
261
- @options[:for_engine][:filename] = @options[:filename] if @options[:filename]
262
- require File.dirname(__FILE__) + "/../#{@name.downcase}"
263
- end
264
- end
265
-
266
- # The `sass` executable.
267
- class Sass < HamlSass
268
- # @param args [Array<String>] The command-line arguments
269
- def initialize(args)
270
- super
271
- @name = "Sass"
272
- @options[:for_engine][:load_paths] = ['.'] + (ENV['SASSPATH'] || '').split(File::PATH_SEPARATOR)
273
- end
274
-
275
- protected
276
-
277
- # Tells optparse how to parse the arguments.
278
- #
279
- # @param opts [OptionParser]
280
- def set_opts(opts)
281
- super
282
-
283
198
  opts.on('--scss',
284
199
  'Use the CSS-superset SCSS syntax.') do
285
200
  @options[:for_engine][:syntax] = :scss
@@ -298,6 +213,11 @@ END
298
213
  'Only meaningful for --watch and --update.') do
299
214
  @options[:stop_on_error] = true
300
215
  end
216
+ opts.on('-c', '--check', "Just check syntax, don't evaluate.") do
217
+ require 'stringio'
218
+ @options[:check_syntax] = true
219
+ @options[:output] = StringIO.new
220
+ end
301
221
  opts.on('-t', '--style NAME',
302
222
  'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
303
223
  @options[:for_engine][:style] = name.to_sym
@@ -340,6 +260,8 @@ END
340
260
  # Processes the options set by the command-line arguments,
341
261
  # and runs the Sass compiler appropriately.
342
262
  def process_result
263
+ require 'sass'
264
+
343
265
  if !@options[:update] && !@options[:watch] &&
344
266
  @args.first && colon_path?(@args.first)
345
267
  if @args.size == 1
@@ -352,6 +274,7 @@ END
352
274
  return interactive if @options[:interactive]
353
275
  return watch_or_update if @options[:watch] || @options[:update]
354
276
  super
277
+ @options[:for_engine][:filename] = @options[:filename]
355
278
 
356
279
  begin
357
280
  input = @options[:input]
@@ -381,13 +304,11 @@ END
381
304
  private
382
305
 
383
306
  def interactive
384
- require 'sass'
385
307
  require 'sass/repl'
386
308
  ::Sass::Repl.new(@options).run
387
309
  end
388
310
 
389
311
  def watch_or_update
390
- require 'sass'
391
312
  require 'sass/plugin'
392
313
  ::Sass::Plugin.options.merge! @options[:for_engine]
393
314
  ::Sass::Plugin.options[:unix_newlines] = @options[:unix_newlines]
@@ -476,11 +397,11 @@ MSG
476
397
  end
477
398
 
478
399
  # The `haml` executable.
479
- class Haml < HamlSass
400
+ class Haml < Generic
480
401
  # @param args [Array<String>] The command-line arguments
481
402
  def initialize(args)
482
403
  super
483
- @name = "Haml"
404
+ @options[:for_engine] = {}
484
405
  @options[:requires] = []
485
406
  @options[:load_paths] = []
486
407
  end
@@ -491,6 +412,21 @@ MSG
491
412
  def set_opts(opts)
492
413
  super
493
414
 
415
+ opts.banner = <<END
416
+ Usage: haml [options] [INPUT] [OUTPUT]
417
+
418
+ Description:
419
+ Converts Haml files to HTML.
420
+
421
+ Options:
422
+ END
423
+
424
+ opts.on('-c', '--check', "Just check syntax, don't evaluate.") do
425
+ require 'stringio'
426
+ @options[:check_syntax] = true
427
+ @options[:output] = StringIO.new
428
+ end
429
+
494
430
  opts.on('-t', '--style NAME',
495
431
  'Output style. Can be indented (default) or ugly.') do |name|
496
432
  @options[:for_engine][:ugly] = true if name.to_sym == :ugly
@@ -536,6 +472,7 @@ MSG
536
472
  # and runs the Haml compiler appropriately.
537
473
  def process_result
538
474
  super
475
+ @options[:for_engine][:filename] = @options[:filename]
539
476
  input = @options[:input]
540
477
  output = @options[:output]
541
478
 
data/lib/haml/util.rb CHANGED
@@ -269,8 +269,8 @@ module Haml
269
269
  #
270
270
  # @return [String, nil]
271
271
  def rails_root
272
- if defined?(Rails.root)
273
- return Rails.root.to_s if Rails.root
272
+ if defined?(::Rails.root)
273
+ return ::Rails.root.to_s if ::Rails.root
274
274
  raise "ERROR: Rails.root is nil!"
275
275
  end
276
276
  return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
@@ -283,7 +283,7 @@ module Haml
283
283
  #
284
284
  # @return [String, nil]
285
285
  def rails_env
286
- return Rails.env.to_s if defined?(Rails.root)
286
+ return ::Rails.env.to_s if defined?(::Rails.env)
287
287
  return RAILS_ENV.to_s if defined?(RAILS_ENV)
288
288
  return nil
289
289
  end
@@ -212,8 +212,18 @@ module Sass
212
212
  end
213
213
 
214
214
  def import_directive
215
- @expected = "string or url()"
216
- arg = tok(STRING) || (uri = tok!(URI))
215
+ values = []
216
+
217
+ loop do
218
+ values << expr!(:import_arg)
219
+ break if use_css_import? || !tok(/,\s*/)
220
+ end
221
+
222
+ return values
223
+ end
224
+
225
+ def import_arg
226
+ return unless arg = tok(STRING) || (uri = tok!(URI))
217
227
  path = @scanner[1] || @scanner[2] || @scanner[3]
218
228
  ss
219
229
 
@@ -318,7 +328,7 @@ module Sass
318
328
  def block_contents(node, context)
319
329
  block_given? ? yield : ss_comments(node)
320
330
  node << (child = block_child(context))
321
- while tok(/;/) || (child && child.has_children)
331
+ while tok(/;/) || has_children?(child)
322
332
  block_given? ? yield : ss_comments(node)
323
333
  node << (child = block_child(context))
324
334
  end
@@ -330,6 +340,12 @@ module Sass
330
340
  variable || directive || declaration_or_ruleset
331
341
  end
332
342
 
343
+ def has_children?(child_or_array)
344
+ return false unless child_or_array
345
+ return child_or_array.last.has_children if child_or_array.is_a?(Array)
346
+ return child_or_array.has_children
347
+ end
348
+
333
349
  # This is a nasty hack, and the only place in the parser
334
350
  # that requires backtracking.
335
351
  # The reason is that we can't figure out if certain strings
@@ -747,6 +763,7 @@ MESSAGE
747
763
  :expr => "expression (e.g. 1px, bold)",
748
764
  :selector_comma_sequence => "selector",
749
765
  :simple_selector_sequence => "selector",
766
+ :import_arg => "file to import (string or url())",
750
767
  }
751
768
 
752
769
  TOK_NAMES = Haml::Util.to_hash(
@@ -84,14 +84,18 @@ module Sass
84
84
 
85
85
  # Appends a child to the node.
86
86
  #
87
- # @param child [Tree::Node] The child node
87
+ # @param child [Tree::Node, Array<Tree::Node>] The child node or nodes
88
88
  # @raise [Sass::SyntaxError] if `child` is invalid
89
89
  # @see #invalid_child?
90
90
  def <<(child)
91
91
  return if child.nil?
92
- check_child! child
93
- self.has_children = true
94
- @children << child
92
+ if child.is_a?(Array)
93
+ child.each {|c| self << c}
94
+ else
95
+ check_child! child
96
+ self.has_children = true
97
+ @children << child
98
+ end
95
99
  end
96
100
 
97
101
  # Raises an error if the given child node is invalid.
@@ -12,4 +12,20 @@ body { font: Arial; background: blue; }
12
12
 
13
13
  midrule { inthe: middle; }
14
14
 
15
+ scss { imported: yes; }
16
+
17
+ body { font: Arial; background: blue; }
18
+
19
+ #page { width: 700px; height: 100; }
20
+ #page #header { height: 300px; }
21
+ #page #header h1 { font-size: 50px; color: blue; }
22
+
23
+ #content.user.show #container.top #column.left { width: 100px; }
24
+ #content.user.show #container.top #column.right { width: 600px; }
25
+ #content.user.show #container.bottom { background: brown; }
26
+
27
+ @import url(basic.css);
28
+ @import url(../results/complex.css);
29
+ #foo { background-color: #bbaaff; }
30
+
15
31
  nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
@@ -2,7 +2,8 @@ $preconst: hello;
2
2
 
3
3
  @mixin premixin {pre-mixin: here}
4
4
 
5
- @import "importee.sass";
5
+ @import "importee.sass", "scss_importee", "basic.sass", "basic.css", "../results/complex.css";
6
+ @import "partial.sass";
6
7
 
7
8
  nonimported {
8
9
  myconst: $preconst;
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.69
4
+ version: 3.1.70
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-08-22 00:00:00 -04:00
14
+ date: 2010-08-28 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency