rails2_asset_pipeline 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +13 -13
- data/Readme.md +5 -5
- data/lib/rails2_asset_pipeline.rb +8 -2
- data/lib/rails2_asset_pipeline/jammit_converter.rb +2 -0
- data/lib/rails2_asset_pipeline/tasks.rb +4 -1
- data/lib/rails2_asset_pipeline/version.rb +1 -1
- data/lib/rails2_asset_pipeline/view_helpers.rb +7 -3
- data/spec/rails2_asset_pipeline/tasks_spec.rb +13 -1
- data/spec/rails2_asset_pipeline/view_helpers_spec.rb +11 -0
- data/spec/rails2_asset_pipeline_spec.rb +17 -0
- data/spec/spec_helper.rb +1 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails2_asset_pipeline (0.
|
4
|
+
rails2_asset_pipeline (0.3.0)
|
5
5
|
sprockets
|
6
6
|
|
7
7
|
GEM
|
@@ -10,19 +10,19 @@ GEM
|
|
10
10
|
bump (0.3.9)
|
11
11
|
diff-lcs (1.1.3)
|
12
12
|
hike (1.2.1)
|
13
|
-
json (1.7.
|
13
|
+
json (1.7.6)
|
14
14
|
multi_json (1.5.0)
|
15
|
-
rack (1.4.
|
16
|
-
rake (0.
|
17
|
-
rspec (2.
|
18
|
-
rspec-core (~> 2.
|
19
|
-
rspec-expectations (~> 2.
|
20
|
-
rspec-mocks (~> 2.
|
21
|
-
rspec-core (2.
|
22
|
-
rspec-expectations (2.
|
23
|
-
diff-lcs (~> 1.1.
|
24
|
-
rspec-mocks (2.
|
25
|
-
sprockets (2.
|
15
|
+
rack (1.4.4)
|
16
|
+
rake (10.0.3)
|
17
|
+
rspec (2.12.0)
|
18
|
+
rspec-core (~> 2.12.0)
|
19
|
+
rspec-expectations (~> 2.12.0)
|
20
|
+
rspec-mocks (~> 2.12.0)
|
21
|
+
rspec-core (2.12.2)
|
22
|
+
rspec-expectations (2.12.1)
|
23
|
+
diff-lcs (~> 1.1.3)
|
24
|
+
rspec-mocks (2.12.1)
|
25
|
+
sprockets (2.8.2)
|
26
26
|
hike (~> 1.2)
|
27
27
|
multi_json (~> 1.0)
|
28
28
|
rack (~> 1.0)
|
data/Readme.md
CHANGED
@@ -62,6 +62,9 @@ if Rails.env.development? # dynamic asset compilation needs these
|
|
62
62
|
require 'sprockets/source_url' # sprockets-source_url for debugable assets in chrome
|
63
63
|
end
|
64
64
|
|
65
|
+
# Use a different path for assets (as in config.assets.prefix from ")
|
66
|
+
# Rails2AssetPipeline.prefix = 'static_assets'
|
67
|
+
|
65
68
|
Rails2AssetPipeline.setup do |sprockets|
|
66
69
|
# ... additional config ...
|
67
70
|
end
|
@@ -150,19 +153,16 @@ Rails2AssetPipeline.manifest = Rails.root.join("spec/fixtures/empty_manifest.jso
|
|
150
153
|
- add `sass` to your gems for sass parsing
|
151
154
|
- add `sprockets-sass` to your gems for sass @import support
|
152
155
|
|
153
|
-
|
154
156
|
# Todo
|
155
157
|
- read config from Rails 3 style config.assets
|
156
|
-
-
|
157
|
-
|
158
|
-
|
159
|
-
|
158
|
+
- sprockets 2.8 wants to use manifest-digest.json, had to overwrite that, find out if nonpstatic manifest makes sense for us and potentially have an option to turn it on
|
160
159
|
|
161
160
|
Author
|
162
161
|
======
|
163
162
|
|
164
163
|
### [Contributors](https://github.com/grosser/rails2_asset_pipeline/contributors)
|
165
164
|
- [Michael Peteuil](https://github.com/mpeteuil)
|
165
|
+
- [Elia Schito](https://github.com/elia)
|
166
166
|
|
167
167
|
[Michael Grosser](http://grosser.it)<br/>
|
168
168
|
michael@grosser.it<br/>
|
@@ -5,7 +5,7 @@ module Rails2AssetPipeline
|
|
5
5
|
STATIC_ENVIRONMENTS = ["production", "staging"]
|
6
6
|
|
7
7
|
class << self
|
8
|
-
attr_accessor :dynamic_assets_available, :manifest
|
8
|
+
attr_accessor :dynamic_assets_available, :manifest, :prefix
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.env
|
@@ -24,10 +24,12 @@ module Rails2AssetPipeline
|
|
24
24
|
|
25
25
|
def self.config_ru(rack)
|
26
26
|
unless STATIC_ENVIRONMENTS.include?(Rails.env)
|
27
|
+
prefix = Rails2AssetPipeline.prefix
|
28
|
+
|
27
29
|
Rails2AssetPipeline.dynamic_assets_available = true
|
28
30
|
|
29
31
|
rack.instance_eval do
|
30
|
-
map "
|
32
|
+
map "/#{prefix}" do
|
31
33
|
run Rails2AssetPipeline.env
|
32
34
|
end
|
33
35
|
end
|
@@ -50,6 +52,10 @@ module Rails2AssetPipeline
|
|
50
52
|
@manifest ||= "#{Rails.root}/public/assets/manifest.json"
|
51
53
|
end
|
52
54
|
|
55
|
+
def self.prefix
|
56
|
+
@prefix ||= 'assets'
|
57
|
+
end
|
58
|
+
|
53
59
|
def self.warn_user_about_misconfiguration!
|
54
60
|
return unless Rails2AssetPipeline.static?
|
55
61
|
return if @manifest_exists ||= File.exist?(manifest)
|
@@ -7,7 +7,10 @@ namespace :assets do
|
|
7
7
|
namespace :r2ap do
|
8
8
|
Rake::SprocketsTask.new do |t|
|
9
9
|
t.environment = Rails2AssetPipeline.env
|
10
|
-
t.output = "./public
|
10
|
+
t.output = "./public/#{Rails2AssetPipeline.prefix}"
|
11
|
+
if t.respond_to?(:manifest=) # sprockets 2.8+ ?
|
12
|
+
t.manifest = Sprockets::Manifest.new(t.environment.index, "./public/#{Rails2AssetPipeline.prefix}/manifest.json")
|
13
|
+
end
|
11
14
|
t.assets = t.environment.paths.map{|p| Dir["#{p.sub(Rails.root.to_s,"")}/**/*"] }.flatten
|
12
15
|
t.log_level = Logger::ERROR
|
13
16
|
t.keep = 2
|
@@ -23,8 +23,12 @@ module Rails2AssetPipeline
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def assets_prefix
|
27
|
+
Rails2AssetPipeline.prefix
|
28
|
+
end
|
29
|
+
|
26
30
|
def rails_asset_id(file)
|
27
|
-
if file.start_with?("/
|
31
|
+
if file.start_with?("/#{assets_prefix}/")
|
28
32
|
nil
|
29
33
|
else
|
30
34
|
super
|
@@ -42,8 +46,8 @@ module Rails2AssetPipeline
|
|
42
46
|
data ? "#{asset}?#{data.mtime.to_i}" : "DID_NOT_FIND_#{asset}_IN_ASSETS"
|
43
47
|
end
|
44
48
|
|
45
|
-
"
|
49
|
+
"/#{assets_prefix}/#{asset_with_id}"
|
46
50
|
end
|
47
|
-
module_function :asset_path
|
51
|
+
module_function :assets_prefix, :asset_path
|
48
52
|
end
|
49
53
|
end
|
@@ -31,7 +31,19 @@ describe "Rails2AssetPipeline Tasks" do
|
|
31
31
|
describe "assets:precompile" do
|
32
32
|
it "compiles" do
|
33
33
|
run "rake assets:precompile"
|
34
|
-
run("ls public/assets").should == "application-
|
34
|
+
run("ls public/assets").should == "application-09565e705ecd8821e8ca69c50e3e2bae.js\nmanifest.json\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with a custom prefix" do
|
38
|
+
after do
|
39
|
+
run "rm -rf public/static-assets"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "compiles" do
|
43
|
+
write "config/initializers/rails2_asset_pipeline.rb", "Rails2AssetPipeline.prefix = 'static-assets'"
|
44
|
+
run "rake assets:precompile"
|
45
|
+
run("ls public/static-assets").should == "application-09565e705ecd8821e8ca69c50e3e2bae.js\nmanifest.json\n"
|
46
|
+
end
|
35
47
|
end
|
36
48
|
end
|
37
49
|
|
@@ -19,6 +19,7 @@ describe Rails2AssetPipeline::ViewHelpers do
|
|
19
19
|
let(:env){
|
20
20
|
env = {}
|
21
21
|
env.stub(:logger).and_return mock()
|
22
|
+
env.stub(:is_a?).with(Sprockets::Base).and_return true
|
22
23
|
env
|
23
24
|
}
|
24
25
|
|
@@ -90,6 +91,16 @@ describe Rails2AssetPipeline::ViewHelpers do
|
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
94
|
+
context "with a custom prefix" do
|
95
|
+
before do
|
96
|
+
Rails2AssetPipeline.prefix = 'static-assets'
|
97
|
+
end
|
98
|
+
|
99
|
+
it "returns a path with digest" do
|
100
|
+
asset_path("xxx.js").should == "/static-assets/xxx.js?123456"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
93
104
|
context "with no way of resolving assets" do
|
94
105
|
before do
|
95
106
|
Rails.env = "production"
|
@@ -52,6 +52,12 @@ describe Rails2AssetPipeline do
|
|
52
52
|
@mapped.should == nil
|
53
53
|
(!!result).should == false
|
54
54
|
end
|
55
|
+
|
56
|
+
it "respects the prefix" do
|
57
|
+
Rails2AssetPipeline.prefix = "static-assets"
|
58
|
+
Rails2AssetPipeline.config_ru(self)
|
59
|
+
@mapped.should == ["/static-assets"]
|
60
|
+
end
|
55
61
|
end
|
56
62
|
|
57
63
|
describe ".manifest" do
|
@@ -90,4 +96,15 @@ describe Rails2AssetPipeline do
|
|
90
96
|
Rails2AssetPipeline.with_dynamic_assets_available(false){ 5 }.should == 5
|
91
97
|
end
|
92
98
|
end
|
99
|
+
|
100
|
+
describe '.prefix' do
|
101
|
+
it 'can be set' do
|
102
|
+
Rails2AssetPipeline.prefix = "xxx"
|
103
|
+
Rails2AssetPipeline.prefix.should == "xxx"
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'is there' do
|
107
|
+
Rails2AssetPipeline.prefix.should == 'assets'
|
108
|
+
end
|
109
|
+
end
|
93
110
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails2_asset_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
@@ -67,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
segments:
|
69
69
|
- 0
|
70
|
-
hash:
|
70
|
+
hash: 4425275783523912848
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: 4425275783523912848
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
82
|
rubygems_version: 1.8.24
|