sass 3.1.21 → 3.2.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/README.md +5 -4
  2. data/REVISION +1 -1
  3. data/Rakefile +6 -15
  4. data/VERSION +1 -1
  5. data/VERSION_NAME +1 -1
  6. data/lib/sass.rb +0 -1
  7. data/lib/sass/cache_stores/base.rb +1 -3
  8. data/lib/sass/cache_stores/filesystem.rb +0 -3
  9. data/lib/sass/css.rb +49 -145
  10. data/lib/sass/engine.rb +23 -47
  11. data/lib/sass/environment.rb +5 -30
  12. data/lib/sass/exec.rb +7 -30
  13. data/lib/sass/importers/base.rb +1 -2
  14. data/lib/sass/importers/filesystem.rb +13 -18
  15. data/lib/sass/less.rb +1 -1
  16. data/lib/sass/plugin.rb +8 -4
  17. data/lib/sass/plugin/compiler.rb +67 -93
  18. data/lib/sass/plugin/configuration.rb +2 -0
  19. data/lib/sass/plugin/staleness_checker.rb +4 -14
  20. data/lib/sass/repl.rb +3 -2
  21. data/lib/sass/script.rb +1 -0
  22. data/lib/sass/script/color.rb +9 -4
  23. data/lib/sass/script/funcall.rb +3 -16
  24. data/lib/sass/script/functions.rb +55 -98
  25. data/lib/sass/script/interpolation.rb +0 -9
  26. data/lib/sass/script/lexer.rb +4 -2
  27. data/lib/sass/script/list.rb +0 -8
  28. data/lib/sass/script/literal.rb +20 -5
  29. data/lib/sass/script/node.rb +0 -8
  30. data/lib/sass/script/number.rb +11 -35
  31. data/lib/sass/script/operation.rb +0 -16
  32. data/lib/sass/script/parser.rb +5 -12
  33. data/lib/sass/script/string_interpolation.rb +0 -9
  34. data/lib/sass/script/unary_operation.rb +0 -7
  35. data/lib/sass/script/variable.rb +1 -5
  36. data/lib/sass/scss/parser.rb +54 -191
  37. data/lib/sass/scss/rx.rb +3 -15
  38. data/lib/sass/scss/static_parser.rb +3 -3
  39. data/lib/sass/selector.rb +3 -15
  40. data/lib/sass/selector/abstract_sequence.rb +2 -11
  41. data/lib/sass/selector/comma_sequence.rb +3 -8
  42. data/lib/sass/selector/sequence.rb +11 -74
  43. data/lib/sass/selector/simple.rb +1 -7
  44. data/lib/sass/selector/simple_sequence.rb +8 -28
  45. data/lib/sass/shared.rb +5 -3
  46. data/lib/sass/tree/comment_node.rb +12 -25
  47. data/lib/sass/tree/debug_node.rb +1 -1
  48. data/lib/sass/tree/directive_node.rb +0 -5
  49. data/lib/sass/tree/each_node.rb +1 -1
  50. data/lib/sass/tree/extend_node.rb +1 -1
  51. data/lib/sass/tree/for_node.rb +2 -2
  52. data/lib/sass/tree/function_node.rb +1 -1
  53. data/lib/sass/tree/if_node.rb +14 -1
  54. data/lib/sass/tree/media_node.rb +4 -4
  55. data/lib/sass/tree/mixin_def_node.rb +1 -1
  56. data/lib/sass/tree/mixin_node.rb +2 -2
  57. data/lib/sass/tree/node.rb +26 -10
  58. data/lib/sass/tree/return_node.rb +1 -1
  59. data/lib/sass/tree/root_node.rb +1 -1
  60. data/lib/sass/tree/rule_node.rb +11 -9
  61. data/lib/sass/tree/variable_node.rb +1 -1
  62. data/lib/sass/tree/visitors/base.rb +1 -1
  63. data/lib/sass/tree/visitors/check_nesting.rb +36 -29
  64. data/lib/sass/tree/visitors/convert.rb +9 -16
  65. data/lib/sass/tree/visitors/cssize.rb +9 -40
  66. data/lib/sass/tree/visitors/perform.rb +23 -79
  67. data/lib/sass/tree/visitors/to_css.rb +21 -23
  68. data/lib/sass/tree/warn_node.rb +1 -1
  69. data/lib/sass/tree/while_node.rb +1 -1
  70. data/lib/sass/util.rb +9 -147
  71. data/lib/sass/version.rb +0 -14
  72. data/test/sass/cache_test.rb +0 -15
  73. data/test/sass/conversion_test.rb +8 -50
  74. data/test/sass/css2sass_test.rb +0 -33
  75. data/test/sass/engine_test.rb +32 -283
  76. data/test/sass/extend_test.rb +0 -315
  77. data/test/sass/functions_test.rb +23 -60
  78. data/test/sass/importer_test.rb +0 -110
  79. data/test/sass/more_results/more_import.css +2 -2
  80. data/test/sass/plugin_test.rb +13 -40
  81. data/test/sass/results/import.css +2 -2
  82. data/test/sass/results/import_charset.css +0 -1
  83. data/test/sass/results/import_charset_1_8.css +0 -1
  84. data/test/sass/results/import_charset_ibm866.css +0 -1
  85. data/test/sass/results/scss_import.css +2 -2
  86. data/test/sass/results/units.css +1 -1
  87. data/test/sass/script_conversion_test.rb +0 -2
  88. data/test/sass/script_test.rb +4 -28
  89. data/test/sass/scss/css_test.rb +1 -79
  90. data/test/sass/scss/scss_test.rb +16 -96
  91. data/test/sass/templates/import_charset.sass +0 -2
  92. data/test/sass/templates/import_charset_1_8.sass +0 -2
  93. data/test/sass/templates/import_charset_ibm866.sass +0 -2
  94. data/test/sass/test_helper.rb +1 -1
  95. data/test/sass/util_test.rb +0 -28
  96. data/test/test_helper.rb +0 -2
  97. data/vendor/{listen → fssm}/LICENSE +1 -1
  98. data/vendor/fssm/README.markdown +55 -0
  99. data/vendor/fssm/Rakefile +59 -0
  100. data/vendor/fssm/VERSION.yml +5 -0
  101. data/vendor/fssm/example.rb +9 -0
  102. data/vendor/fssm/fssm.gemspec +77 -0
  103. data/vendor/fssm/lib/fssm.rb +33 -0
  104. data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
  105. data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
  106. data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
  107. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
  108. data/vendor/fssm/lib/fssm/monitor.rb +26 -0
  109. data/vendor/fssm/lib/fssm/path.rb +91 -0
  110. data/vendor/fssm/lib/fssm/pathname.rb +502 -0
  111. data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
  112. data/vendor/fssm/lib/fssm/state/file.rb +24 -0
  113. data/vendor/fssm/lib/fssm/support.rb +63 -0
  114. data/vendor/fssm/lib/fssm/tree.rb +176 -0
  115. data/vendor/fssm/profile/prof-cache.rb +40 -0
  116. data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
  117. data/vendor/fssm/profile/prof-pathname.rb +68 -0
  118. data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
  119. data/vendor/fssm/profile/prof.html +2379 -0
  120. data/vendor/fssm/spec/path_spec.rb +75 -0
  121. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  122. data/vendor/fssm/spec/root/file.css +0 -0
  123. data/vendor/fssm/spec/root/file.rb +0 -0
  124. data/vendor/fssm/spec/root/file.yml +0 -0
  125. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  126. data/vendor/fssm/spec/spec_helper.rb +14 -0
  127. metadata +246 -281
  128. data/VERSION_DATE +0 -1
  129. data/lib/sass/logger.rb +0 -15
  130. data/lib/sass/logger/base.rb +0 -32
  131. data/lib/sass/logger/log_level.rb +0 -49
  132. data/lib/sass/tree/visitors/deep_copy.rb +0 -87
  133. data/lib/sass/tree/visitors/extend.rb +0 -42
  134. data/lib/sass/tree/visitors/set_options.rb +0 -97
  135. data/lib/sass/util/multibyte_string_scanner.rb +0 -134
  136. data/test/Gemfile +0 -4
  137. data/test/Gemfile.lock +0 -19
  138. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  139. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  140. data/test/sass/logger_test.rb +0 -58
  141. data/test/sass/templates/_double_import_loop2.sass +0 -1
  142. data/test/sass/templates/bork5.sass +0 -3
  143. data/test/sass/templates/double_import_loop1.sass +0 -1
  144. data/test/sass/templates/nested_bork5.sass +0 -2
  145. data/test/sass/templates/single_import_loop.sass +0 -1
  146. data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
  147. data/vendor/listen/CHANGELOG.md +0 -147
  148. data/vendor/listen/Gemfile +0 -23
  149. data/vendor/listen/Guardfile +0 -8
  150. data/vendor/listen/README.md +0 -312
  151. data/vendor/listen/Rakefile +0 -47
  152. data/vendor/listen/Vagrantfile +0 -96
  153. data/vendor/listen/lib/listen.rb +0 -38
  154. data/vendor/listen/lib/listen/adapter.rb +0 -167
  155. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -84
  156. data/vendor/listen/lib/listen/adapters/linux.rb +0 -110
  157. data/vendor/listen/lib/listen/adapters/polling.rb +0 -66
  158. data/vendor/listen/lib/listen/adapters/windows.rb +0 -81
  159. data/vendor/listen/lib/listen/directory_record.rb +0 -318
  160. data/vendor/listen/lib/listen/listener.rb +0 -203
  161. data/vendor/listen/lib/listen/multi_listener.rb +0 -121
  162. data/vendor/listen/lib/listen/turnstile.rb +0 -28
  163. data/vendor/listen/lib/listen/version.rb +0 -3
  164. data/vendor/listen/listen.gemspec +0 -26
  165. data/vendor/listen/spec/listen/adapter_spec.rb +0 -142
  166. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -31
  167. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -41
  168. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  169. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -24
  170. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1138
  171. data/vendor/listen/spec/listen/listener_spec.rb +0 -155
  172. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -156
  173. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  174. data/vendor/listen/spec/listen_spec.rb +0 -73
  175. data/vendor/listen/spec/spec_helper.rb +0 -18
  176. data/vendor/listen/spec/support/adapter_helper.rb +0 -716
  177. data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
  178. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  179. data/vendor/listen/spec/support/listeners_helper.rb +0 -144
  180. data/vendor/listen/spec/support/platform_helper.rb +0 -11
