` element with the given class.
- DIV_CLASS = ?.
-
- # Designates a `
` element with the given id.
- DIV_ID = ?#
-
- # Designates an XHTML/XML comment.
- COMMENT = ?/
-
- # Designates an XHTML doctype or script that is never HTML-escaped.
- DOCTYPE = ?!
-
- # Designates script, the result of which is output.
- SCRIPT = ?=
-
- # Designates script that is always HTML-escaped.
- SANITIZE = ?&
-
- # Designates script, the result of which is flattened and output.
- FLAT_SCRIPT = ?~
-
- # Designates script which is run but not output.
- SILENT_SCRIPT = ?-
-
- # When following SILENT_SCRIPT, designates a comment that is not output.
- SILENT_COMMENT = ?#
-
- # Designates a non-parsed line.
- ESCAPE = ?\\
-
- # Designates a block of filtered text.
- FILTER = ?:
-
- # Designates a non-parsed line. Not actually a character.
- PLAIN_TEXT = -1
-
- # Keeps track of the ASCII values of the characters that begin a
- # specially-interpreted line.
- SPECIAL_CHARACTERS = [
- ELEMENT,
- DIV_CLASS,
- DIV_ID,
- COMMENT,
- DOCTYPE,
- SCRIPT,
- SANITIZE,
- FLAT_SCRIPT,
- SILENT_SCRIPT,
- ESCAPE,
- FILTER
- ]
-
- # The value of the character that designates that a line is part
- # of a multiline string.
- MULTILINE_CHAR_VALUE = ?|
-
- # Regex to match keywords that appear in the middle of a Ruby block
- # with lowered indentation.
- # If a block has been started using indentation,
- # lowering the indentation with one of these won't end the block.
- # For example:
- #
- # - if foo
- # %p yes!
- # - else
- # %p no!
- #
- # The block is ended after `%p no!`, because `else`
- # is a member of this array.
- MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
-
- # The Regex that matches a Doctype command.
- DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)/i
-
- # The Regex that matches a literal string or symbol value
- LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/
-
- private
-
- # Returns the precompiled string with the preamble and postamble
- def precompiled_with_ambles(local_names)
- preamble = < 1
- raise SyntaxError.new("The line was indented #{@next_line.tabs - @line.tabs} levels deeper than the previous line.", @next_line.index)
- end
-
- resolve_newlines unless @next_line.eod?
- @line = @next_line
- newline unless @next_line.eod?
- end
-
- # Close all the open tags
- close until @to_close_stack.empty?
- flush_merged_text
- end
-
- # Processes and deals with lowering indentation.
- def process_indent(line)
- return unless line.tabs <= @template_tabs && @template_tabs > 0
-
- to_close = @template_tabs - line.tabs
- to_close.times {|i| close unless to_close - 1 - i == 0 && mid_block_keyword?(line.text)}
- end
-
- # Processes a single line of Haml.
- #
- # This method doesn't return anything; it simply processes the line and
- # adds the appropriate code to `@precompiled`.
- def process_line(text, index)
- @index = index + 1
-
- case text[0]
- when DIV_CLASS; render_div(text)
- when DIV_ID
- return push_plain(text) if text[1] == ?{
- render_div(text)
- when ELEMENT; render_tag(text)
- when COMMENT; render_comment(text[1..-1].strip)
- when SANITIZE
- return push_plain(text[3..-1].strip, :escape_html => true) if text[1..2] == "=="
- return push_script(text[2..-1].strip, :escape_html => true) if text[1] == SCRIPT
- return push_flat_script(text[2..-1].strip, :escape_html => true) if text[1] == FLAT_SCRIPT
- return push_plain(text[1..-1].strip, :escape_html => true) if text[1] == ?\s
- push_plain text
- when SCRIPT
- return push_plain(text[2..-1].strip) if text[1] == SCRIPT
- push_script(text[1..-1])
- when FLAT_SCRIPT; push_flat_script(text[1..-1])
- when SILENT_SCRIPT
- return start_haml_comment if text[1] == SILENT_COMMENT
-
- raise SyntaxError.new(< false) if text[1..2] == "=="
- return push_script(text[2..-1].strip, :escape_html => false) if text[1] == SCRIPT
- return push_flat_script(text[2..-1].strip, :escape_html => false) if text[1] == FLAT_SCRIPT
- return push_plain(text[1..-1].strip, :escape_html => false) if text[1] == ?\s
- push_plain text
- when ESCAPE; push_plain text[1..-1]
- else push_plain text
- end
- end
-
- # If the text is a silent script text with one of Ruby's mid-block keywords,
- # returns the name of that keyword.
- # Otherwise, returns nil.
- def mid_block_keyword?(text)
- text[MID_BLOCK_KEYWORD_REGEX, 1]
- end
-
- # Evaluates `text` in the context of the scope object, but
- # does not output the result.
- def push_silent(text, can_suppress = false)
- flush_merged_text
- return if can_suppress && options[:suppress_eval]
- @precompiled << "#{text};"
- end
-
- # Adds `text` to `@buffer` with appropriate tabulation
- # without parsing it.
- def push_merged_text(text, tab_change = 0, indent = true)
- text = !indent || @dont_indent_next_line || @options[:ugly] ? text : "#{' ' * @output_tabs}#{text}"
- @to_merge << [:text, text, tab_change]
- @dont_indent_next_line = false
- end
-
- # Concatenate `text` to `@buffer` without tabulation.
- def concat_merged_text(text)
- @to_merge << [:text, text, 0]
- end
-
- def push_text(text, tab_change = 0)
- push_merged_text("#{text}\n", tab_change)
- end
-
- def flush_merged_text
- return if @to_merge.empty?
-
- text, tab_change = @to_merge.inject(["", 0]) do |(str, mtabs), (type, val, tabs)|
- case type
- when :text
- [str << val.inspect[1...-1], mtabs + tabs]
- when :script
- if mtabs != 0 && !@options[:ugly]
- val = "_hamlout.adjust_tabs(#{mtabs}); " + val
- end
- [str << "\#{#{val}}", 0]
- else
- raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Precompiler@to_merge.")
- end
- end
-
- @precompiled <<
- if @options[:ugly]
- "_hamlout.buffer << \"#{text}\";"
- else
- "_hamlout.push_text(\"#{text}\", #{tab_change}, #{@dont_tab_up_next_text.inspect});"
- end
- @to_merge = []
- @dont_tab_up_next_text = false
- end
-
- # Renders a block of text as plain text.
- # Also checks for an illegally opened block.
- def push_plain(text, options = {})
- if block_opened?
- raise SyntaxError.new("Illegal nesting: nesting within plain text is illegal.", @next_line.index)
- end
-
- if contains_interpolation?(text)
- options[:escape_html] = self.options[:escape_html] if options[:escape_html].nil?
- push_script(
- unescape_interpolation(text, :escape_html => options[:escape_html]),
- :escape_html => false)
- else
- push_text text
- end
- end
-
- # Adds +text+ to `@buffer` while flattening text.
- def push_flat(line)
- text = line.full.dup
- text = "" unless text.gsub!(/^#{@flat_spaces}/, '')
- @filter_buffer << "#{text}\n"
- end
-
- # Causes `text` to be evaluated in the context of
- # the scope object and the result to be added to `@buffer`.
- #
- # If `opts[:preserve_script]` is true, Haml::Helpers#find_and_flatten is run on
- # the result before it is added to `@buffer`
- def push_script(text, opts = {})
- raise SyntaxError.new("There's no Ruby code for = to evaluate.") if text.empty?
- return if options[:suppress_eval]
- opts[:escape_html] = options[:escape_html] if opts[:escape_html].nil?
-
- args = %w[preserve_script in_tag preserve_tag escape_html nuke_inner_whitespace]
- args.map! {|name| opts[name.to_sym]}
- args << !block_opened? << @options[:ugly]
-
- no_format = @options[:ugly] &&
- !(opts[:preserve_script] || opts[:preserve_tag] || opts[:escape_html])
- output_temp = "(haml_very_temp = haml_temp; haml_temp = nil; haml_very_temp)"
- out = "_hamlout.#{static_method_name(:format_script, *args)}(#{output_temp});"
-
- # Prerender tabulation unless we're in a tag
- push_merged_text '' unless opts[:in_tag]
-
- unless block_opened?
- @to_merge << [:script, no_format ? "#{text}\n" : "haml_temp = #{text}\n#{out}"]
- concat_merged_text("\n") unless opts[:in_tag] || opts[:nuke_inner_whitespace]
- @newlines -= 1
- return
- end
-
- flush_merged_text
-
- push_silent "haml_temp = #{text}"
- newline_now
- push_and_tabulate([:loud, "_hamlout.buffer << #{no_format ? "#{output_temp}.to_s;" : out}",
- !(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly])])
- end
-
- # Causes `text` to be evaluated, and Haml::Helpers#find_and_flatten
- # to be run on it afterwards.
- def push_flat_script(text, options = {})
- flush_merged_text
-
- raise SyntaxError.new("There's no Ruby code for ~ to evaluate.") if text.empty?
- push_script(text, options.merge(:preserve_script => true))
- end
-
- def start_haml_comment
- return unless block_opened?
-
- @haml_comment = true
- push_and_tabulate([:haml_comment])
- end
-
- # Closes the most recent item in `@to_close_stack`.
- def close
- tag, *rest = @to_close_stack.pop
- send("close_#{tag}", *rest)
- end
-
- # Puts a line in `@precompiled` that will add the closing tag of
- # the most recently opened tag.
- def close_element(value)
- tag, nuke_outer_whitespace, nuke_inner_whitespace = value
- @output_tabs -= 1 unless nuke_inner_whitespace
- @template_tabs -= 1
- rstrip_buffer! if nuke_inner_whitespace
- push_merged_text("#{tag}>" + (nuke_outer_whitespace ? "" : "\n"),
- nuke_inner_whitespace ? 0 : -1, !nuke_inner_whitespace)
- @dont_indent_next_line = nuke_outer_whitespace
- end
-
- # Closes a Ruby block.
- def close_script(_1, _2, push_end = true)
- push_silent("end", true) if push_end
- @template_tabs -= 1
- end
-
- # Closes a comment.
- def close_comment(has_conditional)
- @output_tabs -= 1
- @template_tabs -= 1
- close_tag = has_conditional ? "" : "-->"
- push_text(close_tag, -1)
- end
-
- # Closes a loud Ruby block.
- def close_loud(command, add_newline, push_end = true)
- push_silent('end', true) if push_end
- @precompiled << command
- @template_tabs -= 1
- concat_merged_text("\n") if add_newline
- end
-
- # Closes a filtered block.
- def close_filtered(filter)
- filter.internal_compile(self, @filter_buffer)
- @flat = false
- @flat_spaces = nil
- @filter_buffer = nil
- @template_tabs -= 1
- end
-
- def close_haml_comment
- @haml_comment = false
- @template_tabs -= 1
- end
-
- def close_nil(*args)
- @template_tabs -= 1
- end
-
- # Iterates through the classes and ids supplied through `.`
- # and `#` syntax, and returns a hash with them as attributes,
- # that can then be merged with another attributes hash.
- def parse_class_and_id(list)
- attributes = {}
- list.scan(/([#.])([-_a-zA-Z0-9]+)/) do |type, property|
- case type
- when '.'
- if attributes['class']
- attributes['class'] += " "
- else
- attributes['class'] = ""
- end
- attributes['class'] += property
- when '#'; attributes['id'] = property
- end
- end
- attributes
- end
-
- def parse_static_hash(text)
- attributes = {}
- scanner = StringScanner.new(text)
- scanner.scan(/\s+/)
- until scanner.eos?
- return unless key = scanner.scan(LITERAL_VALUE_REGEX)
- return unless scanner.scan(/\s*=>\s*/)
- return unless value = scanner.scan(LITERAL_VALUE_REGEX)
- return unless scanner.scan(/\s*(?:,|$)\s*/)
- attributes[eval(key).to_s] = eval(value).to_s
- end
- text.count("\n").times { newline }
- attributes
- end
-
- # This is a class method so it can be accessed from Buffer.
- def self.build_attributes(is_html, attr_wrapper, attributes = {})
- quote_escape = attr_wrapper == '"' ? """ : "'"
- other_quote_char = attr_wrapper == '"' ? "'" : '"'
-
- result = attributes.collect do |attr, value|
- next if value.nil?
-
- if value == true
- next " #{attr}" if is_html
- next " #{attr}=#{attr_wrapper}#{attr}#{attr_wrapper}"
- elsif value == false
- next
- end
-
- value = Haml::Helpers.preserve(Haml::Helpers.escape_once(value.to_s))
- # We want to decide whether or not to escape quotes
- value.gsub!('"', '"')
- this_attr_wrapper = attr_wrapper
- if value.include? attr_wrapper
- if value.include? other_quote_char
- value = value.gsub(attr_wrapper, quote_escape)
- else
- this_attr_wrapper = other_quote_char
- end
- end
- " #{attr}=#{this_attr_wrapper}#{value}#{this_attr_wrapper}"
- end
- result.compact.sort.join
- end
-
- def prerender_tag(name, self_close, attributes)
- attributes_string = Precompiler.build_attributes(html?, @options[:attr_wrapper], attributes)
- "<#{name}#{attributes_string}#{self_close && xhtml? ? ' /' : ''}>"
- end
-
- # Parses a line into tag_name, attributes, attributes_hash, object_ref, action, value
- def parse_tag(line)
- raise SyntaxError.new("Invalid tag: \"#{line}\".") unless match = line.scan(/%([-:\w]+)([-\w\.\#]*)(.*)/)[0]
- tag_name, attributes, rest = match
- new_attributes_hash = old_attributes_hash = last_line = object_ref = nil
- attributes_hashes = []
- while rest
- case rest[0]
- when ?{
- break if old_attributes_hash
- old_attributes_hash, rest, last_line = parse_old_attributes(rest)
- attributes_hashes << [:old, old_attributes_hash]
- when ?(
- break if new_attributes_hash
- new_attributes_hash, rest, last_line = parse_new_attributes(rest)
- attributes_hashes << [:new, new_attributes_hash]
- when ?[
- break if object_ref
- object_ref, rest = balance(rest, ?[, ?])
- else; break
- end
- end
-
- if rest
- nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\/\~&!])?(.*)?/)[0]
- nuke_whitespace ||= ''
- nuke_outer_whitespace = nuke_whitespace.include? '>'
- nuke_inner_whitespace = nuke_whitespace.include? '<'
- end
-
- value = value.to_s.strip
- [tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
- nuke_inner_whitespace, action, value, last_line || @index]
- end
-
- def parse_old_attributes(line)
- line = line.dup
- last_line = @index
-
- begin
- attributes_hash, rest = balance(line, ?{, ?})
- rescue SyntaxError => e
- if line.strip[-1] == ?, && e.message == "Unbalanced brackets."
- line << "\n" << @next_line.text
- last_line += 1
- next_line
- retry
- end
-
- raise e
- end
-
- attributes_hash = attributes_hash[1...-1] if attributes_hash
- return attributes_hash, rest, last_line
- end
-
- def parse_new_attributes(line)
- line = line.dup
- scanner = StringScanner.new(line)
- last_line = @index
- attributes = {}
-
- scanner.scan(/\(\s*/)
- loop do
- name, value = parse_new_attribute(scanner)
- break if name.nil?
-
- if name == false
- text = (Haml::Shared.balance(line, ?(, ?)) || [line]).first
- raise Haml::SyntaxError.new("Invalid attribute list: #{text.inspect}.", last_line - 1)
- end
- attributes[name] = value
- scanner.scan(/\s*/)
-
- if scanner.eos?
- line << " " << @next_line.text
- last_line += 1
- next_line
- scanner.scan(/\s*/)
- end
- end
-
- static_attributes = {}
- dynamic_attributes = "{"
- attributes.each do |name, (type, val)|
- if type == :static
- static_attributes[name] = val
- else
- dynamic_attributes << name.inspect << " => " << val << ","
- end
- end
- dynamic_attributes << "}"
- dynamic_attributes = nil if dynamic_attributes == "{}"
-
- return [static_attributes, dynamic_attributes], scanner.rest, last_line
- end
-
- def parse_new_attribute(scanner)
- unless name = scanner.scan(/[-:\w]+/)
- return if scanner.scan(/\)/)
- return false
- end
-
- scanner.scan(/\s*/)
- return name, [:static, true] unless scanner.scan(/=/) #/end
-
- scanner.scan(/\s*/)
- unless quote = scanner.scan(/["']/)
- return false unless var = scanner.scan(/(@@?|\$)?\w+/)
- return name, [:dynamic, var]
- end
-
- re = /((?:\\.|\#[^{]|[^#{quote}\\#])*#?)(#{quote}|#\{)/
- content = []
- loop do
- return false unless scanner.scan(re)
- content << [:str, scanner[1].gsub(/\\(.)/, '\1')]
- break if scanner[2] == quote
- content << [:ruby, balance(scanner, ?{, ?}, 1).first[0...-1]]
- end
-
- return name, [:static, content.first[1]] if content.size == 1
- return name, [:dynamic,
- '"' + content.map {|(t, v)| t == :str ? v.inspect[1...-1] : "\#{#{v}}"}.join + '"']
- end
-
- # Parses a line that will render as an XHTML tag, and adds the code that will
- # render that tag to `@precompiled`.
- def render_tag(line)
- tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
- nuke_inner_whitespace, action, value, last_line = parse_tag(line)
-
- raise SyntaxError.new("Illegal element: classes and ids must have values.") if attributes =~ /[\.#](\.|#|\z)/
-
- # Get rid of whitespace outside of the tag if we need to
- rstrip_buffer! if nuke_outer_whitespace
-
- preserve_tag = options[:preserve].include?(tag_name)
- nuke_inner_whitespace ||= preserve_tag
- preserve_tag &&= !options[:ugly]
-
- escape_html = (action == '&' || (action != '!' && @options[:escape_html]))
-
- case action
- when '/'; self_closing = true
- when '~'; parse = preserve_script = true
- when '='
- parse = true
- if value[0] == ?=
- value = unescape_interpolation(value[1..-1].strip, :escape_html => escape_html)
- escape_html = false
- end
- when '&', '!'
- if value[0] == ?= || value[0] == ?~
- parse = true
- preserve_script = (value[0] == ?~)
- if value[1] == ?=
- value = unescape_interpolation(value[2..-1].strip, :escape_html => escape_html)
- escape_html = false
- else
- value = value[1..-1].strip
- end
- elsif contains_interpolation?(value)
- value = unescape_interpolation(value, :escape_html => escape_html)
- parse = true
- escape_html = false
- end
- else
- if contains_interpolation?(value)
- value = unescape_interpolation(value, :escape_html => escape_html)
- parse = true
- escape_html = false
- end
- end
-
- if parse && @options[:suppress_eval]
- parse = false
- value = ''
- end
-
- object_ref = "nil" if object_ref.nil? || @options[:suppress_eval]
-
- attributes = parse_class_and_id(attributes)
- attributes_hashes.map! do |syntax, attributes_hash|
- if syntax == :old
- static_attributes = parse_static_hash(attributes_hash)
- attributes_hash = nil if static_attributes || @options[:suppress_eval]
- else
- static_attributes, attributes_hash = attributes_hash
- end
- Buffer.merge_attrs(attributes, static_attributes) if static_attributes
- attributes_hash
- end.compact!
-
- raise SyntaxError.new("Illegal nesting: nesting within a self-closing tag is illegal.", @next_line.index) if block_opened? && self_closing
- raise SyntaxError.new("Illegal nesting: content can't be both given on the same line as %#{tag_name} and nested within it.", @next_line.index) if block_opened? && !value.empty?
- raise SyntaxError.new("There's no Ruby code for #{action} to evaluate.", last_line - 1) if parse && value.empty?
- raise SyntaxError.new("Self-closing tags can't have content.", last_line - 1) if self_closing && !value.empty?
-
- self_closing ||= !!( !block_opened? && value.empty? && @options[:autoclose].include?(tag_name) )
- value = nil if value.empty? && (block_opened? || self_closing)
-
- dont_indent_next_line =
- (nuke_outer_whitespace && !block_opened?) ||
- (nuke_inner_whitespace && block_opened?)
-
- # Check if we can render the tag directly to text and not process it in the buffer
- if object_ref == "nil" && attributes_hashes.empty? && !preserve_script
- tag_closed = !block_opened? && !self_closing && !parse
-
- open_tag = prerender_tag(tag_name, self_closing, attributes)
- if tag_closed
- open_tag << "#{value}#{tag_name}>"
- open_tag << "\n" unless nuke_outer_whitespace
- else
- open_tag << "\n" unless parse || nuke_inner_whitespace || (self_closing && nuke_outer_whitespace)
- end
-
- push_merged_text(open_tag, tag_closed || self_closing || nuke_inner_whitespace ? 0 : 1,
- !nuke_outer_whitespace)
-
- @dont_indent_next_line = dont_indent_next_line
- return if tag_closed
- else
- flush_merged_text
- content = parse ? 'nil' : value.inspect
- if attributes_hashes.empty?
- attributes_hashes = ''
- elsif attributes_hashes.size == 1
- attributes_hashes = ", #{attributes_hashes.first}"
- else
- attributes_hashes = ", (#{attributes_hashes.join(").merge(")})"
- end
-
- args = [tag_name, self_closing, !block_opened?, preserve_tag, escape_html,
- attributes, nuke_outer_whitespace, nuke_inner_whitespace
- ].map { |v| v.inspect }.join(', ')
- push_silent "_hamlout.open_tag(#{args}, #{object_ref}, #{content}#{attributes_hashes})"
- @dont_tab_up_next_text = @dont_indent_next_line = dont_indent_next_line
- end
-
- return if self_closing
-
- if value.nil?
- push_and_tabulate([:element, [tag_name, nuke_outer_whitespace, nuke_inner_whitespace]])
- @output_tabs += 1 unless nuke_inner_whitespace
- return
- end
-
- if parse
- push_script(value, :preserve_script => preserve_script, :in_tag => true,
- :preserve_tag => preserve_tag, :escape_html => escape_html,
- :nuke_inner_whitespace => nuke_inner_whitespace)
- concat_merged_text("#{tag_name}>" + (nuke_outer_whitespace ? "" : "\n"))
- end
- end
-
- # Renders a line that creates an XHTML tag and has an implicit div because of
- # `.` or `#`.
- def render_div(line)
- render_tag('%div' + line)
- end
-
- # Renders an XHTML comment.
- def render_comment(line)
- conditional, line = balance(line, ?[, ?]) if line[0] == ?[
- line.strip!
- conditional << ">" if conditional
-
- if block_opened? && !line.empty?
- raise SyntaxError.new('Illegal nesting: nesting within a tag that already has content is illegal.', @next_line.index)
- end
-
- open = "" : "-->"}")
- end
-
- push_text(open, 1)
- @output_tabs += 1
- push_and_tabulate([:comment, !conditional.nil?])
- unless line.empty?
- push_text(line)
- close
- end
- end
-
- # Renders an XHTML doctype or XML shebang.
- def render_doctype(line)
- raise SyntaxError.new("Illegal nesting: nesting within a header command is illegal.", @next_line.index) if block_opened?
- doctype = text_for_doctype(line)
- push_text doctype if doctype
- end
-
- def text_for_doctype(text)
- text = text[3..-1].lstrip.downcase
- if text.index("xml") == 0
- return nil if html?
- wrapper = @options[:attr_wrapper]
- return ""
- end
-
- if html5?
- ''
- else
- version, type = text.scan(DOCTYPE_REGEX)[0]
-
- if xhtml?
- if version == "1.1"
- ''
- elsif version == "5"
- ''
- else
- case type
- when "strict"; ''
- when "frameset"; ''
- when "mobile"; ''
- when "basic"; ''
- else ''
- end
- end
-
- elsif html4?
- case type
- when "strict"; ''
- when "frameset"; ''
- else ''
- end
- end
- end
- end
-
- # Starts a filtered block.
- def start_filtered(name)
- raise Error.new("Invalid filter name \":#{name}\".") unless name =~ /^\w+$/
- raise Error.new("Filter \"#{name}\" is not defined.") unless filter = Filters.defined[name]
-
- push_and_tabulate([:filtered, filter])
- @flat = true
- @filter_buffer = String.new
-
- # If we don't know the indentation by now, it'll be set in Line#tabs
- @flat_spaces = @indentation * @template_tabs if @indentation
- end
-
- def raw_next_line
- text = @template.shift
- return unless text
-
- index = @template_index
- @template_index += 1
-
- return text, index
- end
-
- def next_line
- text, index = raw_next_line
- return unless text
-
- # :eod is a special end-of-document marker
- line =
- if text == :eod
- Line.new '-#', '-#', '-#', index, self, true
- else
- Line.new text.strip, text.lstrip.chomp, text, index, self, false
- end
-
- # `flat?' here is a little outdated,
- # so we have to manually check if either the previous or current line
- # closes the flat block,
- # as well as whether a new block is opened
- @line.tabs if @line
- unless (flat? && !closes_flat?(line) && !closes_flat?(@line)) ||
- (@line && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s])
- if line.text.empty?
- newline
- return next_line
- end
-
- handle_multiline(line)
- end
-
- @next_line = line
- end
-
- def closes_flat?(line)
- line && !line.text.empty? && line.full !~ /^#{@flat_spaces}/
- end
-
- def un_next_line(line)
- @template.unshift line
- @template_index -= 1
- end
-
- def handle_multiline(line)
- if is_multiline?(line.text)
- line.text.slice!(-1)
- while new_line = raw_next_line.first
- break if new_line == :eod
- newline and next if new_line.strip.empty?
- break unless is_multiline?(new_line.strip)
- line.text << new_line.strip[0...-1]
- newline
- end
- un_next_line new_line
- resolve_newlines
- end
- end
-
- # Checks whether or not +line+ is in a multiline sequence.
- def is_multiline?(text)
- text && text.length > 1 && text[-1] == MULTILINE_CHAR_VALUE && text[-2] == ?\s
- end
-
- def contains_interpolation?(str)
- str.include?('#{')
- end
-
- def unescape_interpolation(str, opts = {})
- res = ''
- rest = Haml::Shared.handle_interpolation str.dump do |scan|
- escapes = (scan[2].size - 1) / 2
- res << scan.matched[0...-3 - escapes]
- if escapes % 2 == 1
- res << '#{'
- else
- content = eval('"' + balance(scan, ?{, ?}, 1)[0][0...-1] + '"')
- content = "Haml::Helpers.html_escape(#{content})" if opts[:escape_html]
- res << '#{' + content + "}"# Use eval to get rid of string escapes
- end
- end
- res + rest
- end
-
- def balance(*args)
- res = Haml::Shared.balance(*args)
- return res if res
- raise SyntaxError.new("Unbalanced brackets.")
- end
-
- def block_opened?
- !flat? && @next_line.tabs > @line.tabs
- end
-
- # Pushes value onto `@to_close_stack` and increases
- # `@template_tabs`.
- def push_and_tabulate(value)
- @to_close_stack.push(value)
- @template_tabs += 1
- end
-
- def flat?
- @flat
- end
-
- def newline
- @newlines += 1
- end
-
- def newline_now
- @precompiled << "\n"
- @newlines -= 1
- end
-
- def resolve_newlines
- return unless @newlines > 0
- flush_merged_text unless @to_merge.all? {|type, *_| type == :text}
- @precompiled << "\n" * @newlines
- @newlines = 0
- end
-
- # Get rid of and whitespace at the end of the buffer
- # or the merged text
- def rstrip_buffer!(index = -1)
- last = @to_merge[index]
- if last.nil?
- push_silent("_hamlout.rstrip!", false)
- @dont_tab_up_next_text = true
- return
- end
-
- case last.first
- when :text
- last[1].rstrip!
- if last[1].empty?
- @to_merge.slice! index
- rstrip_buffer! index
- end
- when :script
- last[1].gsub!(/\(haml_temp, (.*?)\);$/, '(haml_temp.rstrip, \1);')
- rstrip_buffer! index - 1
- else
- raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Precompiler@to_merge.")
- end
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/shared.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/shared.rb
deleted file mode 100644
index f031fc44..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/shared.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'strscan'
-
-module Haml
- # This module contains functionality that's shared between Haml and Sass.
- module Shared
- extend self
-
- # Scans through a string looking for the interoplation-opening `#{`
- # and, when it's found, yields the scanner to the calling code
- # so it can handle it properly.
- #
- # The scanner will have any backslashes immediately in front of the `#{`
- # as the second capture group (`scan[2]`),
- # and the text prior to that as the first (`scan[1]`).
- #
- # @yieldparam scan [StringScanner] The scanner scanning through the string
- # @return [String] The text remaining in the scanner after all `#{`s have been processed
- def handle_interpolation(str)
- scan = StringScanner.new(str)
- yield scan while scan.scan(/(.*?)(\\*)\#\{/)
- scan.rest
- end
-
- # Moves a scanner through a balanced pair of characters.
- # For example:
- #
- # Foo (Bar (Baz bang) bop) (Bang (bop bip))
- # ^ ^
- # from to
- #
- # @param scanner [StringScanner] The string scanner to move
- # @param start [Character] The character opening the balanced pair.
- # A `Fixnum` in 1.8, a `String` in 1.9
- # @param finish [Character] The character closing the balanced pair.
- # A `Fixnum` in 1.8, a `String` in 1.9
- # @param count [Fixnum] The number of opening characters matched
- # before calling this method
- # @return [(String, String)] The string matched within the balanced pair
- # and the rest of the string.
- # `["Foo (Bar (Baz bang) bop)", " (Bang (bop bip))"]` in the example above.
- def balance(scanner, start, finish, count = 0)
- str = ''
- scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
- regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
- while scanner.scan(regexp)
- str << scanner.matched
- count += 1 if scanner.matched[-1] == start
- count -= 1 if scanner.matched[-1] == finish
- return [str.strip, scanner.rest] if count == 0
- end
- end
-
- # Formats a string for use in error messages about indentation.
- #
- # @param indentation [String] The string used for indentation
- # @param was [Boolean] Whether or not to add `"was"` or `"were"`
- # (depending on how many characters were in `indentation`)
- # @return [String] The name of the indentation (e.g. `"12 spaces"`, `"1 tab"`)
- def human_indentation(indentation, was = false)
- if !indentation.include?(?\t)
- noun = 'space'
- elsif !indentation.include?(?\s)
- noun = 'tab'
- else
- return indentation.inspect + (was ? ' was' : '')
- end
-
- singular = indentation.length == 1
- if was
- was = singular ? ' was' : ' were'
- else
- was = ''
- end
-
- "#{indentation.length} #{noun}#{'s' unless singular}#{was}"
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/template.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/template.rb
deleted file mode 100644
index 1aa26a46..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/template.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-require 'haml/engine'
-
-module Haml
- # The class that keeps track of the global options for Haml within Rails.
- module Template
- extend self
-
- @options = {}
- # The options hash for Haml when used within Rails.
- # See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.
- #
- # @return [{Symbol => Object}]
- attr_accessor :options
-
- # Enables integration with the Rails 2.2.5+ XSS protection,
- # if it's available and enabled.
- #
- # @return [Boolean] Whether the XSS integration was enabled.
- def try_enabling_xss_integration
- return false unless ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?
-
- Haml::Template.options[:escape_html] = true
-
- Haml::Util.module_eval {def rails_xss_safe?; true; end}
-
- require 'haml/helpers/xss_mods'
- Haml::Helpers.send(:include, Haml::Helpers::XssMods)
-
- Haml::Precompiler.module_eval do
- def precompiled_method_return_value_with_haml_xss
- "(#{precompiled_method_return_value_without_haml_xss}).html_safe!"
- end
- alias_method :precompiled_method_return_value_without_haml_xss, :precompiled_method_return_value
- alias_method :precompiled_method_return_value, :precompiled_method_return_value_with_haml_xss
- end
-
- true
- end
- end
-end
-
-if defined?(RAILS_ENV) && RAILS_ENV == "production"
- Haml::Template.options[:ugly] = true
-end
-
-# Decide how we want to load Haml into Rails.
-# Patching was necessary for versions <= 2.0.1,
-# but we can make it a normal handler for higher versions.
-if defined?(ActionView::TemplateHandler) || defined?(ActionView::Template::Handler)
- require 'haml/template/plugin'
-else
- require 'haml/template/patch'
-end
-
-# Enable XSS integration. Use Rails' after_initialize method if possible
-# so that integration will be checked after the rails_xss plugin is loaded
-# (for Rails 2.3.* where it's not enabled by default).
-if defined?(Rails.configuration.after_initialize)
- Rails.configuration.after_initialize {Haml::Template.try_enabling_xss_integration}
-else
- Haml::Template.try_enabling_xss_integration
-end
-
-if Haml::Util.rails_root
- # Update init.rb to the current version
- # if it's out of date.
- #
- # We can probably remove this as of v1.9,
- # because the new init file is sufficiently flexible
- # to not need updating.
- rails_init_file = File.join(Haml::Util.rails_root, 'vendor', 'plugins', 'haml', 'init.rb')
- haml_init_file = Haml::Util.scope('init.rb')
- begin
- if File.exists?(rails_init_file)
- require 'fileutils'
- FileUtils.cp(haml_init_file, rails_init_file) unless FileUtils.cmp(rails_init_file, haml_init_file)
- end
- rescue SystemCallError
- warn < e
- if logger
- logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
- logger.debug "Backtrace: #{e.backtrace.join("\n")}"
- end
-
- base_path = if defined?(extract_base_path_from)
- # Rails 2.0.x
- extract_base_path_from(file_name) || view_paths.first
- else
- # Rails <=1.2.6
- @base_path
- end
- raise ActionView::TemplateError.new(base_path, file_name || template, @assigns, template, e)
- end
-
- @@compile_time[render_symbol] = Time.now
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/template/plugin.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/template/plugin.rb
deleted file mode 100644
index a270a38c..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/template/plugin.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# This file makes Haml work with Rails
-# using the > 2.0.1 template handler API.
-
-module Haml
- class Plugin < Haml::Util.av_template_class(:Handler)
- if defined?(ActionView::TemplateHandlers::Compilable) ||
- defined?(ActionView::Template::Handlers::Compilable)
- include Haml::Util.av_template_class(:Handlers)::Compilable
- end
-
- def compile(template)
- options = Haml::Template.options.dup
-
- # template is a template object in Rails >=2.1.0,
- # a source string previously
- if template.respond_to? :source
- # Template has a generic identifier in Rails >=3.0.0
- options[:filename] = template.respond_to?(:identifier) ? template.identifier : template.filename
- source = template.source
- else
- source = template
- end
-
- Haml::Engine.new(source, options).send(:precompiled_with_ambles, [])
- end
-
- def cache_fragment(block, name = {}, options = nil)
- @view.fragment_for(block, name, options) do
- eval("_hamlout.buffer", block.binding)
- end
- end
- end
-end
-
-if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
- ActionView::Template
-else
- ActionView::Base
-end.register_template_handler(:haml, Haml::Plugin)
-
-# In Rails 2.0.2, ActionView::TemplateError took arguments
-# that we can't fill in from the Haml::Plugin context.
-# Thus, we've got to monkeypatch ActionView::Base to catch the error.
-if defined?(ActionView::TemplateError) &&
- ActionView::TemplateError.instance_method(:initialize).arity == 5
- class ActionView::Base
- def compile_template(handler, template, file_name, local_assigns)
- render_symbol = assign_method_name(handler, template, file_name)
-
- # Move begin up two lines so it captures compilation exceptions.
- begin
- render_source = create_template_source(handler, template, render_symbol, local_assigns.keys)
- line_offset = @@template_args[render_symbol].size + handler.line_offset
-
- file_name = 'compiled-template' if file_name.blank?
- CompiledTemplates.module_eval(render_source, file_name, -line_offset)
- rescue Exception => e # errors from template code
- if logger
- logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
- logger.debug "Function body: #{render_source}"
- logger.debug "Backtrace: #{e.backtrace.join("\n")}"
- end
-
- # There's no way to tell Haml about the filename,
- # so we've got to insert it ourselves.
- e.backtrace[0].gsub!('(haml)', file_name) if e.is_a?(Haml::Error)
-
- raise ActionView::TemplateError.new(extract_base_path_from(file_name) || view_paths.first, file_name || template, @assigns, template, e)
- end
-
- @@compile_time[render_symbol] = Time.now
- # logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/util.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/util.rb
deleted file mode 100644
index 4cf37213..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/util.rb
+++ /dev/null
@@ -1,289 +0,0 @@
-require 'erb'
-require 'set'
-require 'enumerator'
-require 'stringio'
-
-module Haml
- # A module containing various useful functions.
- module Util
- extend self
-
- # An array of ints representing the Ruby version number.
- RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
-
- # Returns the path of a file relative to the Haml root directory.
- #
- # @param file [String] The filename relative to the Haml root
- # @return [String] The filename relative to the the working directory
- def scope(file)
- File.join(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))), file)
- end
-
- # Converts an array of `[key, value]` pairs to a hash.
- # For example:
- #
- # to_hash([[:foo, "bar"], [:baz, "bang"]])
- # #=> {:foo => "bar", :baz => "bang"}
- #
- # @param arr [Array<(Object, Object)>] An array of pairs
- # @return [Hash] A hash
- def to_hash(arr)
- arr.compact.inject({}) {|h, (k, v)| h[k] = v; h}
- end
-
- # Maps the keys in a hash according to a block.
- # For example:
- #
- # map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
- # #=> {"foo" => "bar", "baz" => "bang"}
- #
- # @param hash [Hash] The hash to map
- # @yield [key] A block in which the keys are transformed
- # @yieldparam key [Object] The key that should be mapped
- # @yieldreturn [Object] The new value for the key
- # @return [Hash] The mapped hash
- # @see #map_vals
- # @see #map_hash
- def map_keys(hash)
- to_hash(hash.map {|k, v| [yield(k), v]})
- end
-
- # Maps the values in a hash according to a block.
- # For example:
- #
- # map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym}
- # #=> {:foo => :bar, :baz => :bang}
- #
- # @param hash [Hash] The hash to map
- # @yield [value] A block in which the values are transformed
- # @yieldparam value [Object] The value that should be mapped
- # @yieldreturn [Object] The new value for the value
- # @return [Hash] The mapped hash
- # @see #map_keys
- # @see #map_hash
- def map_vals(hash)
- to_hash(hash.map {|k, v| [k, yield(v)]})
- end
-
- # Maps the key-value pairs of a hash according to a block.
- # For example:
- #
- # map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
- # #=> {"foo" => :bar, "baz" => :bang}
- #
- # @param hash [Hash] The hash to map
- # @yield [key, value] A block in which the key-value pairs are transformed
- # @yieldparam [key] The hash key
- # @yieldparam [value] The hash value
- # @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair
- # @return [Hash] The mapped hash
- # @see #map_keys
- # @see #map_vals
- def map_hash(hash, &block)
- to_hash(hash.map(&block))
- end
-
- # Computes the powerset of the given array.
- # This is the set of all subsets of the array.
- # For example:
- #
- # powerset([1, 2, 3]) #=>
- # Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]]
- #
- # @param arr [Enumerable]
- # @return [Set] The subsets of `arr`
- def powerset(arr)
- arr.inject([Set.new].to_set) do |powerset, el|
- new_powerset = Set.new
- powerset.each do |subset|
- new_powerset << subset
- new_powerset << subset + [el]
- end
- new_powerset
- end
- end
-
- # Concatenates all strings that are adjacent in an array,
- # while leaving other elements as they are.
- # For example:
- #
- # merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
- # #=> [1, "foobar", 2, "baz"]
- #
- # @param enum [Enumerable]
- # @return [Array] The enumerable with strings merged
- def merge_adjacent_strings(enum)
- e = enum.inject([]) do |a, e|
- if e.is_a?(String) && a.last.is_a?(String)
- a.last << e
- else
- a << e
- end
- a
- end
- end
-
- # Silence all output to STDERR within a block.
- #
- # @yield A block in which no output will be printed to STDERR
- def silence_warnings
- the_real_stderr, $stderr = $stderr, StringIO.new
- yield
- ensure
- $stderr = the_real_stderr
- end
-
- ## Cross Rails Version Compatibility
-
- # Returns the root of the Rails application,
- # if this is running in a Rails context.
- # Returns `nil` if no such root is defined.
- #
- # @return [String, nil]
- def rails_root
- return Rails.root.to_s if defined?(Rails.root)
- return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
- return nil
- end
-
- # Returns an ActionView::Template* class.
- # In pre-3.0 versions of Rails, most of these classes
- # were of the form `ActionView::TemplateFoo`,
- # while afterwards they were of the form `ActionView;:Template::Foo`.
- #
- # @param name [#to_s] The name of the class to get.
- # For example, `:Error` will return `ActionView::TemplateError`
- # or `ActionView::Template::Error`.
- def av_template_class(name)
- return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}")
- return ActionView::Template.const_get(name.to_s)
- end
-
- ## Rails XSS Safety
-
- # Whether or not ActionView's XSS protection is available and enabled,
- # as is the default for Rails 3.0+, and optional for version 2.3.5+.
- # Overridden in haml/template.rb if this is the case.
- #
- # @return [Boolean]
- def rails_xss_safe?
- false
- end
-
- # Assert that a given object (usually a String) is HTML safe
- # according to Rails' XSS handling, if it's loaded.
- #
- # @param text [Object]
- def assert_html_safe!(text)
- return unless rails_xss_safe? && text && !text.to_s.html_safe?
- raise Haml::Error.new("Expected #{text.inspect} to be HTML-safe.")
- end
-
- ## Cross-Ruby-Version Compatibility
-
- # Whether or not this is running under Ruby 1.8 or lower.
- #
- # @return [Boolean]
- def ruby1_8?
- Haml::Util::RUBY_VERSION[0] == 1 && Haml::Util::RUBY_VERSION[1] < 9
- end
-
- # Checks to see if a class has a given method.
- # For example:
- #
- # Haml::Util.has?(:public_instance_method, String, :gsub) #=> true
- #
- # Method collections like `Class#instance_methods`
- # return strings in Ruby 1.8 and symbols in Ruby 1.9 and on,
- # so this handles checking for them in a compatible way.
- #
- # @param attr [#to_s] The (singular) name of the method-collection method
- # (e.g. `:instance_methods`, `:private_methods`)
- # @param klass [Module] The class to check the methods of which to check
- # @param method [String, Symbol] The name of the method do check for
- # @return [Boolean] Whether or not the given collection has the given method
- def has?(attr, klass, method)
- klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
- end
-
- # A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
- #
- # @param enum [Enumerable] The enumerable to get the enumerator for
- # @return [Enumerator] The with-index enumerator
- def enum_with_index(enum)
- ruby1_8? ? enum.enum_with_index : enum.each_with_index
- end
-
- ## Static Method Stuff
-
- # The context in which the ERB for \{#def\_static\_method} will be run.
- class StaticConditionalContext
- # @param set [#include?] The set of variables that are defined for this context.
- def initialize(set)
- @set = set
- end
-
- # Checks whether or not a variable is defined for this context.
- #
- # @param name [Symbol] The name of the variable
- # @return [Boolean]
- def method_missing(name, *args, &block)
- super unless args.empty? && block.nil?
- @set.include?(name)
- end
- end
-
- # This is used for methods in {Haml::Buffer} that need to be very fast,
- # and take a lot of boolean parameters
- # that are known at compile-time.
- # Instead of passing the parameters in normally,
- # a separate method is defined for every possible combination of those parameters;
- # these are then called using \{#static\_method\_name}.
- #
- # To define a static method, an ERB template for the method is provided.
- # All conditionals based on the static parameters
- # are done as embedded Ruby within this template.
- # For example:
- #
- # def_static_method(Foo, :my_static_method, [:foo, :bar], :baz, :bang, <
- # return foo + bar
- # <% elsif baz || bang %>
- # return foo - bar
- # <% else %>
- # return 17
- # <% end %>
- # RUBY
- #
- # \{#static\_method\_name} can be used to call static methods.
- #
- # @overload def_static_method(klass, name, args, *vars, erb)
- # @param klass [Module] The class on which to define the static method
- # @param name [#to_s] The (base) name of the static method
- # @param args [Array] The names of the arguments to the defined methods
- # (**not** to the ERB template)
- # @param vars [Array] The names of the static boolean variables
- # to be made available to the ERB template
- # @param erb [String] The template for the method code
- def def_static_method(klass, name, args, *vars)
- erb = vars.pop
- powerset(vars).each do |set|
- context = StaticConditionalContext.new(set).instance_eval {binding}
- klass.class_eval(<] The static variable assignment
- # @return [String] The real name of the static method
- def static_method_name(name, *vars)
- "#{name}_#{vars.map {|v| !!v}.join('_')}"
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/version.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/version.rb
deleted file mode 100644
index de0b0017..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/haml/version.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'haml/util'
-
-module Haml
- # Handles Haml version-reporting.
- # Haml not only reports the standard three version numbers,
- # but its Git revision hash as well,
- # if it was installed from Git.
- module Version
- include Haml::Util
-
- # Returns a hash representing the version of Haml.
- # The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums.
- # The `:name` key has the name of the version.
- # The `:string` key contains a human-readable string representation of the version.
- # The `:number` key is the major, minor, and teeny keys separated by periods.
- # If Haml is checked out from Git, the `:rev` key will have the revision hash.
- # For example:
- #
- # {
- # :string => "2.1.0.9616393",
- # :rev => "9616393b8924ef36639c7e82aa88a51a24d16949",
- # :number => "2.1.0",
- # :major => 2, :minor => 1, :teeny => 0
- # }
- #
- # @return [{Symbol => String/Fixnum}] The version hash
- def version
- return @@version if defined?(@@version)
-
- numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
- name = File.read(scope('VERSION_NAME')).strip
- @@version = {
- :major => numbers[0],
- :minor => numbers[1],
- :teeny => numbers[2],
- :name => name
- }
- @@version[:number] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
- @@version[:string] = @@version[:number].dup
-
- if File.exists?(scope('REVISION'))
- rev = File.read(scope('REVISION')).strip
- rev = nil if rev !~ /^([a-f0-9]+|\(.*\))$/
- end
-
- if (rev.nil? || rev == '(unknown)') && File.exists?(scope('.git/HEAD'))
- rev = File.read(scope('.git/HEAD')).strip
- if rev =~ /^ref: (.*)$/
- rev = File.read(scope(".git/#{$1}")).strip
- end
- end
-
- if rev
- @@version[:rev] = rev
- unless rev[0] == ?(
- @@version[:string] << "." << rev[0...7]
- end
- @@version[:string] << " (#{name})"
- end
-
- @@version
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass.rb
deleted file mode 100644
index c8243796..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-dir = File.dirname(__FILE__)
-$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
-
-require 'haml/version'
-
-# The module that contains everything Sass-related:
-#
-# * {Sass::Engine} is the class used to render Sass within Ruby code.
-# * {Sass::Plugin} is interfaces with web frameworks (Rails and Merb in particular).
-# * {Sass::SyntaxError} is raised when Sass encounters an error.
-# * {Sass::CSS} handles conversion of CSS to Sass.
-#
-# Also see the {file:SASS_REFERENCE.md full Sass reference}.
-module Sass
- extend Haml::Version
-
- # A string representing the version of Sass.
- # A more fine-grained representation is available from {Sass.version}.
- VERSION = version[:string] unless defined?(Sass::VERSION)
-end
-
-require 'haml/util'
-require 'sass/engine'
-require 'sass/plugin' if defined?(Merb::Plugins)
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/css.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/css.rb
deleted file mode 100644
index 43929848..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/css.rb
+++ /dev/null
@@ -1,404 +0,0 @@
-require File.dirname(__FILE__) + '/../sass'
-require 'sass/tree/node'
-require 'strscan'
-
-module Sass
- module Tree
- class Node
- # Converts a node to Sass code that will generate it.
- #
- # @param tabs [Fixnum] The amount of tabulation to use for the Sass code
- # @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
- # @return [String] The Sass code corresponding to the node
- def to_sass(tabs = 0, opts = {})
- result = ''
-
- children.each do |child|
- result << "#{' ' * tabs}#{child.to_sass(0, opts)}\n"
- end
-
- result
- end
- end
-
- class RuleNode
- # @see Node#to_sass
- def to_sass(tabs, opts = {})
- name = rules.first
- name = "\\" + name if name[0] == ?:
- str = "\n#{' ' * tabs}#{name}#{children.any? { |c| c.is_a? PropNode } ? "\n" : ''}"
-
- children.each do |child|
- str << "#{child.to_sass(tabs + 1, opts)}"
- end
-
- str
- end
- end
-
- class PropNode
- # @see Node#to_sass
- def to_sass(tabs, opts = {})
- "#{' ' * tabs}#{opts[:old] ? ':' : ''}#{name}#{opts[:old] ? '' : ':'} #{value}\n"
- end
- end
-
- class DirectiveNode
- # @see Node#to_sass
- def to_sass(tabs, opts = {})
- "#{' ' * tabs}#{value}#{children.map {|c| c.to_sass(tabs + 1, opts)}}\n"
- end
- end
- end
-
- # This class converts CSS documents into Sass templates.
- # It works by parsing the CSS document into a {Sass::Tree} structure,
- # and then applying various transformations to the structure
- # to produce more concise and idiomatic Sass.
- #
- # Example usage:
- #
- # Sass::CSS.new("p { color: blue }").render #=> "p\n color: blue"
- class CSS
- # @param template [String] The CSS code
- # @option options :old [Boolean] (false)
- # Whether or not to output old property syntax
- # (`:color blue` as opposed to `color: blue`).
- def initialize(template, options = {})
- if template.is_a? IO
- template = template.read
- end
-
- @options = options.dup
- # Backwards compatibility
- @options[:old] = true if @options[:alternate] == false
- @template = StringScanner.new(template)
- end
-
- # Converts the CSS template into Sass code.
- #
- # @return [String] The resulting Sass code
- def render
- begin
- build_tree.to_sass(0, @options).strip + "\n"
- rescue Exception => err
- line = @template.string[0...@template.pos].split("\n").size
-
- err.backtrace.unshift "(css):#{line}"
- raise err
- end
- end
-
- private
-
- # Parses the CSS template and applies various transformations
- #
- # @return [Tree::Node] The root node of the parsed tree
- def build_tree
- root = Tree::Node.new
- whitespace
- rules root
- expand_commas root
- parent_ref_rules root
- remove_parent_refs root
- flatten_rules root
- fold_commas root
- root
- end
-
- # Parses a set of CSS rules.
- #
- # @param root [Tree::Node] The parent node of the rules
- def rules(root)
- while r = rule
- root << r
- whitespace
- end
- end
-
- # Parses a single CSS rule.
- #
- # @return [Tree::Node] The parsed rule
- def rule
- rule = ""
- loop do
- token = @template.scan(/(?:[^\{\};\/\s]|\/[^*])+/)
- if token.nil?
- return if rule.empty?
- break
- end
- rule << token
- break unless @template.match?(/\s|\/\*/)
- whitespace
- rule << " "
- end
-
- rule.strip!
- directive = rule[0] == ?@
-
- if directive
- node = Tree::DirectiveNode.new(rule)
- return node if @template.scan(/;/)
-
- assert_match /\{/
- whitespace
-
- rules(node)
- return node
- end
-
- assert_match /\{/
- node = Tree::RuleNode.new(rule)
- properties(node)
- return node
- end
-
- # Parses a set of CSS properties within a rule.
- #
- # @param rule [Tree::RuleNode] The parent node of the properties
- def properties(rule)
- while @template.scan(/[^:\}\s]+/)
- name = @template[0]
- whitespace
-
- assert_match /:/
-
- value = ''
- while @template.scan(/[^;\s\}]+/)
- value << @template[0] << whitespace
- end
-
- assert_match /(;|(?=\}))/
- rule << Tree::PropNode.new(name, value, nil)
- end
-
- assert_match /\}/
- end
-
- # Moves the scanner over a section of whitespace or comments.
- #
- # @return [String] The ignored whitespace
- def whitespace
- space = @template.scan(/\s*/) || ''
-
- # If we've hit a comment,
- # go past it and look for more whitespace
- if @template.scan(/\/\*/)
- @template.scan_until(/\*\//)
- return space + whitespace
- end
- return space
- end
-
- # Moves the scanner over a regular expression,
- # raising an exception if it doesn't match.
- #
- # @param re [Regexp] The regular expression to assert
- def assert_match(re)
- if @template.scan(re)
- whitespace
- return
- end
-
- line = @template.string[0..@template.pos].count "\n"
- pos = @template.pos
-
- after = @template.string[pos - 15...pos]
- after = "..." + after if pos >= 15
-
- # Display basic regexps as plain old strings
- expected = re.source == Regexp.escape(re.source) ? "\"#{re.source}\"" : re.inspect
-
- was = @template.rest[0...15]
- was += "..." if @template.rest.size >= 15
- raise Exception.new(<`
- # : The arguments for the mixin.
- # Each element is a tuple containing the name of the argument
- # and the parse tree for the default value of the argument.
- #
- # `environment`: {Sass::Environment}
- # : The environment in which the mixin was defined.
- # This is captured so that the mixin can have access
- # to local variables defined in its scope.
- #
- # `tree`: {Sass::Tree::Node}
- # : The parse tree for the mixin.
- Mixin = Struct.new(:name, :args, :environment, :tree)
-
- # This class handles the parsing and compilation of the Sass template.
- # Example usage:
- #
- # template = File.load('stylesheets/sassy.sass')
- # sass_engine = Sass::Engine.new(template)
- # output = sass_engine.render
- # puts output
- class Engine
- include Haml::Util
-
- # A line of Sass code.
- #
- # `text`: `String`
- # : The text in the line, without any whitespace at the beginning or end.
- #
- # `tabs`: `Fixnum`
- # : The level of indentation of the line.
- #
- # `index`: `Fixnum`
- # : The line number in the original document.
- #
- # `offset`: `Fixnum`
- # : The number of bytes in on the line that the text begins.
- # This ends up being the number of bytes of leading whitespace.
- #
- # `filename`: `String`
- # : The name of the file in which this line appeared.
- #
- # `children`: `Array`
- # : The lines nested below this one.
- class Line < Struct.new(:text, :tabs, :index, :offset, :filename, :children)
- def comment?
- text[0] == COMMENT_CHAR && (text[1] == SASS_COMMENT_CHAR || text[1] == CSS_COMMENT_CHAR)
- end
- end
-
- # The character that begins a CSS property.
- PROPERTY_CHAR = ?:
-
- # The character that designates that
- # a property should be assigned to a SassScript expression.
- SCRIPT_CHAR = ?=
-
- # The character that designates the beginning of a comment,
- # either Sass or CSS.
- COMMENT_CHAR = ?/
-
- # The character that follows the general COMMENT_CHAR and designates a Sass comment,
- # which is not output as a CSS comment.
- SASS_COMMENT_CHAR = ?/
-
- # The character that follows the general COMMENT_CHAR and designates a CSS comment,
- # which is embedded in the CSS document.
- CSS_COMMENT_CHAR = ?*
-
- # The character used to denote a compiler directive.
- DIRECTIVE_CHAR = ?@
-
- # Designates a non-parsed rule.
- ESCAPE_CHAR = ?\\
-
- # Designates block as mixin definition rather than CSS rules to output
- MIXIN_DEFINITION_CHAR = ?=
-
- # Includes named mixin declared using MIXIN_DEFINITION_CHAR
- MIXIN_INCLUDE_CHAR = ?+
-
- # The regex that matches properties of the form `name: prop`.
- PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
-
- # The regex that matches and extracts data from
- # properties of the form `name: prop`.
- PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
-
- # The regex that matches and extracts data from
- # properties of the form `:name prop`.
- PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
-
- # The default options for Sass::Engine.
- DEFAULT_OPTIONS = {
- :style => :nested,
- :load_paths => ['.'],
- :cache => true,
- :cache_location => './.sass-cache',
- }.freeze
-
- # @param template [String] The Sass template.
- # @param options [{Symbol => Object}] An options hash;
- # see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}
- def initialize(template, options={})
- @options = DEFAULT_OPTIONS.merge(options.reject {|k, v| v.nil?})
- @template = template
-
- # Backwards compatibility
- @options[:property_syntax] ||= @options[:attribute_syntax]
- case @options[:property_syntax]
- when :alternate; @options[:property_syntax] = :new
- when :normal; @options[:property_syntax] = :old
- end
- end
-
- # Render the template to CSS.
- #
- # @return [String] The CSS
- # @raise [Sass::SyntaxError] if there's an error in the document
- def render
- to_tree.render
- end
-
- alias_method :to_css, :render
-
- # Parses the document into its parse tree.
- #
- # @return [Sass::Tree::Node] The root of the parse tree.
- # @raise [Sass::SyntaxError] if there's an error in the document
- def to_tree
- root = Tree::Node.new
- append_children(root, tree(tabulate(@template)).first, true)
- root.options = @options
- root
- rescue SyntaxError => e; e.add_metadata(@options[:filename], @line)
- end
-
- private
-
- def tabulate(string)
- tab_str = nil
- first = true
- lines = []
- string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^.*?$/).each_with_index do |line, index|
- index += (@options[:line] || 1)
- if line.strip.empty?
- lines.last.text << "\n" if lines.last && lines.last.comment?
- next
- end
-
- line_tab_str = line[/^\s*/]
- unless line_tab_str.empty?
- tab_str ||= line_tab_str
-
- raise SyntaxError.new("Indenting at the beginning of the document is illegal.", index) if first
- if tab_str.include?(?\s) && tab_str.include?(?\t)
- raise SyntaxError.new("Indentation can't use both tabs and spaces.", index)
- end
- end
- first &&= !tab_str.nil?
- if tab_str.nil?
- lines << Line.new(line.strip, 0, index, 0, @options[:filename], [])
- next
- end
-
- if lines.last && lines.last.comment? && line =~ /^(?:#{tab_str}){#{lines.last.tabs + 1}}(.*)$/
- lines.last.text << "\n" << $1
- next
- end
-
- line_tabs = line_tab_str.scan(tab_str).size
- raise SyntaxError.new(<= base
- if line.tabs > base
- if line.tabs > base + 1
- raise SyntaxError.new("The line was indented #{line.tabs - base} levels deeper than the previous line.", line.index)
- end
-
- nodes.last.children, i = tree(arr, i)
- else
- nodes << line
- i += 1
- end
- end
- return nodes, i
- end
-
- def build_tree(parent, line, root = false)
- @line = line.index
- node_or_nodes = parse_line(parent, line, root)
-
- Array(node_or_nodes).each do |node|
- # Node is a symbol if it's non-outputting, like a variable assignment
- next unless node.is_a? Tree::Node
-
- node.line = line.index
- node.filename = line.filename
-
- if node.is_a?(Tree::CommentNode)
- node.lines = line.children
- else
- append_children(node, line.children, false)
- end
- end
-
- node_or_nodes
- end
-
- def append_children(parent, children, root)
- continued_rule = nil
- children.each do |line|
- child = build_tree(parent, line, root)
-
- if child.is_a?(Tree::RuleNode) && child.continued?
- raise SyntaxError.new("Rules can't end in commas.", child.line) unless child.children.empty?
- if continued_rule
- continued_rule.add_rules child
- else
- continued_rule = child
- end
- next
- end
-
- if continued_rule
- raise SyntaxError.new("Rules can't end in commas.", continued_rule.line) unless child.is_a?(Tree::RuleNode)
- continued_rule.add_rules child
- continued_rule.children = child.children
- continued_rule, child = nil, continued_rule
- end
-
- check_for_no_children(child)
- validate_and_append_child(parent, child, line, root)
- end
-
- raise SyntaxError.new("Rules can't end in commas.", continued_rule.line) if continued_rule
-
- parent
- end
-
- def validate_and_append_child(parent, child, line, root)
- unless root
- case child
- when Tree::MixinDefNode
- raise SyntaxError.new("Mixins may only be defined at the root of a document.", line.index)
- when Tree::ImportNode
- raise SyntaxError.new("Import directives may only be used at the root of a document.", line.index)
- end
- end
-
- case child
- when Array
- child.each {|c| validate_and_append_child(parent, c, line, root)}
- when Tree::Node
- parent << child
- end
- end
-
- def check_for_no_children(node)
- return unless node.is_a?(Tree::RuleNode) && node.children.empty?
- warning = (node.rules.size == 1) ? < line.offset + line.text.index(value))
- else
- value
- end
- Tree::PropNode.new(name, expr, property_regx == PROPERTY_OLD ? :old : :new)
- end
-
- def parse_variable(line)
- name, op, value = line.text.scan(Script::MATCH)[0]
- raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath variable declarations.", @line + 1) unless line.children.empty?
- raise SyntaxError.new("Invalid variable: \"#{line.text}\".", @line) unless name && value
-
- Tree::VariableNode.new(name, parse_script(value, :offset => line.offset + line.text.index(value)), op == '||=')
- end
-
- def parse_comment(line)
- if line[1] == CSS_COMMENT_CHAR || line[1] == SASS_COMMENT_CHAR
- Tree::CommentNode.new(line, line[1] == SASS_COMMENT_CHAR)
- else
- Tree::RuleNode.new(line)
- end
- end
-
- def parse_directive(parent, line, root)
- directive, whitespace, value = line.text[1..-1].split(/(\s+)/, 2)
- offset = directive.size + whitespace.size + 1 if whitespace
-
- # If value begins with url( or ",
- # it's a CSS @import rule and we don't want to touch it.
- if directive == "import" && value !~ /^(url\(|")/
- raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.", @line + 1) unless line.children.empty?
- value.split(/,\s*/).map {|f| Tree::ImportNode.new(f)}
- elsif directive == "for"
- parse_for(line, root, value)
- elsif directive == "else"
- parse_else(parent, line, value)
- elsif directive == "while"
- raise SyntaxError.new("Invalid while directive '@while': expected expression.") unless value
- Tree::WhileNode.new(parse_script(value, :offset => offset))
- elsif directive == "if"
- raise SyntaxError.new("Invalid if directive '@if': expected expression.") unless value
- Tree::IfNode.new(parse_script(value, :offset => offset))
- elsif directive == "debug"
- raise SyntaxError.new("Invalid debug directive '@debug': expected expression.") unless value
- raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath debug directives.", @line + 1) unless line.children.empty?
- offset = line.offset + line.text.index(value).to_i
- Tree::DebugNode.new(parse_script(value, :offset => offset))
- else
- Tree::DirectiveNode.new(line.text)
- end
- end
-
- def parse_for(line, root, text)
- var, from_expr, to_name, to_expr = text.scan(/^([^\s]+)\s+from\s+(.+)\s+(to|through)\s+(.+)$/).first
-
- if var.nil? # scan failed, try to figure out why for error message
- if text !~ /^[^\s]+/
- expected = "variable name"
- elsif text !~ /^[^\s]+\s+from\s+.+/
- expected = "'from '"
- else
- expected = "'to ' or 'through '"
- end
- raise SyntaxError.new("Invalid for directive '@for #{text}': expected #{expected}.", @line)
- end
- raise SyntaxError.new("Invalid variable \"#{var}\".", @line) unless var =~ Script::VALIDATE
-
- parsed_from = parse_script(from_expr, :offset => line.offset + line.text.index(from_expr))
- parsed_to = parse_script(to_expr, :offset => line.offset + line.text.index(to_expr))
- Tree::ForNode.new(var[1..-1], parsed_from, parsed_to, to_name == 'to')
- end
-
- def parse_else(parent, line, text)
- previous = parent.last
- raise SyntaxError.new("@else must come after @if.") unless previous.is_a?(Tree::IfNode)
-
- if text
- if text !~ /^if\s+(.+)/
- raise SyntaxError.new("Invalid else directive '@else #{text}': expected 'if '.", @line)
- end
- expr = parse_script($1, :offset => line.offset + line.text.index($1))
- end
-
- node = Tree::IfNode.new(expr)
- append_children(node, line.children, false)
- previous.add_else node
- nil
- end
-
- def parse_mixin_definition(line)
- name, arg_string = line.text.scan(/^=\s*([^(]+)(.*)$/).first
- raise SyntaxError.new("Invalid mixin \"#{line.text[1..-1]}\".", @line) if name.nil?
-
- offset = line.offset + line.text.size - arg_string.size
- args = Script::Parser.new(arg_string.strip, @line, offset).parse_mixin_definition_arglist
- default_arg_found = false
- Tree::MixinDefNode.new(name, args)
- end
-
- def parse_mixin_include(line, root)
- name, arg_string = line.text.scan(/^\+\s*([^(]+)(.*)$/).first
- raise SyntaxError.new("Invalid mixin include \"#{line.text}\".", @line) if name.nil?
-
- offset = line.offset + line.text.size - arg_string.size
- args = Script::Parser.new(arg_string.strip, @line, offset).parse_mixin_include_arglist
- raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath mixin directives.", @line + 1) unless line.children.empty?
- Tree::MixinNode.new(name, args)
- end
-
- def parse_script(script, options = {})
- line = options[:line] || @line
- offset = options[:offset] || 0
- Script.parse(script, line, offset, @options[:filename])
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/environment.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/environment.rb
deleted file mode 100644
index 5440c213..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/environment.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-module Sass
- # The lexical environment for SassScript.
- # This keeps track of variable and mixin definitions.
- #
- # A new environment is created for each level of Sass nesting.
- # This allows variables to be lexically scoped.
- # The new environment refers to the environment in the upper scope,
- # so it has access to variables defined in enclosing scopes,
- # but new variables are defined locally.
- #
- # Environment also keeps track of the {Engine} options
- # so that they can be made available to {Sass::Script::Functions}.
- class Environment
- # The enclosing environment,
- # or nil if this is the global environment.
- #
- # @return [Environment]
- attr_reader :parent
- attr_writer :options
-
- # @param parent [Environment] See \{#parent}
- def initialize(parent = nil)
- @vars = {}
- @mixins = {}
- @parent = parent
-
- set_var("important", Script::String.new("!important")) unless @parent
- end
-
- # The options hash.
- # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
- #
- # @return [{Symbol => Object}]
- def options
- @options || (parent && parent.options) || {}
- end
-
- class << self
- private
-
- # Note: when updating this,
- # update haml/yard/inherited_hash.rb as well.
- def inherited_hash(name)
- class_eval < Object}] The options hash.
- # Only the {file:SASS_REFERENCE.md#cache-option `:cache_location`} option is used
- # @raise [Sass::SyntaxError] if there's an error in the document
- def tree_for(filename, options)
- options = Sass::Engine::DEFAULT_OPTIONS.merge(options)
- text = File.read(filename)
-
- if options[:cache]
- compiled_filename = sassc_filename(filename, options)
- sha = Digest::SHA1.hexdigest(text)
-
- if root = try_to_read_sassc(filename, compiled_filename, sha)
- root.options = options.merge(:filename => filename)
- return root
- end
- end
-
- engine = Sass::Engine.new(text, options.merge(:filename => filename))
-
- begin
- root = engine.to_tree
- rescue Sass::SyntaxError => err
- err.add_backtrace_entry(filename)
- raise err
- end
-
- try_to_write_sassc(root, compiled_filename, sha, options) if options[:cache]
-
- root
- end
-
- # Find the full filename of a Sass or CSS file to import.
- # This follows Sass's import rules:
- # if the filename given ends in `".sass"` or `".css"`,
- # it will try to find that type of file;
- # otherwise, it will try to find the corresponding Sass file
- # and fall back on CSS if it's not available.
- #
- # Any Sass filename returned will correspond to
- # an actual Sass file on the filesystem.
- # CSS filenames, however, may not;
- # they're expected to be put through directly to the stylesheet
- # as CSS `@import` statements.
- #
- # @param filename [String] The filename to search for
- # @param load_paths [Array] The set of filesystem paths
- # to search for Sass files.
- # @return [String] The filename of the imported file.
- # This is an absolute path if the file is a `".sass"` file.
- # @raise [Sass::SyntaxError] if `filename` ends in ``".sass"``
- # and no corresponding Sass file could be found.
- def find_file_to_import(filename, load_paths)
- was_sass = false
- original_filename = filename
-
- if filename[-5..-1] == ".sass"
- filename = filename[0...-5]
- was_sass = true
- elsif filename[-4..-1] == ".css"
- return filename
- end
-
- new_filename = find_full_path("#{filename}.sass", load_paths)
-
- return new_filename if new_filename
- unless was_sass
- warn < e
- warn "Warning. Error encountered while reading cache #{compiled_filename}: #{e}"
- end
-
- def try_to_write_sassc(root, compiled_filename, sha, options)
- return unless File.writable?(File.dirname(options[:cache_location]))
- return if File.exists?(options[:cache_location]) && !File.writable?(options[:cache_location])
- return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
- return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
- FileUtils.mkdir_p(File.dirname(compiled_filename))
- File.open(compiled_filename, "wb") do |f|
- f.write(Sass::VERSION)
- f.write("\n")
- f.write(sha)
- f.write("\n")
- f.write(Marshal.dump(root))
- end
- end
-
- def find_full_path(filename, load_paths)
- partial_name = File.join(File.dirname(filename), "_#{File.basename(filename)}")
-
- if Pathname.new(filename).absolute?
- [partial_name, filename].each do |name|
- return name if File.readable?(name)
- end
- return nil
- end
-
- load_paths.each do |path|
- [partial_name, filename].each do |name|
- full_path = File.join(path, name)
- if File.readable?(full_path)
- return full_path
- end
- end
- end
- nil
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin.rb
deleted file mode 100644
index 5339e7f9..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin.rb
+++ /dev/null
@@ -1,222 +0,0 @@
-require 'sass'
-
-module Sass
- # This module handles the compilation of Sass files.
- # It provides global options and checks whether CSS files
- # need to be updated.
- #
- # This module is used as the primary interface with Sass
- # when it's used as a plugin for various frameworks.
- # All Rack-enabled frameworks are supported out of the box.
- # The plugin is {file:SASS_REFERENCE.md#rails_merb_plugin automatically activated for Rails and Merb}.
- # Other frameworks must enable it explicitly; see {Sass::Plugin::Rack}.
- module Plugin
- extend self
-
- @options = {
- :css_location => './public/stylesheets',
- :always_update => false,
- :always_check => true,
- :full_exception => true
- }
- @checked_for_updates = false
-
- # Whether or not Sass has **ever** checked if the stylesheets need to be updated
- # (in this Ruby instance).
- #
- # @return [Boolean]
- attr_reader :checked_for_updates
-
- # An options hash.
- # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
- #
- # @return [{Symbol => Object}]
- attr_reader :options
-
- # Sets the options hash.
- # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
- #
- # @param value [{Symbol => Object}] The options hash
- def options=(value)
- @options.merge!(value)
- end
-
- # Non-destructively modifies \{#options} so that default values are properly set.
- #
- # @param additional_options [{Symbol => Object}] An options hash with which to merge \{#options}
- # @return [{Symbol => Object}] The modified options hash
- def engine_options(additional_options = {})
- opts = options.dup.merge(additional_options)
- opts[:load_paths] = load_paths(opts)
- opts
- end
-
- # Same as \{#update\_stylesheets}, but respects \{#checked\_for\_updates}
- # and the {file:SASS_REFERENCE.md#always_update-option `:always_update`}
- # and {file:SASS_REFERENCE.md#always_check-option `:always_check`} options.
- #
- # @see #update_stylesheets
- def check_for_updates
- return unless !Sass::Plugin.checked_for_updates ||
- Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
- update_stylesheets
- end
-
- # Updates out-of-date stylesheets.
- #
- # Checks each Sass file in {file:SASS_REFERENCE.md#template_location-option `:template_location`}
- # to see if it's been modified more recently than the corresponding CSS file
- # in {file:SASS_REFERENCE.md#css_location-option} `:css_location`}.
- # If it has, it updates the CSS file.
- def update_stylesheets
- return if options[:never_update]
-
- @checked_for_updates = true
- template_locations.zip(css_locations).each do |template_location, css_location|
-
- Dir.glob(File.join(template_location, "**", "*.sass")).each do |file|
- # Get the relative path to the file with no extension
- name = file.sub(template_location.sub(/\/*$/, '/'), "")[0...-5]
-
- if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name, template_location, css_location))
- update_stylesheet(name, template_location, css_location)
- end
- end
- end
- end
-
- private
-
- def update_stylesheet(name, template_location, css_location)
- css = css_filename(name, css_location)
- File.delete(css) if File.exists?(css)
-
- filename = template_filename(name, template_location)
- result = begin
- Sass::Files.tree_for(filename, engine_options(:css_filename => css, :filename => filename)).render
- rescue Exception => e
- raise e unless options[:full_exception]
- exception_string(e)
- end
-
- # Create any directories that might be necessary
- mkpath(css_location, name)
-
- # Finally, write the file
- File.open(css, 'w') do |file|
- file.print(result)
- end
- end
-
- # Create any successive directories required to be able to write a file to: File.join(base,name)
- def mkpath(base, name)
- dirs = [base]
- name.split(File::SEPARATOR)[0...-1].each { |dir| dirs << File.join(dirs[-1],dir) }
- dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
- end
-
- def load_paths(opts = options)
- (opts[:load_paths] || []) + template_locations
- end
-
- def template_locations
- location = (options[:template_location] || File.join(options[:css_location],'sass'))
- if location.is_a?(String)
- [location]
- else
- location.to_a.map { |l| l.first }
- end
- end
-
- def css_locations
- if options[:template_location] && !options[:template_location].is_a?(String)
- options[:template_location].to_a.map { |l| l.last }
- else
- [options[:css_location]]
- end
- end
-
- def exception_string(e)
- e_string = "#{e.class}: #{e.message}"
-
- if e.is_a? Sass::SyntaxError
- e_string << "\non line #{e.sass_line}"
-
- if e.sass_filename
- e_string << " of #{e.sass_filename}"
-
- if File.exists?(e.sass_filename)
- e_string << "\n\n"
-
- min = [e.sass_line - 5, 0].max
- begin
- File.read(e.sass_filename).rstrip.split("\n")[
- min .. e.sass_line + 5
- ].each_with_index do |line, i|
- e_string << "#{min + i + 1}: #{line}\n"
- end
- rescue
- e_string << "Couldn't read sass file: #{e.sass_filename}"
- end
- end
- end
- end
- < css_mtime ||
- dependencies(template_file).any?(&dependency_updated?(css_mtime))
- end
-
- def dependency_updated?(css_mtime)
- lambda do |dep|
- File.mtime(dep) > css_mtime ||
- dependencies(dep).any?(&dependency_updated?(css_mtime))
- end
- end
-
- def dependencies(filename)
- File.readlines(filename).grep(/^@import /).map do |line|
- line[8..-1].split(',').map do |inc|
- Sass::Files.find_file_to_import(inc.strip, [File.dirname(filename)] + load_paths)
- end
- end.flatten.grep(/\.sass$/)
- end
- end
-end
-
-require 'sass/plugin/rails' if defined?(ActionController)
-require 'sass/plugin/merb' if defined?(Merb::Plugins)
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/merb.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/merb.rb
deleted file mode 100644
index fb931f37..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/merb.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-unless defined?(Sass::MERB_LOADED)
- Sass::MERB_LOADED = true
-
- version = Merb::VERSION.split('.').map { |n| n.to_i }
- if version[0] <= 0 && version[1] < 5
- root = MERB_ROOT
- env = MERB_ENV
- else
- root = Merb.root.to_s
- env = Merb.environment
- end
-
- Sass::Plugin.options.merge!(:template_location => root + '/public/stylesheets/sass',
- :css_location => root + '/public/stylesheets',
- :cache_location => root + '/tmp/sass-cache',
- :always_check => env != "production",
- :full_exception => env != "production")
- config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
-
- if defined? config.symbolize_keys!
- config.symbolize_keys!
- end
-
- Sass::Plugin.options.merge!(config)
-
- if version[0] > 0 || version[1] >= 9
-
- class Merb::Rack::Application
- def call_with_sass(env)
- Sass::Plugin.check_for_updates
- call_without_sass(env)
- end
- alias_method :call_without_sass, :call
- alias_method :call, :call_with_sass
- end
-
- else
-
- class MerbHandler
- def process_with_sass(request, response)
- Sass::Plugin.check_for_updates
- process_without_sass(request, response)
- end
- alias_method :process_without_sass, :process
- alias_method :process, :process_with_sass
- end
-
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/rack.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/rack.rb
deleted file mode 100644
index 9275b4ba..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/rack.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require 'sass/plugin'
-
-module Sass
- module Plugin
- # Rack middleware for compiling Sass code.
- #
- # ## Activate
- #
- # require 'sass/plugin/rack'
- # use Sass::Plugin::Rack
- #
- # ## Customize
- #
- # Sass::Plugin.options.merge(
- # :cache_location => './tmp/sass-cache',
- # :never_update => environment != :production,
- # :full_exception => environment != :production)
- #
- # {file:SASS_REFERENCE.md#options See the Reference for more options}.
- #
- # ## Use
- #
- # Put your Sass files in `public/stylesheets/sass`.
- # Your CSS will be generated in `public/stylesheets`,
- # and regenerated every request if necessary.
- # The locations and frequency {file:SASS_REFERENCE.md#options can be customized}.
- # That's all there is to it!
- class Rack
- # Initialize the middleware.
- #
- # @param app [#call] The Rack application
- def initialize(app)
- @app = app
- self.class.disable_native_plugin!
- end
-
- # Process a request, checking the Sass stylesheets for changes
- # and updating them if necessary.
- #
- # @param env The Rack request environment
- # @return [(#to_i, {String => String}, Object)] The Rack response
- def call(env)
- Sass::Plugin.check_for_updates
- @app.call(env)
- end
-
- # Disable the native Rails or Merb plugins, if they're enabled.
- # This is automatically done once the Rack plugin is activated.
- # This is done so that the stylesheets aren't checked twice for each request.
- def self.disable_native_plugin!
- if defined?(Merb::Rack::Application) &&
- Haml::Util.has?(:instance_method, Merb::Rack::Application, :call_without_sass)
- Merb::Rack::Application.instance_eval {alias_method :call, :call_without_sass}
- end
-
- if defined?(ActionDispatch::Callbacks.to_prepare)
- ActionDispatch::Callbacks.skip_callback(:prepare, :__sass_process)
- elsif defined?(ActionController::Base) &&
- Haml::Util.has?(:instance_method, ActionController::Base, :sass_old_process)
- ActionController::Base.instance_eval {alias_method :process, :sass_old_process}
- end
- end
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/rails.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/rails.rb
deleted file mode 100644
index 8d4a5f40..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/plugin/rails.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-unless defined?(Sass::RAILS_LOADED)
- Sass::RAILS_LOADED = true
-
- Sass::Plugin.options.merge!(:template_location => Haml::Util.rails_root + '/public/stylesheets/sass',
- :css_location => Haml::Util.rails_root + '/public/stylesheets',
- :cache_location => Haml::Util.rails_root + '/tmp/sass-cache',
- :always_check => RAILS_ENV != "production",
- :full_exception => RAILS_ENV != "production")
-
- if defined?(ActionDispatch::Callbacks.to_prepare)
- # Rails >= 3.0.0
- ActionDispatch::Callbacks.to_prepare(:sass_process) {Sass::Plugin.check_for_updates}
- else
- module ActionController
- class Base
- alias_method :sass_old_process, :process
- def process(*args)
- Sass::Plugin.check_for_updates
- sass_old_process(*args)
- end
- end
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/repl.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/repl.rb
deleted file mode 100644
index ee955bf8..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/repl.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-require 'readline'
-
-module Sass
- # Runs a SassScript read-eval-print loop.
- # It presents a prompt on the terminal,
- # reads in SassScript expressions,
- # evaluates them,
- # and prints the result.
- class Repl
- # @param options [{Symbol => Object}] An options hash.
- def initialize(options = {})
- @options = options
- end
-
- # Starts the read-eval-print loop.
- def run
- environment = Environment.new
- environment.set_var('important', Script::String.new('!important'))
- @line = 0
- loop do
- @line += 1
- unless text = Readline.readline('>> ')
- puts
- return
- end
-
- Readline::HISTORY << text
- parse_input(environment, text)
- end
- end
-
- private
-
- def parse_input(environment, text)
- case text
- when Script::MATCH
- name = $1
- guarded = $2 == '||='
- val = Script::Parser.parse($3, @line, text.size - $3.size)
-
- unless guarded && environment.var(name)
- environment.set_var(name, val.perform(environment))
- end
-
- p environment.var(name)
- else
- p Script::Parser.parse(text, @line, 0).perform(environment)
- end
- rescue Sass::SyntaxError => e
- puts "SyntaxError: #{e.message}"
- if @options[:trace]
- e.backtrace.each do |e|
- puts "\tfrom #{e}"
- end
- end
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script.rb
deleted file mode 100644
index bcacabd8..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'strscan'
-require 'sass/script/node'
-require 'sass/script/variable'
-require 'sass/script/funcall'
-require 'sass/script/operation'
-require 'sass/script/literal'
-require 'sass/script/parser'
-
-module Sass
- # SassScript is code that's embedded in Sass documents
- # to allow for property values to be computed from variables.
- #
- # This module contains code that handles the parsing and evaluation of SassScript.
- module Script
- # The character that begins a variable.
- VARIABLE_CHAR = ?!
-
- # The regular expression used to parse variables.
- MATCH = /^!([a-zA-Z_]\w*)\s*((?:\|\|)?=)\s*(.+)/
-
- # The regular expression used to validate variables without matching.
- VALIDATE = /^![a-zA-Z_]\w*$/
-
- # Parses and evaluates a string of SassScript.
- #
- # @param value [String] The SassScript
- # @param line [Fixnum] The number of the line on which the SassScript appeared.
- # Used for error reporting
- # @param offset [Fixnum] The number of characters in on `line` that the SassScript started.
- # Used for error reporting
- # @param environment [Sass::Environment] The environment in which to evaluate the SassScript
- # @return [String] The string result of evaluating the SassScript
- def self.resolve(value, line, offset, environment)
- parse(value, line, offset).perform(environment).to_s
- end
-
- # Parses a string of SassScript
- #
- # @param value [String] The SassScript
- # @param line [Fixnum] The number of the line on which the SassScript appeared.
- # Used for error reporting
- # @param offset [Fixnum] The number of characters in on `line` that the SassScript started.
- # Used for error reporting
- # @param filename [String] The path to the file in which the SassScript appeared.
- # Used for error reporting
- # @return [Script::Node] The root node of the parse tree
- def self.parse(value, line, offset, filename = nil)
- Parser.parse(value, line, offset, filename)
- rescue Sass::SyntaxError => e
- if e.message == "SassScript error"
- e.instance_eval do
- @message += ": #{value.dump}."
- end
- end
- e.sass_line = line
- raise e
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/bool.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/bool.rb
deleted file mode 100644
index 0f455dbd..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/bool.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'sass/script/literal'
-
-module Sass::Script
- # A SassScript object representing a boolean (true or false) value.
- class Bool < Literal
- # The Ruby value of the boolean.
- #
- # @return [Boolean]
- attr_reader :value
- alias_method :to_bool, :value
-
- # @return [String] "true" or "false"
- def to_s
- @value.to_s
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/color.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/color.rb
deleted file mode 100644
index 6e1cce11..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/color.rb
+++ /dev/null
@@ -1,220 +0,0 @@
-require 'sass/script/literal'
-
-module Sass::Script
- # A SassScript object representing a CSS color.
- class Color < Literal
- class << self; include Haml::Util; end
-
- # A hash from color names to `[red, green, blue]` value arrays.
- HTML4_COLORS = map_vals({
- 'black' => 0x000000,
- 'silver' => 0xc0c0c0,
- 'gray' => 0x808080,
- 'white' => 0xffffff,
- 'maroon' => 0x800000,
- 'red' => 0xff0000,
- 'purple' => 0x800080,
- 'fuchsia' => 0xff00ff,
- 'green' => 0x008000,
- 'lime' => 0x00ff00,
- 'olive' => 0x808000,
- 'yellow' => 0xffff00,
- 'navy' => 0x000080,
- 'blue' => 0x0000ff,
- 'teal' => 0x008080,
- 'aqua' => 0x00ffff
- }) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
- # A hash from `[red, green, blue]` value arrays to color names.
- HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
-
- # Creates a new color from RGB components.
- # *Note*: when modifying the components of an existing color,
- # use \{#with} rather than creating a new color object.
- # This preserves forwards-compatiblity for alpha channels and such.
- #
- # @param rgb [Array] A three-element array of the red, green, and blue values (respectively)
- # of the color
- # @raise [Sass::SyntaxError] if any color value isn't between 0 and 255
- def initialize(rgb)
- rgb = rgb.map {|c| c.to_i}
- raise Sass::SyntaxError.new("Color values must be between 0 and 255") if rgb.any? {|c| c < 0 || c > 255}
- super(rgb.freeze)
- end
-
- # @deprecated This will be removed in version 2.6.
- # @see #rgb
- def value
- warn <] A frozen three-element array of the red, green, and blue
- # values (respectively) of the color
- def rgb
- @value
- end
-
- # Returns a copy of this color with one or more channels changed.
- #
- # For example:
- #
- # Color.new([10, 20, 30]).with(:blue => 40)
- # #=> rgb(10, 40, 30)
- # Color.new([126, 126, 126]).with(:red => 0, :green => 255)
- # #=> rgb(0, 255, 126)
- #
- # @param attrs [{Symbol => Fixnum}]
- # A map of channel names (`:red`, `:green`, or `:blue`) to values
- # @return [Color] The new Color object
- def with(attrs)
- Color.new([
- attrs[:red] || rgb[0],
- attrs[:green] || rgb[1],
- attrs[:blue] || rgb[2],
- ])
- end
-
- # The SassScript `+` operation.
- # Its functionality depends on the type of its argument:
- #
- # {Number}
- # : Adds the number to each of the RGB color channels.
- #
- # {Color}
- # : Adds each of the RGB color channels together.
- #
- # {Literal}
- # : See {Literal#plus}.
- #
- # @param other [Literal] The right-hand side of the operator
- # @return [Color] The resulting color
- # @raise [Sass::SyntaxError] if `other` is a number with units
- def plus(other)
- if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
- piecewise(other, :+)
- else
- super
- end
- end
-
- # The SassScript `-` operation.
- # Its functionality depends on the type of its argument:
- #
- # {Number}
- # : Subtracts the number from each of the RGB color channels.
- #
- # {Color}
- # : Subtracts each of the other color's RGB color channels from this color's.
- #
- # {Literal}
- # : See {Literal#minus}.
- #
- # @param other [Literal] The right-hand side of the operator
- # @return [Color] The resulting color
- # @raise [Sass::SyntaxError] if `other` is a number with units
- def minus(other)
- if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
- piecewise(other, :-)
- else
- super
- end
- end
-
- # The SassScript `*` operation.
- # Its functionality depends on the type of its argument:
- #
- # {Number}
- # : Multiplies the number by each of the RGB color channels.
- #
- # {Color}
- # : Multiplies each of the RGB color channels together.
- #
- # @param other [Number, Color] The right-hand side of the operator
- # @return [Color] The resulting color
- # @raise [Sass::SyntaxError] if `other` is a number with units
- def times(other)
- if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
- piecewise(other, :*)
- else
- raise NoMethodError.new(nil, :times)
- end
- end
-
- # The SassScript `/` operation.
- # Its functionality depends on the type of its argument:
- #
- # {Number}
- # : Divides each of the RGB color channels by the number.
- #
- # {Color}
- # : Divides each of this color's RGB color channels by the other color's.
- #
- # {Literal}
- # : See {Literal#div}.
- #
- # @param other [Literal] The right-hand side of the operator
- # @return [Color] The resulting color
- # @raise [Sass::SyntaxError] if `other` is a number with units
- def div(other)
- if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
- piecewise(other, :/)
- else
- super
- end
- end
-
- # The SassScript `%` operation.
- # Its functionality depends on the type of its argument:
- #
- # {Number}
- # : Takes each of the RGB color channels module the number.
- #
- # {Color}
- # : Takes each of this color's RGB color channels modulo the other color's.
- #
- # @param other [Number, Color] The right-hand side of the operator
- # @return [Color] The resulting color
- # @raise [Sass::SyntaxError] if `other` is a number with units
- def mod(other)
- if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
- piecewise(other, :%)
- else
- raise NoMethodError.new(nil, :mod)
- end
- end
-
- # Returns a string representation of the color.
- # This is usually the color's hex value,
- # but if the color has a name that's used instead.
- #
- # @return [String] The string representation
- def to_s
- return HTML4_COLORS_REVERSE[rgb] if HTML4_COLORS_REVERSE[rgb]
- red, green, blue = rgb.map { |num| num.to_s(16).rjust(2, '0') }
- "##{red}#{green}#{blue}"
- end
- alias_method :inspect, :to_s
-
- private
-
- def piecewise(other, operation)
- other_num = other.is_a? Number
- if other_num && !other.unitless?
- raise Sass::SyntaxError.new("Cannot add a number with units (#{other}) to a color (#{self}).")
- end
-
- result = []
- for i in (0...3)
- res = rgb[i].send(operation, other_num ? other.value : other.rgb[i])
- result[i] = [ [res, 255].min, 0 ].max
- end
- with(:red => result[0], :green => result[1], :blue => result[2])
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/funcall.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/funcall.rb
deleted file mode 100644
index 7e144cf1..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/funcall.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require File.join(File.dirname(__FILE__), 'functions')
-module Sass
- module Script
- # A SassScript parse node representing a function call.
- #
- # A function call either calls one of the functions in {Script::Functions},
- # or if no function with the given name exists
- # it returns a string representation of the function call.
- class Funcall < Node
- # The name of the function.
- #
- # @return [String]
- attr_reader :name
-
- # The arguments to the function.
- #
- # @return [Array]
- attr_reader :args
-
- # @param name [String] See \{#name}
- # @param name [Array] See \{#args}
- def initialize(name, args)
- @name = name
- @args = args
- end
-
- # @return [String] A string representation of the function call
- def inspect
- "#{name}(#{args.map {|a| a.inspect}.join(', ')})"
- end
-
- # Evaluates the function call.
- #
- # @param environment [Sass::Environment] The environment in which to evaluate the SassScript
- # @return [Literal] The SassScript object that is the value of the function call
- # @raise [Sass::SyntaxError] if the function call raises an ArgumentError
- def perform(environment)
- args = self.args.map {|a| a.perform(environment)}
- unless Haml::Util.has?(:public_instance_method, Functions, name) && name !~ /^__/
- return Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})")
- end
-
- return Functions::EvaluationContext.new(environment.options).send(name, *args)
- rescue ArgumentError => e
- raise e unless e.backtrace.any? {|t| t =~ /:in `(block in )?(#{name}|perform)'$/}
- raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
- end
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/functions.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/functions.rb
deleted file mode 100644
index fef69602..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/functions.rb
+++ /dev/null
@@ -1,257 +0,0 @@
-module Sass::Script
- # Methods in this module are accessible from the SassScript context.
- # For example, you can write
- #
- # !color = hsl(120, 100%, 50%)
- #
- # and it will call {Sass::Script::Functions#hsl}.
- #
- # The following functions are provided:
- #
- # \{#hsl}
- # : Converts an `hsl(hue, saturation, lightness)` triplet into a color.
- #
- # \{#rgb}
- # : Converts an `rgb(red, green, blue)` triplet into a color.
- #
- # \{#percentage}
- # : Converts a unitless number to a percentage.
- #
- # \{#round}
- # : Rounds a number to the nearest whole number.
- #
- # \{#ceil}
- # : Rounds a number up to the nearest whole number.
- #
- # \{#floor}
- # : Rounds a number down to the nearest whole number.
- #
- # \{#abs}
- # : Returns the absolute value of a number.
- #
- # These functions are described in more detail below.
- #
- # ## Adding Custom Functions
- #
- # New Sass functions can be added by adding Ruby methods to this module.
- # For example:
- #
- # module Sass::Script::Functions
- # def reverse(string)
- # assert_type string, :String
- # Sass::Script::String.new(string.value.reverse)
- # end
- # end
- #
- # There are a few things to keep in mind when modifying this module.
- # First of all, the arguments passed are {Sass::Script::Literal} objects.
- # Literal objects are also expected to be returned.
- # This means that Ruby values must be unwrapped and wrapped.
- #
- # Most Literal objects support the {Sass::Script::Literal#value value} accessor
- # for getting their Ruby values.
- # Color objects, though, must be accessed using {Sass::Script::Color#rgb rgb}.
- #
- # Second, making Ruby functions accessible from Sass introduces the temptation
- # to do things like database access within stylesheets.
- # This is generally a bad idea;
- # since Sass files are by default only compiled once,
- # dynamic code is not a great fit.
- #
- # If you really, really need to compile Sass on each request,
- # first make sure you have adequate caching set up.
- # Then you can use {Sass::Engine} to render the code,
- # using the {file:SASS_REFERENCE.md#custom-option `options` parameter}
- # to pass in data that {EvaluationContext#options can be accessed}
- # from your Sass functions.
- #
- # Within one of the functions in this module,
- # methods of {EvaluationContext} can be used.
- module Functions
- # The context in which methods in {Script::Functions} are evaluated.
- # That means that all instance methods of {EvaluationContext}
- # are available to use in functions.
- class EvaluationContext
- # The options hash for the {Sass::Engine} that is processing the function call
- #
- # @return [{Symbol => Object}]
- attr_reader :options
-
- # @param options [{Symbol => Object}] See \{#options}
- def initialize(options)
- @options = options
-
- # We need to include this individually in each instance
- # because of an icky Ruby restriction
- class << self; include Sass::Script::Functions; end
- end
-
- # Asserts that the type of a given SassScript value
- # is the expected type (designated by a symbol).
- # For example:
- #
- # assert_type value, :String
- # assert_type value, :Number
- #
- # Valid types are `:Bool`, `:Color`, `:Number`, and `:String`.
- #
- # @param value [Sass::Script::Literal] A SassScript value
- # @param type [Symbol] The name of the type the value is expected to be
- def assert_type(value, type)
- return if value.is_a?(Sass::Script.const_get(type))
- raise ArgumentError.new("#{value.inspect} is not a #{type.to_s.downcase}")
- end
- end
-
- instance_methods.each { |m| undef_method m unless m.to_s =~ /^__/ }
-
-
- # Creates a {Color} object from red, green, and blue values.
- # @param red
- # A number between 0 and 255 inclusive,
- # or between 0% and 100% inclusive
- # @param green
- # A number between 0 and 255 inclusive,
- # or between 0% and 100% inclusive
- # @param blue
- # A number between 0 and 255 inclusive,
- # or between 0% and 100% inclusive
- def rgb(red, green, blue)
- assert_type red, :Number
- assert_type green, :Number
- assert_type blue, :Number
-
- rgb = [red, green, blue].map do |c|
- v = c.value
- if c.numerator_units == ["%"] && c.denominator_units.empty?
- next v * 255 / 100.0 if (0..100).include?(v)
- raise ArgumentError.new("Color value #{c} must be between 0% and 100% inclusive")
- else
- next v if (0..255).include?(v)
- raise ArgumentError.new("Color value #{v} must be between 0 and 255 inclusive")
- end
- end
- Color.new(rgb)
- end
-
- # Creates a {Color} object from hue, saturation, and lightness.
- # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
- #
- # @param hue [Number] The hue of the color.
- # Should be between 0 and 360 degrees, inclusive
- # @param saturation [Number] The saturation of the color.
- # Must be between `0%` and `100%`, inclusive
- # @param lightness [Number] The lightness of the color.
- # Must be between `0%` and `100%`, inclusive
- # @return [Color] The resulting color
- # @raise [ArgumentError] if `saturation` or `lightness` are out of bounds
- def hsl(hue, saturation, lightness)
- assert_type hue, :Number
- assert_type saturation, :Number
- assert_type lightness, :Number
-
- original_s = saturation
- original_l = lightness
- # This algorithm is from http://www.w3.org/TR/css3-color#hsl-color
- h, s, l = [hue, saturation, lightness].map { |a| a.value }
- raise ArgumentError.new("Saturation #{s} must be between 0% and 100%") if s < 0 || s > 100
- raise ArgumentError.new("Lightness #{l} must be between 0% and 100%") if l < 0 || l > 100
-
- h = (h % 360) / 360.0
- s /= 100.0
- l /= 100.0
-
- m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s
- m1 = l * 2 - m2
- Color.new([hue_to_rgb(m1, m2, h + 1.0/3),
- hue_to_rgb(m1, m2, h),
- hue_to_rgb(m1, m2, h - 1.0/3)].map { |c| (c * 0xff).round })
- end
-
- # Converts a decimal number to a percentage.
- # For example:
- #
- # percentage(100px / 50px) => 200%
- #
- # @param value [Number] The decimal number to convert to a percentage
- # @return [Number] The percentage
- # @raise [ArgumentError] If `value` isn't a unitless number
- def percentage(value)
- unless value.is_a?(Sass::Script::Number) && value.unitless?
- raise ArgumentError.new("#{value.inspect} is not a unitless number")
- end
- Sass::Script::Number.new(value.value * 100, ['%'])
- end
-
- # Rounds a number to the nearest whole number.
- # For example:
- #
- # round(10.4px) => 10px
- # round(10.6px) => 11px
- #
- # @param value [Number] The number
- # @return [Number] The rounded number
- # @raise [Sass::SyntaxError] if `value` isn't a number
- def round(value)
- numeric_transformation(value) {|n| n.round}
- end
-
- # Rounds a number up to the nearest whole number.
- # For example:
- #
- # ciel(10.4px) => 11px
- # ciel(10.6px) => 11px
- #
- # @param value [Number] The number
- # @return [Number] The rounded number
- # @raise [Sass::SyntaxError] if `value` isn't a number
- def ceil(value)
- numeric_transformation(value) {|n| n.ceil}
- end
-
- # Rounds down to the nearest whole number.
- # For example:
- #
- # floor(10.4px) => 10px
- # floor(10.6px) => 10px
- #
- # @param value [Number] The number
- # @return [Number] The rounded number
- # @raise [Sass::SyntaxError] if `value` isn't a number
- def floor(value)
- numeric_transformation(value) {|n| n.floor}
- end
-
- # Finds the absolute value of a number.
- # For example:
- #
- # abs(10px) => 10px
- # abs(-10px) => 10px
- #
- # @param value [Number] The number
- # @return [Number] The absolute value
- # @raise [Sass::SyntaxError] if `value` isn't a number
- def abs(value)
- numeric_transformation(value) {|n| n.abs}
- end
-
- private
-
- # This method implements the pattern of transforming a numeric value into
- # another numeric value with the same units.
- # It yields a number to a block to perform the operation and return a number
- def numeric_transformation(value)
- assert_type value, :Number
- Sass::Script::Number.new(yield(value.value), value.numerator_units, value.denominator_units)
- end
-
- def hue_to_rgb(m1, m2, h)
- h += 1 if h < 0
- h -= 1 if h > 1
- return m1 + (m2 - m1) * h * 6 if h * 6 < 1
- return m2 if h * 2 < 1
- return m1 + (m2 - m1) * (2.0/3 - h) * 6 if h * 3 < 2
- return m1
- end
- end
-end
diff --git a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/lexer.rb b/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/lexer.rb
deleted file mode 100644
index 268331e2..00000000
--- a/lib/middleman/vendor/gems/ruby/1.8/gems/haml-2.2.17/lib/sass/script/lexer.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-require 'strscan'
-
-module Sass
- module Script
- # The lexical analyzer for SassScript.
- # It takes a raw string and converts it to individual tokens
- # that are easier to parse.
- class Lexer
- # A struct containing information about an individual token.
- #
- # `type`: \[{Symbol}\]
- # : The type of token.
- #
- # `value`: \[{Object}\]
- # : The Ruby object corresponding to the value of the token.
- #
- # `line`: \[{Fixnum}\]
- # : The line of the source file on which the token appears.
- #
- # `offset`: \[{Fixnum}\]
- # : The number of bytes into the line the SassScript token appeared.
- Token = Struct.new(:type, :value, :line, :offset)
-
- # A hash from operator strings to the corresponding token types.
- OPERATORS = {
- '+' => :plus,
- '-' => :minus,
- '*' => :times,
- '/' => :div,
- '%' => :mod,
- '=' => :single_eq,
- '(' => :lparen,
- ')' => :rparen,
- ',' => :comma,
- 'and' => :and,
- 'or' => :or,
- 'not' => :not,
- '==' => :eq,
- '!=' => :neq,
- '>=' => :gte,
- '<=' => :lte,
- '>' => :gt,
- '<' => :lt,
- '#{' => :begin_interpolation,
- '}' => :end_interpolation,
- }
-
- # A list of operator strings ordered with longer names first
- # so that `>` and `<` don't clobber `>=` and `<=`.
- OP_NAMES = OPERATORS.keys.sort_by {|o| -o.size}
-
- # A hash of regular expressions that are used for tokenizing.
- REGULAR_EXPRESSIONS = {
- :whitespace => /\s*/,
- :variable => /!(\w+)/,
- :ident => /(\\.|[^\s\\+\-*\/%(),=!])+/,
- :string_end => /((?:\\.|\#(?!\{)|[^"\\#])*)(?:"|(?=#\{))/,
- :number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/,
- :color => /\##{"([0-9a-fA-F]{1,2})" * 3}|(#{Color::HTML4_COLORS.keys.join("|")})/,
- :bool => /(true|false)\b/,
- :op => %r{(#{Regexp.union(*OP_NAMES.map{|s| Regexp.new(Regexp.escape(s) + (s =~ /\w$/ ? '(?:\b|$)' : ''))})})}
- }
-
- # @param str [String, StringScanner] The source text to lex
- # @param line [Fixnum] The line on which the SassScript appears.
- # Used for error reporting
- # @param offset [Fixnum] The number of characters in on which the SassScript appears.
- # Used for error reporting
- def initialize(str, line, offset, filename)
- @scanner = str.is_a?(StringScanner) ? str : StringScanner.new(str)
- @line = line
- @offset = offset
- @filename = filename
- @prev = nil
- end
-
- # Moves the lexer forward one token.
- #
- # @return [Token] The token that was moved past
- def next
- @tok ||= read_token
- @tok, tok = nil, @tok
- @prev = tok
- return tok
- end
-
- # Returns the next token without moving the lexer forward.
- #
- # @return [Token] The next token
- def peek
- @tok ||= read_token
- end
-
- # @return [Boolean] Whether or not there's more source text to lex.
- def done?
- whitespace unless after_interpolation?
- @scanner.eos? && @tok.nil?
- end
-
- private
-
- def read_token
- return if done?
-
- value = token
- unless value
- raise SyntaxError.new("Syntax error in '#{@scanner.string}' at character #{current_position}.")
- end
- Token.new(value.first, value.last, @line, last_match_position)
- end
-
- def whitespace
- @scanner.scan(REGULAR_EXPRESSIONS[:whitespace])
- end
-
- def token
- return string('') if after_interpolation?
- variable || string || number || color || bool || op || ident
- end
-
- def variable
- return unless @scanner.scan(REGULAR_EXPRESSIONS[:variable])
- [:const, @scanner[1]]
- end
-
- def ident
- return unless s = @scanner.scan(REGULAR_EXPRESSIONS[:ident])
- [:ident, s.gsub(/\\(.)/, '\1')]
- end
-
- def string(start_char = '"')
- return unless @scanner.scan(/#{start_char}#{REGULAR_EXPRESSIONS[:string_end]}/)
- [:string, Script::String.new(@scanner[1].gsub(/\\([^0-9a-f])/, '\1').gsub(/\\([0-9a-f]{1,4})/, "\\\\\\1"))]
- end
-
- def begin_interpolation
- @scanner.scan
- end
-
- def number
- return unless @scanner.scan(REGULAR_EXPRESSIONS[:number])
- value = @scanner[2] ? @scanner[2].to_f : @scanner[3].to_i
- value = -value if @scanner[1]
- [:number, Script::Number.new(value, Array(@scanner[4]))]
- end
-
- def color
- return unless @scanner.scan(REGULAR_EXPRESSIONS[:color])
- value = if @scanner[4]
- color = Color::HTML4_COLORS[@scanner[4].downcase]
- else
- (1..3).map {|i| @scanner[i]}.map {|num| num.ljust(2, num).to_i(16)}
- end
- [:color, Script::Color.new(value)]
- end
-
- def bool
- return unless s = @scanner.scan(REGULAR_EXPRESSIONS[:bool])
- [:bool, Script::Bool.new(s == 'true')]
- end
-
- def op
- prev_chr = @scanner.string[@scanner.pos - 1].chr
- return unless op = @scanner.scan(REGULAR_EXPRESSIONS[:op])
- if @prev && op == '-' && prev_chr !~ /\s/ &&
- [:bool, :ident, :const].include?(@prev.type)
- warn(<]
- attr_reader :numerator_units
-
- # A list of units in the denominator of the number.
- # For example, `1px*em/in*cm` would return `["in", "cm"]`
- # @return [Array]
- attr_reader :denominator_units
-
- # The precision with which numbers will be printed to CSS files.
- # For example, if this is `1000.0`,
- # `3.1415926` will be printed as `3.142`.
- PRECISION = 1000.0
-
- # @param value [Numeric] The value of the number
- # @param numerator_units [Array