sprockets-helpers 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
2
  .bundle
3
3
  Gemfile.lock
4
+ gemfiles/*.lock
4
5
  pkg/*
data/Appraisals ADDED
@@ -0,0 +1,7 @@
1
+ appraise "sprockets-2.0" do
2
+ gem "sprockets", "~> 2.0.0"
3
+ end
4
+
5
+ appraise "sprockets-2.1" do
6
+ gem "sprockets", "~> 2.1.0"
7
+ end
data/README.md CHANGED
@@ -24,7 +24,7 @@ $ gem install sprockets-helpers
24
24
  Setup
25
25
  -----
26
26
 
27
- Let's build a simple Sinatra app using Sprockets and Sprockets::Helpers (See [sinatra-asset-pipeline](https://github.com/stevehodgkiss/sinatra-asset-pipeline) for complete setup):
27
+ Let's build a simple Sinatra app using Sprockets and Sprockets::Helpers (See my fork of [sinatra-asset-pipeline](https://github.com/petebrowne/sinatra-asset-pipeline) for complete setup):
28
28
 
29
29
  ``` ruby
30
30
  require "sinatra/base"
@@ -73,8 +73,8 @@ Usage in Assets
73
73
 
74
74
  Simply requiring sprockets-helpers will add the asset path helpers to the Sprocket context, making them available within any asset. For example, a file `assets/javascripts/paths.js.erb`:
75
75
 
76
- ``` erb
77
- var Paths = { railsImage: "<%= image_path "rails.png %>" };
76
+ ``` js+erb
77
+ var Paths = { railsImage: "<%= image_path "rails.png" %>" };
78
78
  ```
79
79
 
80
80
  Would be transformed into:
@@ -91,7 +91,7 @@ The helpers can also be used in the app itself. You just include the `Sprockets:
91
91
 
92
92
  Now the following index file:
93
93
 
94
- ``` erb
94
+ ``` html+erb
95
95
  <!doctype html>
96
96
  <html lang="en">
97
97
  <head>
@@ -131,7 +131,7 @@ If the source is not an asset in the Sprockets environment, Sprockets::Helpers w
131
131
 
132
132
  Given an image, `public/images/logo.jpg`:
133
133
 
134
- ``` erb
134
+ ``` html+erb
135
135
  <img src="<%= image_path "logo.jpg" %>">
136
136
  ```
137
137
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
+ require "appraisal"
1
2
  require "bundler/gem_tasks"
2
-
3
3
  require "rspec/core/rake_task"
4
- RSpec::Core::RakeTask.new
5
4
 
5
+ RSpec::Core::RakeTask.new
6
6
  task :default => :spec
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "sprockets", "~> 2.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "sprockets", "~> 2.1.0"
6
+
7
+ gemspec :path=>"../"
@@ -19,7 +19,13 @@ module Sprockets
19
19
  # Prepends the base path if the path is not
20
20
  # already an absolute path.
21
21
  def rewrite_base_path(path) # :nodoc:
22
- File.join @options[:prefix].to_s, path
22
+ prefix = if options[:prefix].respond_to? :call
23
+ options[:prefix].call path
24
+ else
25
+ options[:prefix].to_s
26
+ end
27
+
28
+ File.join prefix, path
23
29
  end
24
30
 
25
31
  # Rewrite the query string to inlcude body flag if necessary.
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Helpers
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -46,14 +46,28 @@ describe Sprockets::Helpers do
46
46
  end
47
47
 
48
48
  describe ".prefix" do
49
- it "sets a custom assets prefix" do
50
- within_construct do |c|
51
- c.file "assets/logo.jpg"
52
-
53
- context.asset_path("logo.jpg").should == "/assets/logo.jpg"
54
- Sprockets::Helpers.prefix = "/images"
55
- context.asset_path("logo.jpg").should == "/images/logo.jpg"
56
- Sprockets::Helpers.prefix = nil
49
+ context "that is a string" do
50
+ it "sets a custom assets prefix" do
51
+ within_construct do |c|
52
+ c.file "assets/logo.jpg"
53
+
54
+ context.asset_path("logo.jpg").should == "/assets/logo.jpg"
55
+ Sprockets::Helpers.prefix = "/images"
56
+ context.asset_path("logo.jpg").should == "/images/logo.jpg"
57
+ Sprockets::Helpers.prefix = nil
58
+ end
59
+ end
60
+ end
61
+
62
+ context "that is a proc" do
63
+ it "sets a custom assets prefix" do
64
+ within_construct do |c|
65
+ c.file "assets/logo.jpg"
66
+
67
+ Sprockets::Helpers.prefix = Proc.new { |source| "http://example.com/#{File.basename(source, '.jpg')}" }
68
+ context.asset_path("logo.jpg").should == "http://example.com/logo/logo.jpg"
69
+ Sprockets::Helpers.prefix = nil
70
+ end
57
71
  end
58
72
  end
59
73
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency "sprockets", "~> 2.0"
22
+ s.add_development_dependency "appraisal", "~> 0.4"
22
23
  s.add_development_dependency "rspec", "~> 2.6"
23
24
  s.add_development_dependency "test-construct", "~> 1.2"
24
25
  s.add_development_dependency "rake"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-helpers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pete Browne
@@ -15,9 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-01 00:00:00 Z
18
+ date: 2012-02-23 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
+ type: :runtime
21
22
  requirement: &id001 !ruby/object:Gem::Requirement
22
23
  none: false
23
24
  requirements:
@@ -28,12 +29,27 @@ dependencies:
28
29
  - 2
29
30
  - 0
30
31
  version: "2.0"
32
+ prerelease: false
31
33
  name: sprockets
32
34
  version_requirements: *id001
33
- prerelease: false
34
- type: :runtime
35
35
  - !ruby/object:Gem::Dependency
36
+ type: :development
36
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ - 4
46
+ version: "0.4"
47
+ prerelease: false
48
+ name: appraisal
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ type: :development
52
+ requirement: &id003 !ruby/object:Gem::Requirement
37
53
  none: false
38
54
  requirements:
39
55
  - - ~>
@@ -43,12 +59,12 @@ dependencies:
43
59
  - 2
44
60
  - 6
45
61
  version: "2.6"
46
- name: rspec
47
- version_requirements: *id002
48
62
  prerelease: false
49
- type: :development
63
+ name: rspec
64
+ version_requirements: *id003
50
65
  - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
66
+ type: :development
67
+ requirement: &id004 !ruby/object:Gem::Requirement
52
68
  none: false
53
69
  requirements:
54
70
  - - ~>
@@ -58,12 +74,12 @@ dependencies:
58
74
  - 1
59
75
  - 2
60
76
  version: "1.2"
61
- name: test-construct
62
- version_requirements: *id003
63
77
  prerelease: false
64
- type: :development
78
+ name: test-construct
79
+ version_requirements: *id004
65
80
  - !ruby/object:Gem::Dependency
66
- requirement: &id004 !ruby/object:Gem::Requirement
81
+ type: :development
82
+ requirement: &id005 !ruby/object:Gem::Requirement
67
83
  none: false
68
84
  requirements:
69
85
  - - ">="
@@ -72,10 +88,9 @@ dependencies:
72
88
  segments:
73
89
  - 0
74
90
  version: "0"
75
- name: rake
76
- version_requirements: *id004
77
91
  prerelease: false
78
- type: :development
92
+ name: rake
93
+ version_requirements: *id005
79
94
  description: Asset path helpers for Sprockets 2.0 applications
80
95
  email:
81
96
  - me@petebrowne.com
@@ -87,10 +102,13 @@ extra_rdoc_files: []
87
102
 
88
103
  files:
89
104
  - .gitignore
105
+ - Appraisals
90
106
  - Gemfile
91
107
  - LICENSE
92
108
  - README.md
93
109
  - Rakefile
110
+ - gemfiles/sprockets-2.0.gemfile
111
+ - gemfiles/sprockets-2.1.gemfile
94
112
  - lib/sprockets-helpers.rb
95
113
  - lib/sprockets/helpers.rb
96
114
  - lib/sprockets/helpers/asset_path.rb
@@ -128,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
146
  requirements: []
129
147
 
130
148
  rubyforge_project: sprockets-helpers
131
- rubygems_version: 1.8.5
149
+ rubygems_version: 1.8.11
132
150
  signing_key:
133
151
  specification_version: 3
134
152
  summary: Asset path helpers for Sprockets 2.0 applications