Глюк compass, проект на rails?

Суть проблемы описана в Настроить пути compass?. Бился над решением непрерывно, но оно так и не приходит. Начал ковырять исходники гемов. Задача стоит в том, чтобы узнать из-за чего гем compass или compass-core или compass-rails или sprockets устанавливают ведущий слеш перед путем к спрайту. Как выяснилось настройки compass:
Compass.configuration.http_generated_images_path = 'sprites'
Compass.configuration.relative_assets = false

совершенно не влияют ни на что. А вот почему. Я нашел то место в геме, откуда берется вычисление url спрайта в css:
../gems/compass-1.0.3/lib/compass/sass_extensions/functions/sprites.rb
def sprite_url(map)
    puts("мы здесь были")
    verify_map(map, "sprite-url")
    map.generate
    generated_image_url(identifier("#{map.path}-s#{map.uniqueness_hash}.png"))
  end

../gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions/urls.rb
module GeneratedImageUrl
    def self.included(base)
      if base.respond_to?(:declare)
        base.declare :generated_image_url, [:path]
        base.declare :generated_image_url, [:path, :cache_buster]
      end
    end
    def generated_image_url(path, cache_buster = bool(false))
      path = path.value # get to the string value of the literal.

      if path =~ %r{^#{Regexp.escape(Compass.configuration.http_generated_images_path)}/(.*)}
        # Treat root relative urls (without a protocol) like normal if they start with
        # the generated_images path.
        path = $1
      elsif absolute_path?(path)
        # Short curcuit if they have provided an absolute url.
        return unquoted_string("url(#{path})")
      end

      # Compute the path to the image, either root relative or stylesheet relative
      # or nil if the http_generated_images_path is not set in the configuration.
      http_generated_images_path = if relative?
        compute_relative_path(Compass.configuration.generated_images_path)
      elsif Compass.configuration.http_generated_images_path
        Compass.configuration.http_generated_images_path
      else
        Compass.configuration.http_root_relative(Compass.configuration.generated_images_dir)
      end

      # Compute the real path to the image on the file stystem if the generated_images_dir is set.
      real_path = if Compass.configuration.generated_images_path
        File.join(Compass.configuration.generated_images_path, path.gsub(/#.*$/,""))
      else
        File.join(Compass.configuration.project_path, path.gsub(/#.*$/,""))
      end

      # prepend the path to the image if there's one
      if http_generated_images_path
        http_generated_images_path = "#{http_generated_images_path}/" unless http_generated_images_path[-1..-1] == "/"
        path = "#{http_generated_images_path}#{path}"
      end

      # Compute the asset host unless in relative mode.
      asset_host = if !relative? && Compass.configuration.asset_host
        Compass.configuration.asset_host.call(path)
      end

      # Compute and append the cache buster if there is one.
      if cache_buster.to_bool
        path, anchor = path.split("#", 2)
        if cache_buster.is_a?(Sass::Script::Value::String)
          path += "#{path["?"] ? "&" : "?"}#{cache_buster.value}"
        else
          path = cache_busted_path(path, real_path)
        end
        path = "#{path}#{"#" if anchor}#{anchor}"
      end

      # prepend the asset host if there is one.
      path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host

      clean_url(path)
    end
  end

../gems/gems/compass-rails-2.0.5/lib/compass-rails/patches/4_0.rb
def generated_image_url(path, cache_buster = Sass::Script::Bool.new(false))
    cachebust_generated_images(path)
    asset_url(path)
  end

Вы заметили 2 одинаковые функции с именем generated_image_url?
Так вот, если я изменяю исходники гемов, так чтобы вызвалась функция гема compass-core (я в 2 местах переименовал функцию generated_image_url), то настройки http_generated_images_path, relative_assets начинают работать и все получается. Отсюда спрашивается: Какого черта их там две и вызывается не та))?

Весь интернет перерыл, похожее есть, тоже неверный путь к картинкам, но там все решается путем манипулирования assets-path в файле css:
background-image: asset-path(какой/то/путь). А у меня эти стейтменты генерит компас и я в sass файлах их не вижу, просто включаю две строчки:
@import "sprites/theme/icons/*.png"
@include all-icons-sprites

поэтому нужно, чтобы этот путь был правильным, рождаясь где-то в недрах компаса. Помогите немного, устал на одном месте топтаться..
  • Вопрос задан
  • 294 просмотра
Решения вопроса 1
@sunnmas Автор вопроса
Ruby
../gems/gems/compass-rails-2.0.5/lib/compass-rails/patches/4_0.rb
//def generated_image_url(path, cache_buster = Sass::Script::Bool.new(false))
//    cachebust_generated_images(path)
//    asset_url(path)
//  end

а компиляцию ресурсов буду делать локально, главное теперь в гем файле все с версиями прописать, чтобы на другую версию случайно не перешел
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
08 мая 2024, в 19:51
10000 руб./за проект
08 мая 2024, в 19:42
150000 руб./за проект
08 мая 2024, в 19:41
1500 руб./за проект