active_assets 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -2
- data/active_assets.gemspec +5 -2
- data/lib/active_assets.rb +11 -3
- data/lib/active_assets/active_expansions.rb +17 -10
- data/lib/active_assets/active_expansions/expansion.rb +0 -1
- data/lib/active_assets/active_expansions/expansions.rb +13 -5
- data/lib/active_assets/active_expansions/railtie.rb +1 -1
- data/lib/active_assets/active_sprites.rb +14 -31
- data/lib/active_assets/active_sprites/railtie.rb +1 -1
- data/lib/active_assets/active_sprites/runners/abstract_runner.rb +23 -11
- data/lib/active_assets/active_sprites/sprite_piece.rb +0 -2
- data/lib/active_assets/active_sprites/sprites.rb +20 -14
- data/lib/active_assets/rails2_support.rb +32 -0
- data/rails_generators/active_assets/USAGE +0 -0
- data/rails_generators/active_assets/active_assets_generator.rb +8 -0
- data/rails_generators/active_assets/templates/active_assets.rake +4 -0
- data/rails_generators/active_assets/templates/active_assets.rb +57 -0
- data/test/active_assets/active_expansions/expansions_test.rb +8 -7
- data/test/fixtures/rails_root_23/Rakefile +10 -0
- data/test/fixtures/rails_root_23/config/assets/assets.rb +71 -0
- data/test/fixtures/rails_root_23/config/boot.rb +113 -0
- data/test/fixtures/rails_root_23/config/environment.rb +41 -0
- data/test/fixtures/rails_root_23/config/environments/development.rb +17 -0
- data/test/fixtures/rails_root_23/config/environments/production.rb +28 -0
- data/test/fixtures/rails_root_23/config/environments/test.rb +28 -0
- data/test/fixtures/rails_root_23/config/initializers/active_assets.rb +53 -0
- data/test/fixtures/rails_root_23/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/rails_root_23/config/initializers/cookie_verification_secret.rb +7 -0
- data/test/fixtures/rails_root_23/config/initializers/inflections.rb +10 -0
- data/test/fixtures/rails_root_23/config/initializers/mime_types.rb +5 -0
- data/test/fixtures/rails_root_23/config/initializers/new_rails_defaults.rb +21 -0
- data/test/fixtures/rails_root_23/config/initializers/session_store.rb +15 -0
- data/test/fixtures/rails_root_23/config/locales/en.yml +5 -0
- data/test/fixtures/rails_root_23/config/routes.rb +43 -0
- data/test/fixtures/rails_root_23/config/sprites.rb +14 -0
- data/test/fixtures/rails_root_23/log/test.log +1 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite3/1.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite3/2.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Argentina.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Australia.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Austria.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Belgium.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Brazil.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Cameroon.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Canada.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Chile.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/China.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Denmark.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Finland.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/France.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Germany.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Greece.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Hong Kong.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Hungary.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Iceland.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/India.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Indonesia.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Ireland.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Israel.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Italy.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Japan.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Malaysia.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Mexico.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/New Zealand.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Norway.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Pakistan.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Palestine.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Peru.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Poland.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Portugal.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Puerto Rico.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Romania.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Russia.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Saudi Arabia.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Singapore.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/South Africa.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/South Korea.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Spain.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Sweden.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Switzerland.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Thailand.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/The Netherlands.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Turkey.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/UK.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/USA.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Ukraine.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Uruguay.png +0 -0
- data/test/fixtures/rails_root_23/public/images/sprite_images/sprite4/Venezuela.png +0 -0
- data/test/fixtures/rails_root_23/public/javascripts/bar/bas.js +1 -0
- data/test/fixtures/rails_root_23/public/javascripts/bas/bar.js +1 -0
- data/test/fixtures/rails_root_23/public/stylesheets/bar/bas.css +1 -0
- data/test/fixtures/rails_root_23/public/stylesheets/bas/bar.css +1 -0
- data/test/helper.rb +2 -5
- data/test/support/rails_helper.rb +17 -5
- metadata +217 -38
- data/lib/active_assets/active_expansions/configurable.rb +0 -14
- data/lib/active_assets/active_sprites/configurable.rb +0 -13
- data/lib/tasks/active_expansions/cache.rake +0 -6
- data/lib/tasks/active_sprites/sprites.rake +0 -5
data/Rakefile
CHANGED
data/active_assets.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "active_assets"
|
4
|
-
s.version = '0.
|
4
|
+
s.version = '0.3.0'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = ["Sam Woodard"]
|
7
7
|
s.email = ["sam@wildfireapp.com"]
|
@@ -16,12 +16,15 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
+
s.add_runtime_dependency "activesupport", "~>2.3.5"
|
20
|
+
|
21
|
+
s.add_development_dependency 'rails', "~>2.3.5"
|
22
|
+
s.add_development_dependency 'rake'
|
19
23
|
s.add_development_dependency 'oily_png'
|
20
24
|
s.add_development_dependency 'chunky_png'
|
21
25
|
s.add_development_dependency 'rmagick'
|
22
26
|
s.add_development_dependency 'mini_magick'
|
23
27
|
s.add_development_dependency 'css_parser', '~>1.1.5'
|
24
|
-
s.add_development_dependency "rails", "~>3.0.3"
|
25
28
|
s.add_development_dependency "test-unit", "> 2.0"
|
26
29
|
s.add_development_dependency "ZenTest", "~>4.4.2"
|
27
30
|
end
|
data/lib/active_assets.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
|
3
3
|
module ActiveAssets
|
4
|
-
|
4
|
+
autoload :ActiveExpansions, 'active_assets/active_expansions'
|
5
|
+
autoload :ActiveSprites, 'active_assets/active_sprites'
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
def self.rails2?
|
8
|
+
rv = Rails.version rescue nil
|
9
|
+
rv ||= RAILS_GEM_VERSION rescue nil
|
10
|
+
rv ||= Gem.loaded_specs.find { |n,spec| n == 'rails' }[1].version.to_s
|
11
|
+
|
12
|
+
Gem::Version.new(rv) < Gem::Version.new('3.0.0.beta')
|
13
|
+
end
|
8
14
|
end
|
15
|
+
|
16
|
+
require 'active_assets/rails2_support' if ActiveAssets.rails2?
|
@@ -2,16 +2,23 @@ require 'active_support'
|
|
2
2
|
|
3
3
|
module ActiveAssets
|
4
4
|
module ActiveExpansions
|
5
|
-
|
5
|
+
autoload :Asset, 'active_assets/active_expansions/asset'
|
6
|
+
autoload :AssetScope, 'active_assets/active_expansions/asset_scope'
|
7
|
+
autoload :TypeInferrable, 'active_assets/active_expansions/type_inferrable'
|
8
|
+
autoload :Configurable, 'active_assets/active_expansions/configurable'
|
9
|
+
autoload :Expansion, 'active_assets/active_expansions/expansion'
|
10
|
+
autoload :Assets, 'active_assets/active_expansions/assets'
|
11
|
+
autoload :Javascripts, 'active_assets/active_expansions/javascripts'
|
12
|
+
autoload :Stylesheets, 'active_assets/active_expansions/stylesheets'
|
13
|
+
autoload :Expansions, 'active_assets/active_expansions/expansions'
|
6
14
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
autoload :Expansions
|
15
|
+
def self.define_tasks
|
16
|
+
namespace :activeexpansions do
|
17
|
+
desc "Cache the active expansions to the {stylesheets,javascripts} cache directory"
|
18
|
+
task :cache => :environment do
|
19
|
+
Rails.application.expansions.javascripts.cache! and Rails.application.expansions.stylesheets.cache!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
16
23
|
end
|
17
24
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require 'active_support/configurable'
|
2
|
-
|
3
1
|
module ActiveAssets
|
4
2
|
module ActiveExpansions
|
5
3
|
class Expansions
|
6
4
|
include AssetScope
|
7
5
|
include TypeInferrable
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
|
7
|
+
@@precache_assets = false
|
8
|
+
cattr_accessor :precache_assets
|
9
|
+
|
10
|
+
ActiveSupport.run_load_hooks(:active_expansions, self) if ActiveSupport.respond_to?(:run_load_hooks)
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@expansions = Hash.new(&method(:build_expansions_hash_with_defaults))
|
@@ -71,6 +71,14 @@ module ActiveAssets
|
|
71
71
|
@expansions.clear
|
72
72
|
end
|
73
73
|
|
74
|
+
def precache_assets
|
75
|
+
@@precache_assets
|
76
|
+
end
|
77
|
+
|
78
|
+
def precache_assets=(val)
|
79
|
+
@@precache_assets = val
|
80
|
+
end
|
81
|
+
|
74
82
|
private
|
75
83
|
def defer_expansion(name, options, &blk)
|
76
84
|
@deferred_expansion_config = [name, options]
|
@@ -6,7 +6,7 @@ module ActiveAssets
|
|
6
6
|
module ActiveExpansions
|
7
7
|
class Railtie < Rails::Railtie
|
8
8
|
rake_tasks do
|
9
|
-
|
9
|
+
ActiveAssets::ActiveExpansions.define_tasks
|
10
10
|
end
|
11
11
|
|
12
12
|
config.active_expansions = ActiveSupport::OrderedOptions.new
|
@@ -2,38 +2,21 @@ require 'active_support'
|
|
2
2
|
|
3
3
|
module ActiveAssets
|
4
4
|
module ActiveSprites
|
5
|
-
|
6
|
-
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
11
|
-
autoload :
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def self.load_engine_tasks(engine_class)
|
20
|
-
desc "Generate sprites"
|
21
|
-
task :sprites do
|
22
|
-
require 'rails'
|
23
|
-
require 'rails/active_sprites'
|
24
|
-
|
5
|
+
autoload :SpritePiece, 'active_assets/active_sprites/sprite_piece'
|
6
|
+
autoload :Sprite, 'active_assets/active_sprites/sprite'
|
7
|
+
autoload :Sprites, 'active_assets/active_sprites/sprites'
|
8
|
+
autoload :Configurable, 'active_assets/active_sprites/configurable'
|
9
|
+
autoload :SpriteStylesheet, 'active_assets/active_sprites/sprite_stylesheet'
|
10
|
+
autoload :AbstractRunner, 'active_assets/active_sprites/runners/abstract_runner'
|
11
|
+
autoload :RmagickRunner, 'active_assets/active_sprites/runners/rmagick_runner'
|
12
|
+
autoload :MiniMagickRunner, 'active_assets/active_sprites/runners/mini_magick_runner'
|
13
|
+
autoload :ChunkyPngRunner, 'active_assets/active_sprites/runners/chunky_png_runner'
|
14
|
+
|
15
|
+
def self.define_tasks
|
16
|
+
desc "Generate sprites."
|
17
|
+
task :sprites => :environment do
|
25
18
|
ENV['VERBOSE'] ||= 'true'
|
26
|
-
|
27
|
-
Rails.application ||= Class.new(Rails::Application)
|
28
|
-
Rails.application.extend Rails::ActiveSprites
|
29
|
-
|
30
|
-
engine = engine_class.new
|
31
|
-
sprite_path = File.join(engine.config.paths.config.paths.first, 'sprites.rb')
|
32
|
-
|
33
|
-
if File.exists?(sprite_path)
|
34
|
-
load sprite_path
|
35
|
-
Rails.application.sprites.generate!(engine)
|
36
|
-
end
|
19
|
+
Rails.application.sprites.generate!
|
37
20
|
end
|
38
21
|
end
|
39
22
|
|
@@ -9,7 +9,7 @@ module ActiveAssets
|
|
9
9
|
config.active_sprites = ActiveSupport::OrderedOptions.new
|
10
10
|
|
11
11
|
rake_tasks do
|
12
|
-
|
12
|
+
ActiveAssets::ActiveSprites.define_tasks
|
13
13
|
end
|
14
14
|
|
15
15
|
initializer 'active_sprites-extend-application' do
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'action_controller'
|
2
2
|
require 'action_view'
|
3
|
-
require 'rack/mount'
|
4
3
|
require 'action_view'
|
5
4
|
require 'fileutils'
|
6
5
|
|
@@ -10,15 +9,14 @@ module ActiveAssets
|
|
10
9
|
class AssetContext < ActionView::Base
|
11
10
|
end
|
12
11
|
|
13
|
-
def initialize(
|
14
|
-
@railtie = railtie
|
12
|
+
def initialize(sprites)
|
15
13
|
@sprites = if ENV['SPRITE']
|
16
14
|
sprites.select do |name, sprite|
|
17
15
|
ENV['SPRITE'].split(',').map(&:strip).any? do |sp|
|
18
16
|
# were going to be very forgiving
|
19
17
|
name == sp ||
|
20
18
|
name == sp.to_sym ||
|
21
|
-
name ==
|
19
|
+
name == self.normalize_path(sp)
|
22
20
|
end
|
23
21
|
end.map(&:last)
|
24
22
|
else
|
@@ -61,7 +59,7 @@ module ActiveAssets
|
|
61
59
|
end
|
62
60
|
|
63
61
|
stylesheet = SpriteStylesheet.new(sprite_pieces)
|
64
|
-
stylesheet_file_path = File.join(
|
62
|
+
stylesheet_file_path = File.join(Rails.public_path, sprite_stylesheet_path)
|
65
63
|
$stdout << "Writing stylesheet to #{stylesheet_file_path} ... " if verbose
|
66
64
|
stylesheet.write stylesheet_file_path
|
67
65
|
$stdout << "done.\n" if verbose
|
@@ -70,7 +68,7 @@ module ActiveAssets
|
|
70
68
|
create_sprite(sprite, sprite_path, sprite_pieces, image_list, width, height, orientation, verbose)
|
71
69
|
$stdout << "Success!\n" if verbose
|
72
70
|
|
73
|
-
sprite_file_path = File.join(
|
71
|
+
sprite_file_path = File.join(Rails.public_path, sprite_path)
|
74
72
|
$stdout << "Writing sprite to #{sprite_file_path} ... " if verbose
|
75
73
|
write sprite_file_path, sprite.quality
|
76
74
|
$stdout << "done.\n" if verbose
|
@@ -91,13 +89,11 @@ module ActiveAssets
|
|
91
89
|
end
|
92
90
|
|
93
91
|
def image_computed_full_path(path)
|
94
|
-
File.join(
|
92
|
+
File.join(Rails.public_path, image_computed_path(path))
|
95
93
|
end
|
96
94
|
|
97
95
|
def stylesheet_computed_path(path)
|
98
|
-
|
99
|
-
stylesheet_path = stylesheet_full_path ? stylesheet_full_path[%r{public/(.*)}, 1] : 'stylesheets'
|
100
|
-
File.join(stylesheet_path, path)
|
96
|
+
File.join('stylesheets', path)
|
101
97
|
end
|
102
98
|
|
103
99
|
def sanitize_asset_path(path)
|
@@ -105,9 +101,25 @@ module ActiveAssets
|
|
105
101
|
end
|
106
102
|
|
107
103
|
def sprite_url(sprite, sprite_path)
|
108
|
-
sprite.url.present? ? sprite.url :
|
104
|
+
sprite.url.present? ? sprite.url : normalize_path(sprite_path)
|
109
105
|
end
|
110
106
|
|
107
|
+
# Rack::Mount::Utils#normalize_path from rack-mount 0.6.13
|
108
|
+
# Normalizes URI path.
|
109
|
+
#
|
110
|
+
# Strips off trailing slash and ensures there is a leading slash.
|
111
|
+
#
|
112
|
+
# normalize_path("/foo") # => "/foo"
|
113
|
+
# normalize_path("/foo/") # => "/foo"
|
114
|
+
# normalize_path("foo") # => "/foo"
|
115
|
+
# normalize_path("") # => "/"
|
116
|
+
def normalize_path(path)
|
117
|
+
path = "/#{path}"
|
118
|
+
path.squeeze!('/')
|
119
|
+
path.sub!(%r{/+\Z}, '')
|
120
|
+
path = '/' if path == ''
|
121
|
+
path
|
122
|
+
end
|
111
123
|
end
|
112
124
|
end
|
113
125
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
require 'active_support/configurable'
|
2
|
-
|
3
1
|
module ActiveAssets
|
4
2
|
module ActiveSprites
|
5
3
|
class Sprites
|
6
|
-
|
7
|
-
include Configurable
|
8
|
-
ActiveSupport.run_load_hooks(:active_sprites, self)
|
4
|
+
cattr_accessor :sprite_backend
|
9
5
|
|
10
6
|
def initialize
|
11
7
|
@sprites = Hash.new do |sprites, name|
|
@@ -49,39 +45,39 @@ module ActiveAssets
|
|
49
45
|
@sprites.clear
|
50
46
|
end
|
51
47
|
|
52
|
-
def generate!
|
48
|
+
def generate!
|
53
49
|
begin
|
54
50
|
case sprite_backend
|
55
51
|
when :rmagick
|
56
52
|
require 'rmagick'
|
57
|
-
RmagickRunner.new(
|
53
|
+
RmagickRunner.new(@sprites).generate!
|
58
54
|
when :mini_magick
|
59
55
|
require 'mini_magick'
|
60
|
-
MiniMagickRunner.new(
|
56
|
+
MiniMagickRunner.new(@sprites).generate!
|
61
57
|
when :chunky_png, :oily_png
|
62
58
|
begin
|
63
59
|
require 'oily_png'
|
64
|
-
ChunkyPngRunner.new(
|
60
|
+
ChunkyPngRunner.new(@sprites).generate!
|
65
61
|
rescue LoadError
|
66
62
|
require 'chunky_png'
|
67
|
-
ChunkyPngRunner.new(
|
63
|
+
ChunkyPngRunner.new(@sprites).generate!
|
68
64
|
end
|
69
65
|
else
|
70
66
|
begin
|
71
67
|
require 'rmagick'
|
72
|
-
RmagickRunner.new(
|
68
|
+
RmagickRunner.new(@sprites).generate!
|
73
69
|
rescue LoadError
|
74
70
|
begin
|
75
71
|
begin
|
76
72
|
require 'oily_png'
|
77
|
-
ChunkyPngRunner.new(
|
73
|
+
ChunkyPngRunner.new(@sprites).generate!
|
78
74
|
rescue LoadError
|
79
75
|
require 'chunky_png'
|
80
|
-
ChunkyPngRunner.new(
|
76
|
+
ChunkyPngRunner.new(@sprites).generate!
|
81
77
|
end
|
82
78
|
rescue LoadError
|
83
79
|
require 'mini_magick'
|
84
|
-
MiniMagickRunner.new(
|
80
|
+
MiniMagickRunner.new(@sprites).generate!
|
85
81
|
end
|
86
82
|
end
|
87
83
|
end
|
@@ -93,6 +89,16 @@ module ActiveAssets
|
|
93
89
|
$stdout << msg
|
94
90
|
end
|
95
91
|
end
|
92
|
+
|
93
|
+
def sprite_backend
|
94
|
+
@@sprite_backend
|
95
|
+
end
|
96
|
+
|
97
|
+
def sprite_backend=(val)
|
98
|
+
@@sprite_backend = val
|
99
|
+
end
|
100
|
+
|
101
|
+
ActiveSupport.run_load_hooks(:active_sprites, self) if ActiveSupport.respond_to?(:run_load_hooks)
|
96
102
|
end
|
97
103
|
end
|
98
104
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
gem 'rails', '< 3.0.0.beta' # Prevent mistakes loading this against rails 3
|
2
|
+
|
3
|
+
require 'initializer'
|
4
|
+
require 'active_support/ordered_hash'
|
5
|
+
require 'active_support/ordered_options'
|
6
|
+
|
7
|
+
module Rails
|
8
|
+
|
9
|
+
class Application
|
10
|
+
def config
|
11
|
+
Rails.configuration
|
12
|
+
end unless methods.grep(/^config$/).any? # Use grep + regexp for 1.8 + 1.9
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
alias config configuration unless respond_to?(:config)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.application
|
20
|
+
@application ||= Application.new
|
21
|
+
end
|
22
|
+
|
23
|
+
class Configuration
|
24
|
+
def active_expansions
|
25
|
+
@active_expansions ||= ActiveSupport::OrderedOptions.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def active_sprites
|
29
|
+
@active_sprites ||= ActiveSupport::OrderedOptions.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'active_assets'
|
2
|
+
require 'rails/active_assets'
|
3
|
+
|
4
|
+
Rails.application.extend Rails::ActiveAssets
|
5
|
+
|
6
|
+
module ActiveAssets
|
7
|
+
module ActiveExpansions
|
8
|
+
def self.boot!
|
9
|
+
if Rails.application.config.active_expansions.respond_to?(:precache_assets)
|
10
|
+
Expansions.precache_assets = Rails.application.config.active_expansions.precache_assets
|
11
|
+
end
|
12
|
+
|
13
|
+
options = Rails.application.config.active_expansions
|
14
|
+
options.each { |k,v| send("#{k}=", v) }
|
15
|
+
|
16
|
+
load_active_expansions(Rails.root)
|
17
|
+
|
18
|
+
Rails.application.expansions.javascripts.register!
|
19
|
+
Rails.application.expansions.stylesheets.register!
|
20
|
+
|
21
|
+
if Expansions.precache_assets
|
22
|
+
Rails.application.expansions.javascripts.cache!
|
23
|
+
Rails.application.expansions.stylesheets.cache!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def self.load_active_expansions(root)
|
29
|
+
if File.exists?(File.join(root, 'config/assets.rb'))
|
30
|
+
load File.join(root, 'config/assets.rb')
|
31
|
+
elsif File.directory?(File.join(root, 'config/assets'))
|
32
|
+
Dir[File.join(root, 'config/assets/*.rb')].each do |f|
|
33
|
+
load f
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module ActiveSprites
|
40
|
+
def self.boot!
|
41
|
+
if Rails.application.config.active_sprites.respond_to?(:sprite_backend)
|
42
|
+
Sprites.sprite_backend = Rails.application.config.active_sprites.sprite_backend
|
43
|
+
end
|
44
|
+
|
45
|
+
load_sprite_definition
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def self.load_sprite_definition
|
50
|
+
config_path = File.join(Rails.root, 'config')
|
51
|
+
load File.join(config_path, 'sprites.rb') if File.exists?(File.join(config_path, 'sprites.rb'))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
ActiveAssets::ActiveExpansions.boot!
|
57
|
+
ActiveAssets::ActiveSprites.boot!
|