// Used for creating the source string for fonts using @font-face
// Reference: http://goo.gl/Ru1bKP

@function font-url-prefixer($asset-pipeline) {
  @if $asset-pipeline == true {
    @return font-url;
  } @else {
    @return url;
  }
}

@function font-source-declaration(
  $font-family,
  $file-path,
  $asset-pipeline,
  $file-formats,
  $font-url) {

  $src: null;

  $formats-map: (
    eot:   $font-url + "(\"#{$file-path}.eot?#iefix\")" format("embedded-opentype"),
    woff2: $font-url + "(\"#{$file-path}.woff2\")" format("woff2"),
    woff:  $font-url + "(\"#{$file-path}.woff\")" format("woff"),
    ttf:   $font-url + "(\"#{$file-path}.ttf\")" format("truetype"),
    svg:   $font-url + "(\"#{$file-path}.svg##{$font-family}\")" format("svg")
  );

  @each $format, $file-path in $formats-map {
    @if contains($file-formats, $format) {
      $src: append($src, $file-path, comma);
    }
  }

  @return $src;
}

// Used for creating the source string for fonts using @font-face
// Reference: http://goo.gl/Ru1bKP

@function font-url-prefixer($asset-pipeline) {
  @if $asset-pipeline == true {
    @return font-url;
  } @else {
    @return url;
  }
}

@function font-source-declaration(
  $font-family,
  $file-path,
  $asset-pipeline,
  $file-formats,
  $font-url) {

  $src: null;

  $formats-map: (
    eot:   "#{$file-path}.eot?#iefix" format("embedded-opentype"),
    woff2: "#{$file-path}.woff2" format("woff2"),
    woff:  "#{$file-path}.woff" format("woff"),
    ttf:   "#{$file-path}.ttf" format("truetype"),
    svg:   "#{$file-path}.svg##{$font-family}" format("svg")
  );

  @each $key, $values in $formats-map {
    @if contains($file-formats, $key) {
      $file-path: nth($values, 1);
      $font-format: nth($values, 2);

      @if $asset-pipeline == true {
        $src: append($src, font-url($file-path) $font-format, comma);
      } @else {
        $src: append($src, url($file-path) $font-format, comma);
      }
    }
  }

  @return $src;
}

Fix `font-url` for `sass-rails` > 5.x
Fix `font-url` for `sass-rails` > 5.x

When using newer versions of `sass-rails`, the `$asset-pipeline` flag
wasn't working properly. Although the `font-url` asset helper from
`sass-rails` was being generated into the resulting CSS, it was not
being post-processed by the asset pipeline.

The way we were previously outputting the `font-url` caused `sass-rails`
to not recognize the `font-url` helper. This change appends the helper
in a more direct way, and this resolves the issue.

Fixes #603
