active_assets 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
data/active_assets.gemspec
CHANGED
@@ -53,7 +53,7 @@ module ActiveAssets
|
|
53
53
|
|
54
54
|
image_list.each_with_index do |image, i|
|
55
55
|
sprite_pieces[i].details = SpriteDetails.new(
|
56
|
-
sprite_path,
|
56
|
+
sprite.url.present? ? sprite.url : sprite_path,
|
57
57
|
orientation == Sprite::Orientation::VERTICAL ? 0 : "#{-offset}px",
|
58
58
|
orientation == Sprite::Orientation::VERTICAL ? "#{-offset}px" : 0,
|
59
59
|
"#{image.columns}px",
|
@@ -21,7 +21,7 @@ module ActiveAssets
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
attr_reader :path, :stylesheet_path, :name, :orientation, :quality, :matte_color
|
24
|
+
attr_reader :path, :stylesheet_path, :name, :orientation, :quality, :matte_color, :url
|
25
25
|
|
26
26
|
def initialize
|
27
27
|
# Ordered Hash?
|
@@ -89,6 +89,12 @@ module ActiveAssets
|
|
89
89
|
def quality=(val)
|
90
90
|
@quality = val
|
91
91
|
end
|
92
|
+
|
93
|
+
# The url to be used in the background attributes on the stylesheet
|
94
|
+
# it can be overriden but its the path to ths sprite, but default.
|
95
|
+
def url=(val)
|
96
|
+
@url = val
|
97
|
+
end
|
92
98
|
end
|
93
99
|
end
|
94
100
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'css_parser'
|
2
3
|
|
3
4
|
class SpriteTest < Test::Unit::TestCase
|
4
5
|
def setup
|
@@ -66,4 +67,27 @@ class SpriteTest < Test::Unit::TestCase
|
|
66
67
|
|
67
68
|
assert_equal '#FFFFFF', Rails.application.sprites[:foobas].matte_color
|
68
69
|
end
|
70
|
+
|
71
|
+
def test_url
|
72
|
+
Rails.application.sprites do
|
73
|
+
sprite :foobar, :url => "activecodebase.com" do
|
74
|
+
_"sprite_images/sprite3/1.gif" => ".klass_1"
|
75
|
+
_"sprite_images/sprite3/2.gif" => ".klass_2"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Rails.application.sprites.generate!
|
80
|
+
|
81
|
+
sprite = Rails.application.sprites[:foobar]
|
82
|
+
parser = CssParser::Parser.new
|
83
|
+
parser.load_file!(File.basename(sprite.stylesheet_path), File.dirname(Rails.root.join('public/stylesheets', sprite.stylesheet_path)), :screen)
|
84
|
+
|
85
|
+
uses_url = true
|
86
|
+
|
87
|
+
parser.each_selector do |selector, declarations, specificity|
|
88
|
+
uses_url &= declarations[%r{url\('(.+)'\)},1] == "activecodebase.com"
|
89
|
+
end
|
90
|
+
|
91
|
+
assert uses_url
|
92
|
+
end
|
69
93
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Woodard
|