rails2_asset_pipeline 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails2_asset_pipeline (0.1.4)
4
+ rails2_asset_pipeline (0.1.5)
5
5
  sprockets
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -4,7 +4,7 @@ Familiar asset handling for those stuck on Rails 2.
4
4
 
5
5
  - sprockets/coffee/sass etc goodness
6
6
  - application.js?time for development
7
- - application-MD5.js for production
7
+ - application-MD5.js for production (and development without config.ru)
8
8
  - old asset versions can stay around during deploys
9
9
  - converter for jammit asset.yml
10
10
  - no monkey-patching, everything is opt-in
@@ -1,3 +1,3 @@
1
1
  module Rails2AssetPipeline
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -5,7 +5,7 @@ module Rails2AssetPipeline
5
5
  return "/assets/NOT_FOUND" unless data
6
6
  asset = "/assets/#{asset}"
7
7
 
8
- if Rails2AssetPipeline::STATIC_ENVIRONMENTS.include?(Rails.env)
8
+ if Rails2AssetPipeline::STATIC_ENVIRONMENTS.include?(Rails.env) and Rails2AssetPipeline.dynamic_assets_available
9
9
  asset.sub(/(\.[\.a-z]+$)/, "-#{data.digest}\\1")
10
10
  else
11
11
  "#{asset}?#{data.mtime.to_i}"
@@ -4,6 +4,10 @@ require 'sprockets'
4
4
  module Rails2AssetPipeline
5
5
  STATIC_ENVIRONMENTS = ["production", "staging"]
6
6
 
7
+ class << self
8
+ attr_accessor :dynamic_assets_available
9
+ end
10
+
7
11
  def self.env
8
12
  @env || setup
9
13
  end
@@ -21,6 +25,7 @@ module Rails2AssetPipeline
21
25
  def self.config_ru
22
26
  lambda do
23
27
  unless STATIC_ENVIRONMENTS.include?(Rails.env)
28
+ Rails2AssetPipeline.dynamic_assets_available = true
24
29
  map '/assets' do
25
30
  run Rails2AssetPipeline.env
26
31
  end
@@ -8,28 +8,42 @@ describe Rails2AssetPipeline::ViewHelpers do
8
8
 
9
9
  before do
10
10
  Rails2AssetPipeline.stub(:env).and_return env
11
+ Rails2AssetPipeline.dynamic_assets_available = true
12
+ env["xxx.js"] = mock(:digest => "abc", :mtime => Time.at(123456))
11
13
  end
12
14
 
13
- it "returns a path with query on development" do
14
- Rails.env = "development"
15
- env["xxx.js"] = mock(:mtime => Time.at(123456))
16
- pipeline_path("xxx.js").should == "/assets/xxx.js?123456"
15
+ it "silently fails with unfound assets" do
16
+ pipeline_path("yyy.js").should == "/assets/NOT_FOUND"
17
17
  end
18
18
 
19
- it "returns a path with md5 on production" do
20
- Rails.env = "production"
21
- env["xxx.js"] = mock(:digest => "abc")
22
- pipeline_path("xxx.js").should == "/assets/xxx-abc.js"
23
- end
19
+ context "development" do
20
+ before do
21
+ Rails.env = "development"
22
+ end
23
+
24
+ it "returns a path with query" do
25
+ pipeline_path("xxx.js").should == "/assets/xxx.js?123456"
26
+ end
24
27
 
25
- it "returns a path with md5 on production and complicated file" do
26
- Rails.env = "production"
27
- env["xxx.yy.js"] = mock(:digest => "abc")
28
- pipeline_path("xxx.yy.js").should == "/assets/xxx-abc.yy.js"
28
+ it "returns a path with digest when dynamic loader is not available" do
29
+ Rails2AssetPipeline.dynamic_assets_available = false
30
+ pipeline_path("xxx.js").should == "/assets/xxx.js?123456"
31
+ end
29
32
  end
30
33
 
31
- it "silently fails with unfound assets" do
32
- pipeline_path("xxx.js").should == "/assets/NOT_FOUND"
34
+ context "production" do
35
+ before do
36
+ Rails.env = "production"
37
+ end
38
+
39
+ it "returns a path with md5" do
40
+ pipeline_path("xxx.js").should == "/assets/xxx-abc.js"
41
+ end
42
+
43
+ it "returns a path with md5 on production and complicated file" do
44
+ env["xxx.yy.js"] = env["xxx.js"]
45
+ pipeline_path("xxx.yy.js").should == "/assets/xxx-abc.yy.js"
46
+ end
33
47
  end
34
48
  end
35
49
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,13 @@ $LOAD_PATH.unshift 'lib'
2
2
  require 'rails2_asset_pipeline'
3
3
  require 'rails2_asset_pipeline/view_helpers'
4
4
 
5
+ RSpec.configure do |config|
6
+ config.before do
7
+ # cleanup
8
+ Rails2AssetPipeline.dynamic_assets_available = false
9
+ end
10
+ end
11
+
5
12
  module Rails
6
13
  def self.env
7
14
  @env || "test"
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
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -67,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  segments:
69
69
  - 0
70
- hash: 3376332490525238817
70
+ hash: 960373205858034414
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: 3376332490525238817
79
+ hash: 960373205858034414
80
80
  requirements: []
81
81
  rubyforge_project:
82
82
  rubygems_version: 1.8.24