rails2_asset_pipeline 0.1.8 → 0.1.9

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.8)
4
+ rails2_asset_pipeline (0.1.9)
5
5
  sprockets
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -24,6 +24,7 @@ rake assets:convert_jammit # reads config/assets.yml and converts packs into `a
24
24
  With ViewHelpers included you can:
25
25
  <%= stylesheet_link_tag "application" %>
26
26
  <%= javascript_include_tag "application" %>
27
+ <%= image_tag "foo.jpg" %> <-- will go to public if you set Rails2AssetPipeline::ViewHelpers.ignored_folders = ["images"]
27
28
  From good old public <%= javascript_include_tag "/javascripts/application.js" %>
28
29
  Just a path: <%= asset_path "application.js" %>
29
30
  ```
@@ -1,3 +1,3 @@
1
1
  module Rails2AssetPipeline
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
@@ -1,10 +1,20 @@
1
1
  module Rails2AssetPipeline
2
2
  module ViewHelpers
3
+ class << self
4
+ attr_accessor :ignored_folders # e.g. 'images'
5
+ end
6
+
3
7
  # Overwrite rails helper to use pipeline path for all relative assets
4
8
  # args: source, 'javascripts', 'js'
5
9
  def compute_public_path(*args)
6
10
  source = args[0]
7
- source_is_relative = (source.is_a?(String) and source =~ /^[a-z]+(\/|\.|$)/) # xxx or xxx.js or xxx/yyy, not /xxx or http://
11
+ ignored_folders = Rails2AssetPipeline::ViewHelpers.ignored_folders
12
+ source_is_relative = (
13
+ source.is_a?(String) and
14
+ source =~ /^[a-z]+(\/|\.|$)/ and # xxx or xxx.js or xxx/yyy, not /xxx or http://
15
+ not (ignored_folders and ignored_folders.include?(args[1]))
16
+ )
17
+
8
18
  if source_is_relative
9
19
  source = "#{source}.#{args[2]}" unless source.include?(".")
10
20
  super(asset_path(source), *args[1..-1])
@@ -71,6 +71,12 @@ describe Rails2AssetPipeline::ViewHelpers do
71
71
  @compute_public_path.should == ["http://xxx", "a", "b"]
72
72
  end
73
73
 
74
+ it "does nothing for ignored folders" do
75
+ Rails2AssetPipeline::ViewHelpers.ignored_folders = ["a"]
76
+ compute_public_path("xxx", "a", "b").should == :super
77
+ @compute_public_path.should == ["xxx", "a", "b"]
78
+ end
79
+
74
80
  it "converts relative, nested paths without extension" do
75
81
  env["xxx/yyy.js"] = env["xxx.js"]
76
82
  compute_public_path("xxx/yyy", "a", "js").should == :super
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@ RSpec.configure do |config|
7
7
  # cleanup
8
8
  Rails2AssetPipeline.dynamic_assets_available = false
9
9
  Rails.env = "development"
10
+ Rails2AssetPipeline::ViewHelpers.ignored_folders = nil
10
11
  end
11
12
  end
12
13
 
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.8
4
+ version: 0.1.9
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: 3123271431630063706
70
+ hash: 1642934669653718374
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: 3123271431630063706
79
+ hash: 1642934669653718374
80
80
  requirements: []
81
81
  rubyforge_project:
82
82
  rubygems_version: 1.8.24