rails2_asset_pipeline 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source :rubygems
2
2
  gemspec
3
3
 
4
4
  gem 'rake'
5
+ gem 'json'
5
6
  gem 'rspec', '~>2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails2_asset_pipeline (0.1.15)
4
+ rails2_asset_pipeline (0.1.16)
5
5
  sprockets
6
6
 
7
7
  GEM
@@ -9,6 +9,7 @@ GEM
9
9
  specs:
10
10
  diff-lcs (1.1.3)
11
11
  hike (1.2.1)
12
+ json (1.7.3)
12
13
  multi_json (1.3.6)
13
14
  rack (1.4.1)
14
15
  rake (0.9.2)
@@ -31,6 +32,7 @@ PLATFORMS
31
32
  ruby
32
33
 
33
34
  DEPENDENCIES
35
+ json
34
36
  rails2_asset_pipeline!
35
37
  rake
36
38
  rspec (~> 2)
data/Readme.md CHANGED
@@ -38,13 +38,22 @@ Just a path: <%= asset_path "application.js" %>
38
38
  config.gem "rails2_asset_pipeline"
39
39
 
40
40
  ### Initializer
41
- Here you can do additional configuration of sprockets.
41
+ Here you can do configuration of sprockets.
42
+ - loaded in `rake assets:precompile` **without** the rails environment (to enable compiling/deploying without development environment)
43
+ - configure sprockets
44
+ - require sprockets extensions like sprockets/sass
42
45
 
43
46
  ```Ruby
44
47
  # config/initializers/rails2_asset_pipeline.rb
48
+ require "sprockets/sass"
49
+
45
50
  Rails2AssetPipeline.setup do |sprockets|
46
51
  # ... additional config ...
47
52
  end
53
+
54
+ # let image_tag still go to public/images
55
+ require 'rails2_asset_pipeline/view_helpers'
56
+ Rails2AssetPipeline::ViewHelpers.ignored_folders = ["images"]
48
57
  ```
49
58
 
50
59
  ### Tasks
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ require 'rails2_asset_pipeline'
2
3
  require 'rake/sprocketstask'
3
4
 
4
5
  namespace :assets do
@@ -14,20 +15,25 @@ namespace :assets do
14
15
  end
15
16
  end
16
17
 
18
+ task :config do
19
+ initializer = Rails.root.join("config/initializers/rails2_asset_pipeline.rb")
20
+ load initializer if File.exist?(initializer)
21
+ end
22
+
17
23
  desc "Compile all the assets"
18
- task :precompile => :environment do
24
+ task :precompile => "assets:config" do
19
25
  load_tasks.call
20
26
  Rake::Task["r2ap:assets"].invoke
21
27
  end
22
28
 
23
29
  desc "Remove compiled assets"
24
- task :clean => :environment do
30
+ task :clean => "assets:config" do
25
31
  load_tasks.call
26
32
  Rake::Task["r2ap:clobber"].invoke
27
33
  end
28
34
 
29
35
  desc "Remove old assets"
30
- task :remove_old => :environment do
36
+ task :remove_old => "assets:config" do
31
37
  load_tasks.call
32
38
  Rake::Task["r2ap:clean"].invoke
33
39
  end
@@ -1,3 +1,3 @@
1
1
  module Rails2AssetPipeline
2
- VERSION = '0.1.15'
2
+ VERSION = '0.1.16'
3
3
  end
@@ -36,10 +36,10 @@ module Rails2AssetPipeline
36
36
 
37
37
  asset_with_id = if Rails2AssetPipeline.static?
38
38
  @sprockets_manifest ||= Sprockets::Manifest.new(Rails2AssetPipeline.env, Rails2AssetPipeline.manifest)
39
- @sprockets_manifest.assets[asset] || "NOT_FOUND_IN_MANIFEST"
39
+ @sprockets_manifest.assets[asset] || "NOT_FOUND_IN_MANIFEST_#{asset}"
40
40
  else
41
41
  data = Rails2AssetPipeline.env[asset]
42
- data ? "#{asset}?#{data.mtime.to_i}" : "NOT_FOUND_IN_ASSETS"
42
+ data ? "#{asset}?#{data.mtime.to_i}" : "NOT_FOUND_IN_ASSETS_#{asset}"
43
43
  end
44
44
 
45
45
  "/assets/#{asset_with_id}"
@@ -1,15 +1,10 @@
1
1
  $LOAD_PATH << File.expand_path("../../lib", __FILE__)
2
2
  require "rails2_asset_pipeline/tasks"
3
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
4
+ # Fake rails
5
+ require "pathname"
6
+ module Rails
7
+ def self.root
8
+ Pathname.new(File.expand_path("..", __FILE__))
12
9
  end
13
-
14
- require "rails2_asset_pipeline"
15
10
  end
@@ -6,6 +6,7 @@ describe "Rails2AssetPipeline Tasks" do
6
6
  run "rm -rf public/javascripts"
7
7
  run "rm -rf public/stylesheets"
8
8
  run "rm -rf app/assets"
9
+ run "rm -rf config/initializers"
9
10
  write "app/assets/javascripts/application.js", "alert(1)"
10
11
  end
11
12
 
@@ -20,6 +21,13 @@ describe "Rails2AssetPipeline Tasks" do
20
21
  end
21
22
  end
22
23
 
24
+ describe "assets:config" do
25
+ it "loads the initializer" do
26
+ write "config/initializers/rails2_asset_pipeline.rb", "puts 'Foo'"
27
+ run("rake assets:config").should =~ /Foo/
28
+ end
29
+ end
30
+
23
31
  describe "assets:precompile" do
24
32
  it "compiles" do
25
33
  run "rake assets:precompile"
@@ -56,7 +56,7 @@ describe Rails2AssetPipeline::ViewHelpers do
56
56
  end
57
57
 
58
58
  it "silently fails with unfound assets" do
59
- asset_path("yyy.js").should == "/assets/NOT_FOUND_IN_ASSETS"
59
+ asset_path("yyy.js").should == "/assets/NOT_FOUND_IN_ASSETS_yyy.js"
60
60
  end
61
61
 
62
62
  context "development" do
@@ -86,7 +86,7 @@ describe Rails2AssetPipeline::ViewHelpers do
86
86
 
87
87
  it "fails if file is missing from the manifest" do
88
88
  env["yyy.js"] = env["xxx.js"]
89
- asset_path("yyy.js").should == "/assets/NOT_FOUND_IN_MANIFEST"
89
+ asset_path("yyy.js").should == "/assets/NOT_FOUND_IN_MANIFEST_yyy.js"
90
90
  end
91
91
  end
92
92
 
@@ -113,8 +113,8 @@ describe Rails2AssetPipeline::ViewHelpers do
113
113
 
114
114
  it "does recheck the file all the time on failure" do
115
115
  expect{ asset_path("yyy.js") }.to raise_error /No dynamic assets available/
116
- write manifest, "Foo"
117
- expect{ asset_path("yyy.js") }.to raise_error /unexpected token at 'Foo'/ # unhelpful but fast
116
+ write manifest, "FooBar"
117
+ expect{ asset_path("yyy.js") }.to raise_error /FooBar/ # unhelpful but fast
118
118
  end
119
119
 
120
120
  it "tells me to copy config.ru.example if it is helpful" do
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.15
4
+ version: 0.1.16
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: 2012-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-12 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: -87837174722734127
70
+ hash: 1930372524341073127
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: -87837174722734127
79
+ hash: 1930372524341073127
80
80
  requirements: []
81
81
  rubyforge_project:
82
82
  rubygems_version: 1.8.24