require 'delegate' require 'forwardable' require 'nokogiri' # TODO => replace with Builder require 'sass' require 'ice_nine' require 'equalizer' module Hexp # Inject the Hexp::DSL module into classes that include Hexp # # @param [Class] klazz # The class that included Hexp # # @return [Class] # # @api private def self.included(klazz) klazz.send(:include, Hexp::DSL) end # Deep freeze an object # # Delegates to IceNine # # @param [Array] args # arguments to pass on # @return [Object] # # @api private def self.deep_freeze(*args) IceNine.deep_freeze(*args) end # Variant of ::Array with slightly modified semantics # # `Array()` is often used to wrap a value in an Array, unless it's already # an array. However if your object implements `#to_a`, then `Array()` will use # that value. Because of this objects that aren't Array-like will get # converted as well, such as Struct objects. # # This implementation relies on #to_ary, which signals that the Object is # a drop-in replacement for an actual Array. # # @param [Object] arg # # @return [Array] # # @api private def self.Array(arg) if arg.respond_to? :to_ary arg.to_ary else [ arg ] end end # Parse HTML to Hexp # # The input have a single root element. If there are multiple only the first # will be converted. If there is no root element (e.g. an empty document, or # only a DTD or comment) then an error is raised # # @example # Hexp.parse('