data/README.md CHANGED
@@ -175,15 +175,16 @@ See `sass-convert --help` for further information and options.
175
175
 
176
176
  Sass was envisioned by [Hampton Catlin](http://hamptoncatlin.com) (hcatlin).
177
177
  However, Hampton doesn't even know his way around the code anymore and now
178
- occasionally consults on the language issues. Hampton lives in Cambridge, UK and
179
- is the owner of [Catlin Software](http://www.catlinsoftware.com/).
178
+ occasionally consults on the language issues. Hampton lives in Jacksonville,
179
+ Florida and is the lead mobile developer for Wikimedia.
180
180
 
181
181
  [Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of
182
182
  Sass. His hard work has kept the project alive by endlessly answering forum
183
183
  posts, fixing bugs, refactoring, finding speed improvements, writing
184
184
  documentation, implementing new features, and getting Hampton coffee (a fitting
185
- task for a boy-genius). Nathan lives in Seattle, Washington and works on
186
- [Dart](http://dartlang.org) application libraries at Google.
185
+ task for a boy-genius). Nathan lives in Seattle, Washington and while not being
186
+ a student at the University of Washington or working at an internship, he
187
+ consults for Unspace Interactive.
187
188
 
188
189
  [Chris Eppstein](http://acts-as-architect.blogspot.com) is a core contributor to
189
190
  Sass and the creator of Compass, the first Sass-based framework. Chris focuses
data/REVISION CHANGED
@@ -1 +1 @@
1
- (release)
1
+ d30f40911d3707add3c20a224719b9a6bd20ee8e
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ end
24
24
  # Don't use Rake::GemPackageTast because we want prerequisites to run
25
25
  # before we load the gemspec.
26
26
  desc "Build all the packages."
27
- task :package => [:revision_file, :date_file, :submodules, :permissions] do
27
+ task :package => [:revision_file, :submodules, :permissions] do
28
28
  version = get_version
29
29
  File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
30
30
  load scope('sass.gemspec')
@@ -51,7 +51,7 @@ task :permissions do
51
51
  end
52
52
 
53
53
  task :revision_file do
54
- require scope('lib/sass')
54
+ require 'lib/sass'
55
55
 
56
56
  release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
57
57
  if Sass.version[:rev] && !release
@@ -63,17 +63,8 @@ task :revision_file do
63
63
  end
64
64
  end
65
65
 
66
- task :date_file do
67
- File.open(scope('VERSION_DATE'), 'w') do |f|
68
- f.puts Time.now.utc.strftime('%d %B %Y %T %Z')
69
- end
70
- end
71
-
72
66
  # We also need to get rid of this file after packaging.
73
- at_exit do
74
- File.delete(scope('REVISION')) rescue nil
75
- File.delete(scope('VERSION_DATE')) rescue nil
76
- end
67
+ at_exit { File.delete(scope('REVISION')) rescue nil }
77
68
 
78
69
  desc "Install Sass as a gem. Use SUDO=1 to install with sudo."
79
70
  task :install => [:package] do
@@ -124,9 +115,9 @@ task :submodules do
124
115
  if File.exist?(File.dirname(__FILE__) + "/.git")
125
116
  sh %{git submodule sync}
126
117
  sh %{git submodule update --init}
127
- elsif !File.exist?(File.dirname(__FILE__) + "/vendor/listen/lib")
118
+ elsif !File.exist?(File.dirname(__FILE__) + "/vendor/fssm/lib")
128
119
  warn <<WARN
129
- WARNING: vendor/listen doesn't exist, and this isn't a git repository so
120
+ WARNING: vendor/fssm doesn't exist, and this isn't a git repository so
130
121
  I can't get it automatically!
131
122
  WARN
132
123
  end
@@ -156,7 +147,7 @@ def get_version
156
147
  version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
157
148
  return written_version unless version.size == 5 && version[3] == "alpha" # prerelease
158
149
 
159
- return written_version if (commit_count = `git log --pretty=oneline HEAD ^stable | wc -l`).empty?
150
+ return written_version if (commit_count = `git log --pretty=oneline --first-parent stable.. | wc -l`).empty?
160
151
  version[4] = commit_count.strip
161
152
  version.join('.')
162
153
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.21
1
+ 3.2.0.alpha.3
@@ -1 +1 @@
1
- Brainy Betty
1
+ Bleeding Edge
@@ -65,7 +65,6 @@ module Sass
65
65
  end
66
66
  end
67
67
 
68
- require 'sass/logger'
69
68
  require 'sass/util'
70
69
 
71
70
  require 'sass/engine'
@@ -49,8 +49,6 @@ module Sass
49
49
  # @param obj [Object] The object to cache.
50
50
  def store(key, sha, root)
51
51
  _store(key, Sass::VERSION, sha, Marshal.dump(root))
52
- rescue TypeError, LoadError => e
53
- Sass::Util.sass_warn "Warning. Error encountered while saving cache #{path_to(key)}: #{e}"
54
52
  end
55
53
 
56
54
  # Retrieve a {Sass::Tree::RootNode}.
@@ -61,7 +59,7 @@ module Sass
61
59
  def retrieve(key, sha)
62
60
  contents = _retrieve(key, Sass::VERSION, sha)
63
61
  Marshal.load(contents) if contents
64
- rescue EOFError, TypeError, ArgumentError, LoadError => e
62
+ rescue EOFError, TypeError, ArgumentError => e
65
63
  Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
66
64
  end
67
65
 
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  module Sass
4
2
  module CacheStores
5
3
  # A backend for the Sass cache using the filesystem.
@@ -53,7 +51,6 @@ module Sass
53
51
  # @param key [String]
54
52
  # @return [String] The path to the cache file.
55
53
  def path_to(key)
56
- key = key.gsub(/[<>:\\|?*%]/) {|c| "%%%03d" % Sass::Util.ord(c)}
57
54
  File.join(cache_location, key)
58
55
  end
59
56
  end
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../sass'
2
2
  require 'sass/tree/node'
3
3
  require 'sass/scss/css_parser'
4
+ require 'strscan'
4
5
 
5
6
  module Sass
6
7
  # This class converts CSS documents into Sass or SCSS templates.
@@ -74,30 +75,15 @@ module Sass
74
75
  #
75
76
  # @return [Tree::Node] The root node of the parsed tree
76
77
  def build_tree
77
- root = Sass::SCSS::CssParser.new(@template, @options[:filename]).parse
78
- parse_selectors root
78
+ root = Sass::SCSS::CssParser.new(@template).parse
79
79
  expand_commas root
80
- nest_seqs root
81
80
  parent_ref_rules root
81
+ remove_parent_refs root
82
82
  flatten_rules root
83
83
  fold_commas root
84
- dump_selectors root
85
84
  root
86
85
  end
87
86
 
88
- # Parse all the selectors in the document and assign them to
89
- # {Sass::Tree::RuleNode#parsed_rules}.
90
- #
91
- # @param root [Tree::Node] The parent node
92
- def parse_selectors(root)
93
- root.children.each do |child|
94
- next parse_selectors(child) if child.is_a?(Tree::DirectiveNode)
95
- next unless child.is_a?(Tree::RuleNode)
96
- parser = Sass::SCSS::CssParser.new(child.rule.first, child.filename, child.line)
97
- child.parsed_rules = parser.parse_selector
98
- end
99
- end
100
-
101
87
  # Transform
102
88
  #
103
89
  # foo, bar, baz
@@ -115,14 +101,12 @@ module Sass
115
101
  # @param root [Tree::Node] The parent node
116
102
  def expand_commas(root)
117
103
  root.children.map! do |child|
118
- # child.parsed_rules.members.size > 1 iff the rule contains a comma
119
- unless child.is_a?(Tree::RuleNode) && child.parsed_rules.members.size > 1
104
+ unless child.is_a?(Tree::RuleNode) && child.rule.first.include?(',')
120
105
  expand_commas(child) if child.is_a?(Tree::DirectiveNode)
121
106
  next child
122
107
  end
123
- child.parsed_rules.members.map do |seq|
124
- node = Tree::RuleNode.new([])
125
- node.parsed_rules = make_cseq(seq)
108
+ child.rule.first.split(',').map do |rule|
109
+ node = Tree::RuleNode.new([rule.strip])
126
110
  node.children = child.children
127
111
  node
128
112
  end
@@ -130,7 +114,22 @@ module Sass
130
114
  root.children.flatten!
131
115
  end
132
116
 
133
- # Make rules use nesting so that
117
+ # Make rules use parent refs so that
118
+ #
119
+ # foo
120
+ # color: green
121
+ # foo.bar
122
+ # color: blue
123
+ #
124
+ # becomes
125
+ #
126
+ # foo
127
+ # color: green
128
+ # &.bar
129
+ # color: blue
130
+ #
131
+ # This has the side effect of nesting rules,
132
+ # so that
134
133
  #
135
134
  # foo
136
135
  # color: green
@@ -143,31 +142,28 @@ module Sass
143
142
  #
144
143
  # foo
145
144
  # color: green
146
- # bar
145
+ # & bar
147
146
  # color: red
148
- # baz
147
+ # & baz
149
148
  # color: blue
150
149
  #
151
150
  # @param root [Tree::Node] The parent node
152
- def nest_seqs(root)
151
+ def parent_ref_rules(root)
153
152
  current_rule = nil
154
153
  root.children.map! do |child|
155
154
  unless child.is_a?(Tree::RuleNode)
156
- nest_seqs(child) if child.is_a?(Tree::DirectiveNode)
155
+ parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode)
157
156
  next child
158
157
  end
159
158
 
160
- seq = first_seq(child)
161
- seq.members.reject! {|sseq| sseq == "\n"}
162
- first, rest = seq.members.first, seq.members[1..-1]
159
+ first, rest = child.rule.first.scan(/\A(&?(?: .|[^ ])[^.#: \[]*)([.#: \[].*)?\Z/m).first
163
160
 
164
- if current_rule.nil? || first_sseq(current_rule) != first
165
- current_rule = Tree::RuleNode.new([])
166
- current_rule.parsed_rules = make_seq(first)
161
+ if current_rule.nil? || current_rule.rule.first != first
162
+ current_rule = Tree::RuleNode.new([first])
167
163
  end
168
164
 
169
- unless rest.empty?
170
- child.parsed_rules = make_seq(*rest)
165
+ if rest
166
+ child.rule = ["&" + rest]
171
167
  current_rule << child
172
168
  else
173
169
  current_rule.children += child.children
@@ -178,57 +174,32 @@ module Sass
178
174
  root.children.compact!
179
175
  root.children.uniq!
180
176
 
181
- root.children.each {|v| nest_seqs(v)}
177
+ root.children.each { |v| parent_ref_rules(v) }
182
178
  end
183
179
 
184
- # Make rules use parent refs so that
180
+ # Remove useless parent refs so that
185
181
  #
186
182
  # foo
187
- # color: green
188
- # foo.bar
189
- # color: blue
183
+ # & bar
184
+ # color: blue
190
185
  #
191
186
  # becomes
192
187
  #
193
188
  # foo
194
- # color: green
195
- # &.bar
189
+ # bar
196
190
  # color: blue
197
191
  #
198
192
  # @param root [Tree::Node] The parent node
199
- def parent_ref_rules(root)
200
- current_rule = nil
201
- root.children.map! do |child|
202
- unless child.is_a?(Tree::RuleNode)
203
- parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode)
204
- next child
205
- end
206
-
207
- sseq = first_sseq(child)
208
- next child unless sseq.is_a?(Sass::Selector::SimpleSequence)
209
-
210
- firsts, rest = [sseq.members.first], sseq.members[1..-1]
211
- firsts.push rest.shift if firsts.first.is_a?(Sass::Selector::Parent)
212
-
213
- if current_rule.nil? || first_sseq(current_rule).members != firsts
214
- current_rule = Tree::RuleNode.new([])
215
- current_rule.parsed_rules = make_sseq(*firsts)
216
- end
217
-
218
- unless rest.empty?
219
- rest.unshift Sass::Selector::Parent.new
220
- child.parsed_rules = make_sseq(*rest)
221
- current_rule << child
222
- else
223
- current_rule.children += child.children
193
+ def remove_parent_refs(root)
194
+ root.children.each do |child|
195
+ case child
196
+ when Tree::RuleNode
197
+ child.rule.first.gsub! /^& +/, ''
198
+ remove_parent_refs child
199
+ when Tree::DirectiveNode
200
+ remove_parent_refs child
224
201
  end
225
-
226
- current_rule
227
202
  end
228
- root.children.compact!
229
- root.children.uniq!
230
-
231
- root.children.each {|v| parent_ref_rules(v)}
232
203
  end
233
204
 
234
205
  # Flatten rules so that
@@ -265,7 +236,7 @@ module Sass
265
236
  end
266
237
  end
267
238
 
268
- # Flattens a single rule.
239
+ # Flattens a single rule
269
240
  #
270
241
  # @param rule [Tree::RuleNode] The candidate for flattening
271
242
  # @see #flatten_rules
@@ -273,10 +244,10 @@ module Sass
273
244
  while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
274
245
  child = rule.children.first
275
246
 
276
- if first_simple_sel(child).is_a?(Sass::Selector::Parent)
277
- rule.parsed_rules = child.parsed_rules.resolve_parent_refs(rule.parsed_rules)
247
+ if child.rule.first[0] == ?&
248
+ rule.rule = [child.rule.first.gsub(/^&/, rule.rule.first)]
278
249
  else
279
- rule.parsed_rules = make_seq(first_sseq(rule), *first_seq(child).members)
250
+ rule.rule = ["#{rule.rule.first} #{child.rule.first}"]
280
251
  end
281
252
 
282
253
  rule.children = child.children
@@ -309,7 +280,7 @@ module Sass
309
280
  end
310
281
 
311
282
  if prev_rule && prev_rule.children == child.children
312
- prev_rule.parsed_rules.members << first_seq(child)
283
+ prev_rule.rule.first << ", #{child.rule.first}"
313
284
  next nil
314
285
  end
315
286
 
@@ -319,72 +290,5 @@ module Sass
319
290
  end
320
291
  root.children.compact!
321
292
  end
322
-
323
- # Dump all the parsed {Sass::Tree::RuleNode} selectors to strings.
324
- #
325
- # @param root [Tree::Node] The parent node
326
- def dump_selectors(root)
327
- root.children.each do |child|
328
- next dump_selectors(child) if child.is_a?(Tree::DirectiveNode)
329
- next unless child.is_a?(Tree::RuleNode)
330
- child.rule = [child.parsed_rules.to_s]
331
- dump_selectors(child)
332
- end
333
- end
334
-
335
- # Create a {Sass::Selector::CommaSequence}.
336
- #
337
- # @param seqs [Array<Sass::Selector::Sequence>]
338
- # @return [Sass::Selector::CommaSequence]
339
- def make_cseq(*seqs)
340
- Sass::Selector::CommaSequence.new(seqs)
341
- end
342
-
343
- # Create a {Sass::Selector::CommaSequence} containing only a single
344
- # {Sass::Selector::Sequence}.
345
- #
346
- # @param sseqs [Array<Sass::Selector::Sequence, String>]
347
- # @return [Sass::Selector::CommaSequence]
348
- def make_seq(*sseqs)
349
- make_cseq(Sass::Selector::Sequence.new(sseqs))
350
- end
351
-
352
- # Create a {Sass::Selector::CommaSequence} containing only a single
353
- # {Sass::Selector::Sequence} which in turn contains only a single
354
- # {Sass::Selector::SimpleSequence}.
355
- #
356
- # @param sseqs [Array<Sass::Selector::Sequence, String>]
357
- # @return [Sass::Selector::CommaSequence]
358
- def make_sseq(*sseqs)
359
- make_seq(Sass::Selector::SimpleSequence.new(sseqs))
360
- end
361
-
362
- # Return the first {Sass::Selector::Sequence} in a {Sass::Tree::RuleNode}.
363
- #
364
- # @param rule [Sass::Tree::RuleNode]
365
- # @return [Sass::Selector::Sequence]
366
- def first_seq(rule)
367
- rule.parsed_rules.members.first
368
- end
369
-
370
- # Return the first {Sass::Selector::SimpleSequence} in a
371
- # {Sass::Tree::RuleNode}.
372
- #
373
- # @param rule [Sass::Tree::RuleNode]
374
- # @return [Sass::Selector::SimpleSequence, String]
375
- def first_sseq(rule)
376
- first_seq(rule).members.first
377
- end
378
-
379
- # Return the first {Sass::Selector::Simple} in a {Sass::Tree::RuleNode},
380
- # unless the rule begins with a combinator.
381
- #
382
- # @param rule [Sass::Tree::RuleNode]
383
- # @return [Sass::Selector::Simple?]
384
- def first_simple_sel(rule)
385
- sseq = first_sseq(rule)
386
- return unless sseq.is_a?(Sass::Selector::SimpleSequence)
387
- sseq.members.first
388
- end
389
293
  end
390
294
  end
@@ -1,3 +1,4 @@
1
+ require 'strscan'
1
2
  require 'set'
2
3
  require 'digest/sha1'
3
4
  require 'sass/cache_stores'
@@ -25,11 +26,8 @@ require 'sass/tree/charset_node'
25
26
  require 'sass/tree/visitors/base'
26
27
  require 'sass/tree/visitors/perform'
27
28
  require 'sass/tree/visitors/cssize'
28
- require 'sass/tree/visitors/extend'
29
29
  require 'sass/tree/visitors/convert'
30
30
  require 'sass/tree/visitors/to_css'
31
- require 'sass/tree/visitors/deep_copy'
32
- require 'sass/tree/visitors/set_options'
33
31
  require 'sass/tree/visitors/check_nesting'
34
32
  require 'sass/selector'
35
33
  require 'sass/environment'
@@ -90,10 +88,7 @@ module Sass
90
88
  #
91
89
  # `children`: `Array<Line>`
92
90
  # : The lines nested below this one.
93
- #
94
- # `comment_tab_str`: `String?`
95
- # : The prefix indentation for this comment, if it is a comment.
96
- class Line < Struct.new(:text, :tabs, :index, :offset, :filename, :children, :comment_tab_str)
91
+ class Line < Struct.new(:text, :tabs, :index, :offset, :filename, :children)
97
92
  def comment?
98
93
  text[0] == COMMENT_CHAR && (text[1] == SASS_COMMENT_CHAR || text[1] == CSS_COMMENT_CHAR)
99
94
  end
@@ -110,10 +105,6 @@ module Sass
110
105
  # which is not output as a CSS comment.
111
106
  SASS_COMMENT_CHAR = ?/
112
107
 
113
- # The character that indicates that a comment allows interpolation
114
- # and should be preserved even in `:compressed` mode.
115
- SASS_LOUD_COMMENT_CHAR = ?!
116
-
117
108
  # The character that follows the general COMMENT_CHAR and designates a CSS comment,
118
109
  # which is embedded in the CSS document.
119
110
  CSS_COMMENT_CHAR = ?*
@@ -219,7 +210,7 @@ module Sass
219
210
  # If you're compiling a single Sass file from the filesystem,
220
211
  # use \{Sass::Engine.for\_file}.
221
212
  # If you're compiling multiple files from the filesystem,
222
- # use {Sass::Plugin}.
213
+ # use {Sass::Plugin.
223
214
  #
224
215
  # @param template [String] The Sass template.
225
216
  # This template can be encoded using any encoding
@@ -316,6 +307,7 @@ module Sass
316
307
  sha = Digest::SHA1.hexdigest(@template)
317
308
 
318
309
  if root = @options[:cache_store].retrieve(key, sha)
310
+ @options = root.options.merge(@options)
319
311
  root.options = @options
320
312
  return root
321
313
  end
@@ -324,7 +316,7 @@ module Sass
324
316
  check_encoding!
325
317
 
326
318
  if @options[:syntax] == :scss
327
- root = Sass::SCSS::Parser.new(@template, @options[:filename]).parse
319
+ root = Sass::SCSS::Parser.new(@template).parse
328
320
  else
329
321
  root = Tree::RootNode.new(@template)
330
322
  append_children(root, tree(tabulate(@template)).first, true)
@@ -334,7 +326,7 @@ module Sass
334
326
  if @options[:cache] && key && sha
335
327
  begin
336
328
  old_options = root.options
337
- root.options = {}
329
+ root.options = {:importer => root.options[:importer]}
338
330
  @options[:cache_store].store(key, sha, root)
339
331
  ensure
340
332
  root.options = old_options
@@ -427,8 +419,7 @@ but this line was indented by #{Sass::Shared.human_indentation line[/^\s*/]}.
427
419
  MSG
428
420
  end
429
421
 
430
- last.comment_tab_str ||= comment_tab_str
431
- last.text << "\n" << line
422
+ last.text << "\n" << $1
432
423
  true
433
424
  end
434
425
 
@@ -494,8 +485,8 @@ MSG
494
485
  if child.is_a?(Tree::CommentNode) && child.silent
495
486
  if continued_comment &&
496
487
  child.line == continued_comment.line +
497
- continued_comment.lines + 1
498
- continued_comment.value += ["\n"] + child.value
488
+ continued_comment.value.count("\n") + 1
489
+ continued_comment.value << "\n" << child.value
499
490
  next
500
491
  end
501
492
 
@@ -546,7 +537,7 @@ WARNING
546
537
  when ?$
547
538
  parse_variable(line)
548
539
  when COMMENT_CHAR
549
- parse_comment(line)
540
+ parse_comment(line.text)
550
541
  when DIRECTIVE_CHAR
551
542
  parse_directive(parent, line, root)
552
543
  when ESCAPE_CHAR
@@ -565,9 +556,9 @@ WARNING
565
556
  end
566
557
 
567
558
  def parse_property_or_rule(line)
568
- scanner = Sass::Util::MultibyteStringScanner.new(line.text)
559
+ scanner = StringScanner.new(line.text)
569
560
  hack_char = scanner.scan(/[:\*\.]|\#(?!\{)/)
570
- parser = Sass::SCSS::SassParser.new(scanner, @options[:filename], @line)
561
+ parser = Sass::SCSS::SassParser.new(scanner, @line)
571
562
 
572
563
  unless res = parser.parse_interp_ident
573
564
  return Tree::RuleNode.new(parse_interp(line.text))
@@ -608,21 +599,13 @@ WARNING
608
599
  end
609
600
 
610
601
  def parse_comment(line)
611
- if line.text[1] == CSS_COMMENT_CHAR || line.text[1] == SASS_COMMENT_CHAR
612
- silent = line.text[1] == SASS_COMMENT_CHAR
613
- if loud = line.text[2] == SASS_LOUD_COMMENT_CHAR
614
- value = self.class.parse_interp(line.text, line.index, line.offset, :filename => @filename)
615
- value[0].slice!(2) # get rid of the "!"
616
- else
617
- value = [line.text]
618
- end
619
- value = with_extracted_values(value) do |str|
620
- str = str.gsub(/^#{line.comment_tab_str}/m, '')[2..-1] # get rid of // or /*
621
- format_comment_text(str, silent)
622
- end
623
- Tree::CommentNode.new(value, silent, loud)
602
+ if line[1] == CSS_COMMENT_CHAR || line[1] == SASS_COMMENT_CHAR
603
+ silent = line[1] == SASS_COMMENT_CHAR
604
+ Tree::CommentNode.new(
605
+ format_comment_text(line[2..-1], silent),
606
+ silent)
624
607
  else
625
- Tree::RuleNode.new(parse_interp(line.text))
608
+ Tree::RuleNode.new(parse_interp(line))
626
609
  end
627
610
  end
628
611
 
@@ -683,7 +666,7 @@ WARNING
683
666
  :line => @line + 1) unless line.children.empty?
684
667
  Tree::CharsetNode.new(name)
685
668
  elsif directive == "media"
686
- Tree::MediaNode.new(value.split(',').map {|s| s.strip})
669
+ Tree::MediaNode.new(value)
687
670
  else
688
671
  Tree::DirectiveNode.new(line.text)
689
672
  end
@@ -749,7 +732,7 @@ WARNING
749
732
  raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.",
750
733
  :line => @line + 1) unless line.children.empty?
751
734
 
752
- scanner = Sass::Util::MultibyteStringScanner.new(value)
735
+ scanner = StringScanner.new(value)
753
736
  values = []
754
737
 
755
738
  loop do
@@ -761,11 +744,6 @@ WARNING
761
744
  break unless scanner.scan(/,\s*/)
762
745
  end
763
746
 
764
- if scanner.scan(/;/)
765
- raise SyntaxError.new("Invalid @import: expected end of line, was \";\".",
766
- :line => @line)
767
- end
768
-
769
747
  return values
770
748
  end
771
749
 
@@ -773,19 +751,17 @@ WARNING
773
751
  return if scanner.eos?
774
752
  unless (str = scanner.scan(Sass::SCSS::RX::STRING)) ||
775
753
  (uri = scanner.scan(Sass::SCSS::RX::URI))
776
- return Tree::ImportNode.new(scanner.scan(/[^,;]+/))
754
+ return Tree::ImportNode.new(scanner.scan(/[^,]+/))
777
755
  end
778
756
 
779
757
  val = scanner[1] || scanner[2]
780
758
  scanner.scan(/\s*/)
781
- if media = scanner.scan(/[a-zA-Z].*/)
759
+ if media = scanner.scan(/[^,].*/)
782
760
  Tree::DirectiveNode.new("@import #{str || uri} #{media}")
783
- elsif !scanner.match?(/[,;]|$/)
784
- raise SyntaxError.new("Invalid @import: \"#{str || uri} #{scanner.rest}\"")
785
761
  elsif uri
786
762
  Tree::DirectiveNode.new("@import #{uri}")
787
763
  elsif val =~ /^http:\/\//
788
- Tree::DirectiveNode.new("@import #{str}")
764
+ Tree::DirectiveNode.new("@import url(#{val})")
789
765
  else
790
766
  Tree::ImportNode.new(val)
791
767
  end