rails2_asset_pipeline 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/Readme.md +3 -2
- data/lib/rails2_asset_pipeline/tasks.rb +7 -8
- data/lib/rails2_asset_pipeline/version.rb +1 -1
- data/lib/tasks/rails2_asset_pipeline.rake +1 -0
- data/spec/fake_rails/Rakefile +15 -0
- data/spec/fake_rails/app/assets/javascripts/application.js +1 -0
- data/spec/rails2_asset_pipeline/tasks_spec.rb +55 -0
- metadata +6 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails2_asset_pipeline (0.1.
|
4
|
+
rails2_asset_pipeline (0.1.1)
|
5
5
|
sprockets
|
6
6
|
|
7
7
|
GEM
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
rspec-expectations (2.6.0)
|
21
21
|
diff-lcs (~> 1.1.2)
|
22
22
|
rspec-mocks (2.6.0)
|
23
|
-
sprockets (2.3
|
23
|
+
sprockets (2.4.3)
|
24
24
|
hike (~> 1.2)
|
25
25
|
multi_json (~> 1.0)
|
26
26
|
rack (~> 1.0)
|
data/Readme.md
CHANGED
@@ -65,6 +65,7 @@ end
|
|
65
65
|
## View helpers
|
66
66
|
```
|
67
67
|
# app/helpers/application_helper.rb
|
68
|
+
require 'rails2_asset_pipeline/view_helpers'
|
68
69
|
module ApplicationHelper
|
69
70
|
include Rails2AssetPipeline::ViewHelpers
|
70
71
|
...
|
@@ -76,11 +77,11 @@ end
|
|
76
77
|
|
77
78
|
rake assets:precompile
|
78
79
|
rake assets:clean
|
80
|
+
rake assets:remove_old # Keeps current + 2 older versions in public/assets
|
79
81
|
|
80
82
|
## Todo
|
81
83
|
- read config from Rails 3 style config.assets
|
82
|
-
-
|
83
|
-
- asset helpers for inside css/scss
|
84
|
+
- asset image helpers for inside css/scss
|
84
85
|
|
85
86
|
Author
|
86
87
|
======
|
@@ -6,7 +6,7 @@ namespace :assets do
|
|
6
6
|
Rake::SprocketsTask.new do |t|
|
7
7
|
t.environment = Rails2AssetPipeline.env
|
8
8
|
t.output = "./public/assets"
|
9
|
-
t.assets = t.environment.paths.map{|p| Dir["#{p.sub(Rails.root.to_s,
|
9
|
+
t.assets = t.environment.paths.map{|p| Dir["#{p.sub(Rails.root.to_s,"")}/**/*"] }.flatten
|
10
10
|
t.keep = 2
|
11
11
|
end
|
12
12
|
end
|
@@ -21,13 +21,12 @@ namespace :assets do
|
|
21
21
|
desc "Remove compiled assets"
|
22
22
|
task :clean => :environment do
|
23
23
|
load_tasks.call
|
24
|
-
Rake::Task["r2ap:
|
24
|
+
Rake::Task["r2ap:clobber"].invoke
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
#end
|
27
|
+
desc "Remove old assets"
|
28
|
+
task :remove_old => :environment do
|
29
|
+
load_tasks.call
|
30
|
+
Rake::Task["r2ap:clean"].invoke
|
31
|
+
end
|
33
32
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
|
2
|
+
require "rails2_asset_pipeline/tasks"
|
3
|
+
|
4
|
+
task :environment do
|
5
|
+
# simulate loading of rails
|
6
|
+
require "pathname"
|
7
|
+
|
8
|
+
module Rails
|
9
|
+
def self.root
|
10
|
+
Pathname.new(File.expand_path("..", __FILE__))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require "rails2_asset_pipeline"
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
alert(1)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Rails2AssetPipeline Tasks" do
|
4
|
+
def run(cmd)
|
5
|
+
result = `#{cmd} 2>&1`
|
6
|
+
raise "FAILED #{cmd} --> #{result}" unless $?.success?
|
7
|
+
result
|
8
|
+
end
|
9
|
+
|
10
|
+
def write(file, content)
|
11
|
+
File.open(file, 'w'){|f| f.write content }
|
12
|
+
end
|
13
|
+
|
14
|
+
def cleanup
|
15
|
+
run "rm -rf public/assets"
|
16
|
+
write "app/assets/javascripts/application.js", "alert(1)"
|
17
|
+
end
|
18
|
+
|
19
|
+
around do |example|
|
20
|
+
Dir.chdir File.expand_path("../../fake_rails", __FILE__) do
|
21
|
+
begin
|
22
|
+
cleanup
|
23
|
+
example.call
|
24
|
+
ensure
|
25
|
+
cleanup
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "assets:precompile" do
|
31
|
+
it "compiles" do
|
32
|
+
run "rake assets:precompile"
|
33
|
+
run("ls public/assets").should == "application-84582092b2aab64d132618a3d4ac2288.js\nmanifest.json\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "assets:clean" do
|
38
|
+
it "removes everything" do
|
39
|
+
run "rake assets:precompile"
|
40
|
+
run "rake assets:clean"
|
41
|
+
run("ls public").should == ""
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "assets:remove_old" do
|
46
|
+
it "removes old" do
|
47
|
+
4.times do |i|
|
48
|
+
write "app/assets/javascripts/application.js", "#{i}"
|
49
|
+
run "rake assets:precompile"
|
50
|
+
end
|
51
|
+
run "rake assets:remove_old" # keeps current + 2 older ones = 3
|
52
|
+
run("ls public/assets").scan(/application-/).size.should == 3
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -44,6 +44,9 @@ files:
|
|
44
44
|
- lib/rails2_asset_pipeline/view_helpers.rb
|
45
45
|
- lib/tasks/rails2_asset_pipeline.rake
|
46
46
|
- rails2_asset_pipeline.gemspec
|
47
|
+
- spec/fake_rails/Rakefile
|
48
|
+
- spec/fake_rails/app/assets/javascripts/application.js
|
49
|
+
- spec/rails2_asset_pipeline/tasks_spec.rb
|
47
50
|
- spec/rails2_asset_pipeline/view_helpers_spec.rb
|
48
51
|
- spec/rails2_asset_pipeline_spec.rb
|
49
52
|
- spec/spec_helper.rb
|
@@ -62,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
65
|
version: '0'
|
63
66
|
segments:
|
64
67
|
- 0
|
65
|
-
hash: -
|
68
|
+
hash: -2252524658053579579
|
66
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
70
|
none: false
|
68
71
|
requirements:
|
@@ -71,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
74
|
version: '0'
|
72
75
|
segments:
|
73
76
|
- 0
|
74
|
-
hash: -
|
77
|
+
hash: -2252524658053579579
|
75
78
|
requirements: []
|
76
79
|
rubyforge_project:
|
77
80
|
rubygems_version: 1.8.24
|