sprockets-vendor_gems 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/sprockets-vendor_gems.rb +25 -11
- data/spec/spec_helper.rb +8 -0
- data/spec/sprockets-vendor_gems_spec.rb +42 -0
- data/sprockets-vendor_gems.gemspec +7 -2
- metadata +90 -6
data/README.md
CHANGED
@@ -12,10 +12,11 @@ end
|
|
12
12
|
```
|
13
13
|
|
14
14
|
or get an Environment with those paths in there already:
|
15
|
+
|
15
16
|
``` ruby
|
16
17
|
require 'sprockets-vendor_gems'
|
17
18
|
|
18
|
-
env = Sprockets::EnvironmentWithVendoredGems.new
|
19
|
+
env = Sprockets::EnvironmentWithVendoredGems.new
|
19
20
|
```
|
20
21
|
|
21
22
|
Yeah!
|
@@ -2,22 +2,22 @@ require 'sprockets'
|
|
2
2
|
require 'rubygems'
|
3
3
|
|
4
4
|
module ::Sprockets
|
5
|
-
|
6
|
-
|
7
|
-
for_types = [ options[:for] || [ 'javascripts', 'stylesheets' ] ].flatten
|
5
|
+
def self.find_gem_vendor_paths(options = {})
|
6
|
+
options = { :paths => %w{vendor lib app} }.merge(options)
|
8
7
|
|
9
|
-
|
8
|
+
for_types = [ options[:for] || [ 'javascripts', 'stylesheets' ] ].flatten
|
10
9
|
|
11
|
-
|
12
|
-
%w{vendor lib app}.product(for_types).each do |base_dir, type|
|
13
|
-
path = File.join(gemspec.gem_dir, base_dir, "assets", type.to_s)
|
10
|
+
paths = []
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
GemEnvironment.each do |gemspec|
|
13
|
+
options[:paths].product(for_types).each do |base_dir, type|
|
14
|
+
path = File.join(gemspec.gem_dir, base_dir, "assets", type.to_s)
|
18
15
|
|
19
|
-
|
16
|
+
paths << path if File.directory?(path)
|
17
|
+
end
|
20
18
|
end
|
19
|
+
|
20
|
+
paths
|
21
21
|
end
|
22
22
|
|
23
23
|
class EnvironmentWithVendoredGems < Environment
|
@@ -27,5 +27,19 @@ module ::Sprockets
|
|
27
27
|
Sprockets.find_gem_vendor_paths.each { |path| append_path(path) }
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
class GemEnvironment
|
32
|
+
extend Enumerable
|
33
|
+
|
34
|
+
def self.gemspecs
|
35
|
+
Gem.loaded_specs.map(&:last)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.each(&block)
|
39
|
+
return enum_for(:each) unless block_given?
|
40
|
+
|
41
|
+
gemspecs.each {|spec| yield spec }
|
42
|
+
end
|
43
|
+
end
|
30
44
|
end
|
31
45
|
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sprockets do
|
4
|
+
include FakeFS::SpecHelpers
|
5
|
+
|
6
|
+
describe '.find_gem_vendor_paths' do
|
7
|
+
let(:gem_dir) { "dir" }
|
8
|
+
let(:gemspec) { stub(:gem_dir => gem_dir) }
|
9
|
+
|
10
|
+
let(:paths) do
|
11
|
+
%w{vendor lib app}.collect do |dir|
|
12
|
+
File.join(gem_dir, dir, 'assets/javascripts')
|
13
|
+
File.join(gem_dir, dir, 'assets/stylesheets')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
paths.each { |path| FileUtils.mkdir_p path }
|
19
|
+
|
20
|
+
Sprockets::GemEnvironment.stubs(:each).yields(gemspec)
|
21
|
+
end
|
22
|
+
|
23
|
+
subject { described_class.find_gem_vendor_paths }
|
24
|
+
|
25
|
+
it { should =~ paths }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Sprockets::EnvironmentWithVendoredGems do
|
30
|
+
let(:env) { described_class.new }
|
31
|
+
let(:path) { 'path' }
|
32
|
+
|
33
|
+
before do
|
34
|
+
Sprockets.expects(:find_gem_vendor_paths).returns([ path ])
|
35
|
+
|
36
|
+
described_class.any_instance.expects(:append_path).with(path)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should work' do
|
40
|
+
env
|
41
|
+
end
|
42
|
+
end
|
@@ -11,8 +11,13 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
12
|
gem.name = "sprockets-vendor_gems"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = '0.1.
|
14
|
+
gem.version = '0.1.2'
|
15
15
|
|
16
|
-
gem.
|
16
|
+
gem.add_dependency 'sprockets'
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rake'
|
19
|
+
gem.add_development_dependency 'rspec'
|
20
|
+
gem.add_development_dependency 'mocha'
|
21
|
+
gem.add_development_dependency 'fakefs'
|
17
22
|
end
|
18
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-vendor_gems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,88 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02
|
13
|
-
dependencies:
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sprockets
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mocha
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: fakefs
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
14
94
|
description: Get the vendored assets paths in gems.
|
15
95
|
email:
|
16
96
|
- john@coswellproductions.com
|
@@ -24,6 +104,8 @@ files:
|
|
24
104
|
- README.md
|
25
105
|
- Rakefile
|
26
106
|
- lib/sprockets-vendor_gems.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
- spec/sprockets-vendor_gems_spec.rb
|
27
109
|
- sprockets-vendor_gems.gemspec
|
28
110
|
homepage: ''
|
29
111
|
licenses: []
|
@@ -42,11 +124,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
124
|
requirements:
|
43
125
|
- - ! '>='
|
44
126
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
127
|
+
version: '0'
|
46
128
|
requirements: []
|
47
129
|
rubyforge_project:
|
48
|
-
rubygems_version: 1.8.
|
130
|
+
rubygems_version: 1.8.23
|
49
131
|
signing_key:
|
50
132
|
specification_version: 3
|
51
133
|
summary: Get the vendored assets paths in gems.
|
52
|
-
test_files:
|
134
|
+
test_files:
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/sprockets-vendor_gems_spec.rb
|