active_assets 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/active_assets.gemspec +1 -1
- data/lib/active_assets/active_sprites/railtie.rb +4 -2
- data/lib/active_assets/active_sprites/runners/abstract_runner.rb +12 -27
- data/lib/active_assets/active_sprites/runners/chunky_png_runner.rb +1 -1
- data/lib/active_assets/active_sprites/runners/mini_magick_runner.rb +1 -1
- data/lib/active_assets/active_sprites/runners/rmagick_runner.rb +1 -1
- data/lib/active_assets/active_sprites.rb +2 -0
- metadata +4 -4
data/active_assets.gemspec
CHANGED
@@ -18,8 +18,10 @@ module ActiveAssets
|
|
18
18
|
|
19
19
|
initializer 'active_sprites-load-definitons' do
|
20
20
|
Rails.application.config.paths.config.paths.each {|config_path| load_sprite_definition(config_path) }
|
21
|
-
|
22
|
-
|
21
|
+
if config.active_sprites.load_engine_sprite_definitions
|
22
|
+
Rails.application.railties.engines.map(&:config).map(&:paths).map(&:config).map(&:paths).each do |config_path|
|
23
|
+
load_sprite_definition(config_path)
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -12,7 +12,6 @@ module ActiveAssets
|
|
12
12
|
|
13
13
|
def initialize(railtie, sprites)
|
14
14
|
@railtie = railtie
|
15
|
-
setup_context
|
16
15
|
@sprites = if ENV['SPRITE']
|
17
16
|
sprites.select do |name, sprite|
|
18
17
|
ENV['SPRITE'].split(',').map(&:strip).any? do |sp|
|
@@ -45,8 +44,8 @@ module ActiveAssets
|
|
45
44
|
$stdout << "Starting Sprite, #{sprite.path}\n"
|
46
45
|
end
|
47
46
|
|
48
|
-
sprite_path =
|
49
|
-
sprite_stylesheet_path =
|
47
|
+
sprite_path = image_computed_path(sprite.path)
|
48
|
+
sprite_stylesheet_path = stylesheet_computed_path(sprite.stylesheet_path)
|
50
49
|
|
51
50
|
orientation = sprite.orientation.to_s
|
52
51
|
sprite_pieces = sprite.sprite_pieces
|
@@ -87,36 +86,22 @@ module ActiveAssets
|
|
87
86
|
end
|
88
87
|
|
89
88
|
private
|
90
|
-
def
|
91
|
-
File.join(
|
89
|
+
def image_computed_path(path)
|
90
|
+
File.join('images', path)
|
92
91
|
end
|
93
92
|
|
94
|
-
def
|
95
|
-
@
|
93
|
+
def image_computed_full_path(path)
|
94
|
+
File.join(@railtie.config.paths.public.to_a.first, image_computed_path(path))
|
96
95
|
end
|
97
96
|
|
98
|
-
def
|
99
|
-
|
97
|
+
def stylesheet_computed_path(path)
|
98
|
+
stylesheet_full_path = @railtie.config.respond_to?(:action_controller) && @railtie.config.paths.public.stylesheets.to_a.first
|
99
|
+
stylesheet_path = stylesheet_full_path ? stylesheet_full_path[%r{public/(.*)}, 1] : 'stylesheets'
|
100
|
+
File.join(stylesheet_path, path)
|
100
101
|
end
|
101
102
|
|
102
|
-
def
|
103
|
-
|
104
|
-
@railtie.config.action_controller = ActiveSupport::OrderedOptions.new
|
105
|
-
|
106
|
-
paths = @railtie.config.paths
|
107
|
-
options = @railtie.config.action_controller
|
108
|
-
|
109
|
-
options.assets_dir ||= paths.public.to_a.first
|
110
|
-
options.javascripts_dir ||= paths.public.javascripts.to_a.first
|
111
|
-
options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
|
112
|
-
|
113
|
-
ActiveSupport.on_load(:action_controller) do
|
114
|
-
options.each { |k,v| send("#{k}=", v) }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
controller = ActionController::Base.new
|
119
|
-
@context = AssetContext.new(@railtie.config.action_controller, {}, controller)
|
103
|
+
def sanitize_asset_path(path)
|
104
|
+
path.split('?').first
|
120
105
|
end
|
121
106
|
|
122
107
|
end
|
@@ -12,7 +12,7 @@ module ActiveAssets
|
|
12
12
|
width, height = 0, 0
|
13
13
|
|
14
14
|
image_list = sprite_pieces.map do |sp|
|
15
|
-
sprite_piece_path =
|
15
|
+
sprite_piece_path = image_computed_full_path(sp.path)
|
16
16
|
sp_image = ChunkyPNG::Image.from_file(sprite_piece_path)
|
17
17
|
sp.details = SpritePiece::Details.new(
|
18
18
|
sprite.url.present? ? sprite.url : sprite_path,
|
@@ -14,7 +14,7 @@ module ActiveAssets
|
|
14
14
|
offset = 0
|
15
15
|
|
16
16
|
image_list = sprite_pieces.map do |sp|
|
17
|
-
sp_path =
|
17
|
+
sp_path = image_computed_full_path(sp.path)
|
18
18
|
image = MiniMagick::Image.open(sp_path)
|
19
19
|
sp.details = SpritePiece::Details.new(
|
20
20
|
sprite.url.present? ? sprite.url : sprite_path,
|
@@ -10,7 +10,7 @@ module ActiveAssets
|
|
10
10
|
private
|
11
11
|
def set_sprite_details_and_return_image_list(sprite, sprite_path, sprite_pieces, orientation)
|
12
12
|
sprite_piece_paths = sprite_pieces.map do |sp|
|
13
|
-
|
13
|
+
image_computed_full_path(sp.path)
|
14
14
|
end
|
15
15
|
image_list = ImageList.new(*sprite_piece_paths)
|
16
16
|
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Woodard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-03 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|