sprockets-commonjs 0.0.5 → 0.0.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Rakefile +1 -3
- data/{lib/assets/javascripts → assets}/sprockets/commonjs.js +0 -0
- data/examples/example.js +64 -2
- data/lib/sprockets/commonjs.rb +20 -29
- data/sprockets-commonjs.gemspec +2 -3
- metadata +11 -65
- data/Appraisals +0 -31
- data/gemfiles/sprockets_2_1.gemfile +0 -7
- data/gemfiles/sprockets_2_1.gemfile.lock +0 -28
- data/gemfiles/sprockets_2_2.gemfile +0 -7
- data/gemfiles/sprockets_2_2.gemfile.lock +0 -30
- data/gemfiles/sprockets_2_3.gemfile +0 -7
- data/gemfiles/sprockets_2_3.gemfile.lock +0 -30
- data/gemfiles/sprockets_2_4.gemfile +0 -7
- data/gemfiles/sprockets_2_4.gemfile.lock +0 -30
- data/gemfiles/sprockets_2_5.gemfile +0 -7
- data/gemfiles/sprockets_2_5.gemfile.lock +0 -30
- data/gemfiles/sprockets_2_6.gemfile +0 -7
- data/gemfiles/sprockets_2_6.gemfile.lock +0 -30
- data/gemfiles/sprockets_2_7.gemfile +0 -7
- data/gemfiles/sprockets_2_7.gemfile.lock +0 -30
- data/gemfiles/sprockets_2_8.gemfile +0 -7
- data/gemfiles/sprockets_2_8.gemfile.lock +0 -30
- data/lib/sprockets/commonjs/engine.rb +0 -15
- data/lib/sprockets-commonjs.rb +0 -2
- data/test/bar.js +0 -1
- data/test/foo.module.js +0 -1
- data/test/source.js +0 -2
- data/test/sprockets_commonjs_test.rb +0 -35
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,6 @@ require 'bundler/gem_tasks'
|
|
2
2
|
require 'sprockets'
|
3
3
|
require 'sprockets/commonjs'
|
4
4
|
require 'rake/testtask'
|
5
|
-
require 'appraisal'
|
6
5
|
|
7
6
|
task :example do
|
8
7
|
env = Sprockets::Environment.new(File.expand_path('..', __FILE__))
|
@@ -16,7 +15,6 @@ end
|
|
16
15
|
task :default => :test
|
17
16
|
|
18
17
|
Rake::TestTask.new do |t|
|
19
|
-
t.
|
20
|
-
t.libs << 'lib' << 'test'
|
18
|
+
t.libs << "test"
|
21
19
|
t.warning = true
|
22
20
|
end
|
File without changes
|
data/examples/example.js
CHANGED
@@ -1,11 +1,73 @@
|
|
1
|
-
|
1
|
+
(function() {
|
2
|
+
if (!this.require) {
|
3
|
+
var modules = {}, cache = {};
|
4
|
+
|
5
|
+
var require = function(name, root) {
|
6
|
+
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
|
7
|
+
module = cache[path] || cache[indexPath];
|
8
|
+
if (module) {
|
9
|
+
return module;
|
10
|
+
} else if (fn = modules[path] || modules[path = indexPath]) {
|
11
|
+
module = {id: path, exports: {}};
|
12
|
+
cache[path] = module.exports;
|
13
|
+
fn(module.exports, function(name) {
|
14
|
+
return require(name, dirname(path));
|
15
|
+
}, module);
|
16
|
+
return cache[path] = module.exports;
|
17
|
+
} else {
|
18
|
+
throw 'module ' + name + ' not found';
|
19
|
+
}
|
20
|
+
};
|
21
|
+
|
22
|
+
var expand = function(root, name) {
|
23
|
+
var results = [], parts, part;
|
24
|
+
// If path is relative
|
25
|
+
if (/^\.\.?(\/|$)/.test(name)) {
|
26
|
+
parts = [root, name].join('/').split('/');
|
27
|
+
} else {
|
28
|
+
parts = name.split('/');
|
29
|
+
}
|
30
|
+
for (var i = 0, length = parts.length; i < length; i++) {
|
31
|
+
part = parts[i];
|
32
|
+
if (part == '..') {
|
33
|
+
results.pop();
|
34
|
+
} else if (part != '.' && part != '') {
|
35
|
+
results.push(part);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return results.join('/');
|
39
|
+
};
|
40
|
+
|
41
|
+
var dirname = function(path) {
|
42
|
+
return path.split('/').slice(0, -1).join('/');
|
43
|
+
};
|
44
|
+
|
45
|
+
this.require = function(name) {
|
46
|
+
return require(name, '');
|
47
|
+
};
|
48
|
+
|
49
|
+
this.require.define = function(bundle) {
|
50
|
+
for (var key in bundle) {
|
51
|
+
modules[key] = bundle[key];
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
this.require.modules = modules;
|
56
|
+
this.require.cache = cache;
|
57
|
+
}
|
58
|
+
|
59
|
+
return this.require;
|
60
|
+
}).call(this);
|
61
|
+
this.require.define({"modules/program":function(exports, require, module){module.exports = function(){
|
2
62
|
alert('Long live the Programs!');
|
3
63
|
};
|
4
|
-
|
64
|
+
;}});
|
65
|
+
this.require.define({"modules/user":function(exports, require, module){var Program = require('modules/program');
|
5
66
|
|
6
67
|
module.exports = function(){
|
7
68
|
alert('Long live the Users');
|
8
69
|
Program();
|
9
70
|
};
|
71
|
+
;}});
|
10
72
|
|
11
73
|
var self = 'application.js';
|
data/lib/sprockets/commonjs.rb
CHANGED
@@ -3,47 +3,38 @@ require 'tilt'
|
|
3
3
|
|
4
4
|
module Sprockets
|
5
5
|
class CommonJS < Tilt::Template
|
6
|
-
|
7
|
-
WRAPPER = '%s.define({"%s":' +
|
8
|
-
'function(exports, require, module){' +
|
9
|
-
'%s' +
|
10
|
-
";}});\n"
|
11
|
-
|
12
|
-
class << self
|
13
|
-
attr_accessor :default_namespace
|
14
|
-
end
|
15
|
-
|
16
6
|
self.default_mime_type = 'application/javascript'
|
17
|
-
self.default_namespace = 'this.require'
|
18
7
|
|
19
|
-
|
8
|
+
def self.default_namespace
|
9
|
+
'this.require'
|
10
|
+
end
|
20
11
|
|
21
12
|
def prepare
|
22
13
|
@namespace = self.class.default_namespace
|
23
14
|
end
|
24
15
|
|
16
|
+
attr_reader :namespace
|
17
|
+
|
25
18
|
def evaluate(scope, locals, &block)
|
26
|
-
if
|
19
|
+
if File.extname(scope.logical_path) == '.module'
|
20
|
+
path = scope.logical_path
|
21
|
+
path = path.gsub(/^\.?\//, '') # Remove relative paths
|
22
|
+
path = path.chomp('.module') # Remove module ext
|
23
|
+
|
27
24
|
scope.require_asset 'sprockets/commonjs'
|
28
|
-
|
25
|
+
|
26
|
+
code = ''
|
27
|
+
code << "#{namespace}.define({#{path.inspect}:"
|
28
|
+
code << 'function(exports, require, module){'
|
29
|
+
code << data
|
30
|
+
code << ";}});\n"
|
31
|
+
code
|
29
32
|
else
|
30
33
|
data
|
31
34
|
end
|
32
35
|
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
attr_reader :namespace
|
37
|
-
|
38
|
-
def commonjs_module?(scope)
|
39
|
-
scope.pathname.basename.to_s.include?('.module')
|
40
|
-
end
|
41
|
-
|
42
|
-
def commonjs_module_name(scope)
|
43
|
-
scope.logical_path.sub(/\.module$/, '')
|
44
|
-
end
|
45
|
-
|
46
36
|
end
|
47
|
-
end
|
48
37
|
|
49
|
-
|
38
|
+
register_postprocessor 'application/javascript', CommonJS
|
39
|
+
append_path File.expand_path('../../../assets', __FILE__)
|
40
|
+
end
|
data/sprockets-commonjs.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "sprockets-commonjs"
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.6.pre'
|
7
7
|
s.authors = ["Alex MacCaw"]
|
8
8
|
s.email = ["info@eribium.org"]
|
9
9
|
s.homepage = ""
|
@@ -19,6 +19,5 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
# specify any dependencies here; for example:
|
21
21
|
# s.add_development_dependency "rspec"
|
22
|
-
s.add_runtime_dependency "sprockets",
|
23
|
-
s.add_development_dependency 'appraisal', '~> 0.5.1'
|
22
|
+
s.add_runtime_dependency "sprockets", "~>2.4.0"
|
24
23
|
end
|
metadata
CHANGED
@@ -1,48 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-commonjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alex MacCaw
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-06-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70323409247920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2.1'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: appraisal
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.5.1
|
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.5.1
|
24
|
+
version_requirements: *70323409247920
|
46
25
|
description: Adds CommonJS support to Sprockets
|
47
26
|
email:
|
48
27
|
- info@eribium.org
|
@@ -51,40 +30,17 @@ extensions: []
|
|
51
30
|
extra_rdoc_files: []
|
52
31
|
files:
|
53
32
|
- .gitignore
|
54
|
-
- Appraisals
|
55
33
|
- Gemfile
|
56
34
|
- README.md
|
57
35
|
- Rakefile
|
36
|
+
- assets/sprockets/commonjs.js
|
58
37
|
- examples/application.js
|
59
38
|
- examples/example.js
|
60
39
|
- examples/index.html
|
61
40
|
- examples/modules/program.module.js
|
62
41
|
- examples/modules/user.module.js
|
63
|
-
- gemfiles/sprockets_2_1.gemfile
|
64
|
-
- gemfiles/sprockets_2_1.gemfile.lock
|
65
|
-
- gemfiles/sprockets_2_2.gemfile
|
66
|
-
- gemfiles/sprockets_2_2.gemfile.lock
|
67
|
-
- gemfiles/sprockets_2_3.gemfile
|
68
|
-
- gemfiles/sprockets_2_3.gemfile.lock
|
69
|
-
- gemfiles/sprockets_2_4.gemfile
|
70
|
-
- gemfiles/sprockets_2_4.gemfile.lock
|
71
|
-
- gemfiles/sprockets_2_5.gemfile
|
72
|
-
- gemfiles/sprockets_2_5.gemfile.lock
|
73
|
-
- gemfiles/sprockets_2_6.gemfile
|
74
|
-
- gemfiles/sprockets_2_6.gemfile.lock
|
75
|
-
- gemfiles/sprockets_2_7.gemfile
|
76
|
-
- gemfiles/sprockets_2_7.gemfile.lock
|
77
|
-
- gemfiles/sprockets_2_8.gemfile
|
78
|
-
- gemfiles/sprockets_2_8.gemfile.lock
|
79
|
-
- lib/assets/javascripts/sprockets/commonjs.js
|
80
|
-
- lib/sprockets-commonjs.rb
|
81
42
|
- lib/sprockets/commonjs.rb
|
82
|
-
- lib/sprockets/commonjs/engine.rb
|
83
43
|
- sprockets-commonjs.gemspec
|
84
|
-
- test/bar.js
|
85
|
-
- test/foo.module.js
|
86
|
-
- test/source.js
|
87
|
-
- test/sprockets_commonjs_test.rb
|
88
44
|
homepage: ''
|
89
45
|
licenses: []
|
90
46
|
post_install_message:
|
@@ -97,26 +53,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
53
|
- - ! '>='
|
98
54
|
- !ruby/object:Gem::Version
|
99
55
|
version: '0'
|
100
|
-
segments:
|
101
|
-
- 0
|
102
|
-
hash: 26412344906566093
|
103
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
57
|
none: false
|
105
58
|
requirements:
|
106
|
-
- - ! '
|
59
|
+
- - ! '>'
|
107
60
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
hash: 26412344906566093
|
61
|
+
version: 1.3.1
|
112
62
|
requirements: []
|
113
63
|
rubyforge_project: sprockets-commonjs
|
114
|
-
rubygems_version: 1.8.
|
64
|
+
rubygems_version: 1.8.15
|
115
65
|
signing_key:
|
116
66
|
specification_version: 3
|
117
67
|
summary: Adds CommonJS support to Sprockets
|
118
|
-
test_files:
|
119
|
-
- test/bar.js
|
120
|
-
- test/foo.module.js
|
121
|
-
- test/source.js
|
122
|
-
- test/sprockets_commonjs_test.rb
|
68
|
+
test_files: []
|
data/Appraisals
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
appraise "sprockets-2-1" do
|
2
|
-
gem 'sprockets', '~> 2.1.3'
|
3
|
-
end
|
4
|
-
|
5
|
-
appraise "sprockets-2-2" do
|
6
|
-
gem 'sprockets', '~> 2.2.2'
|
7
|
-
end
|
8
|
-
|
9
|
-
appraise "sprockets-2-3" do
|
10
|
-
gem 'sprockets', '~> 2.3.2'
|
11
|
-
end
|
12
|
-
|
13
|
-
appraise "sprockets-2-4" do
|
14
|
-
gem 'sprockets', '~> 2.4.5'
|
15
|
-
end
|
16
|
-
|
17
|
-
appraise "sprockets-2-5" do
|
18
|
-
gem 'sprockets', '~> 2.5.0'
|
19
|
-
end
|
20
|
-
|
21
|
-
appraise "sprockets-2-6" do
|
22
|
-
gem 'sprockets', '~> 2.6.0'
|
23
|
-
end
|
24
|
-
|
25
|
-
appraise "sprockets-2-7" do
|
26
|
-
gem 'sprockets', '~> 2.7.0'
|
27
|
-
end
|
28
|
-
|
29
|
-
appraise "sprockets-2-8" do
|
30
|
-
gem 'sprockets', '~> 2.8.2'
|
31
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
rack (1.4.1)
|
15
|
-
rake (10.0.3)
|
16
|
-
sprockets (2.1.3)
|
17
|
-
hike (~> 1.2)
|
18
|
-
rack (~> 1.0)
|
19
|
-
tilt (~> 1.1, != 1.3.0)
|
20
|
-
tilt (1.3.3)
|
21
|
-
|
22
|
-
PLATFORMS
|
23
|
-
ruby
|
24
|
-
|
25
|
-
DEPENDENCIES
|
26
|
-
appraisal (~> 0.5.1)
|
27
|
-
sprockets (~> 2.1.3)
|
28
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.2.2)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.2.2)
|
30
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.3.2)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.3.2)
|
30
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.4.5)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.4.5)
|
30
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.5.0)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.5.0)
|
30
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.6.0)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.6.0)
|
30
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.7.0)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.7.0)
|
30
|
-
sprockets-commonjs!
|
@@ -1,30 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/jamesarosen/Projects/sprockets-commonjs
|
3
|
-
specs:
|
4
|
-
sprockets-commonjs (0.0.4)
|
5
|
-
sprockets (~> 2.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
appraisal (0.5.1)
|
11
|
-
bundler
|
12
|
-
rake
|
13
|
-
hike (1.2.1)
|
14
|
-
multi_json (1.5.0)
|
15
|
-
rack (1.4.1)
|
16
|
-
rake (10.0.3)
|
17
|
-
sprockets (2.8.2)
|
18
|
-
hike (~> 1.2)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
rack (~> 1.0)
|
21
|
-
tilt (~> 1.1, != 1.3.0)
|
22
|
-
tilt (1.3.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
appraisal (~> 0.5.1)
|
29
|
-
sprockets (~> 2.8.2)
|
30
|
-
sprockets-commonjs!
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'sprockets/commonjs'
|
2
|
-
|
3
|
-
if defined?(Rails)
|
4
|
-
module Sprockets
|
5
|
-
class CommonJS
|
6
|
-
|
7
|
-
class Engine < Rails::Engine
|
8
|
-
initializer :setup_commonjs, :after => "sprockets.environment", :group => :all do |app|
|
9
|
-
app.assets.register_postprocessor 'application/javascript', CommonJS
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/sprockets-commonjs.rb
DELETED
data/test/bar.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
window.bar = "Bar!"
|
data/test/foo.module.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = "Foo!";
|
data/test/source.js
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'sprockets-commonjs'
|
4
|
-
|
5
|
-
class SprocketsCommonjsTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
TEST_DIR = File.expand_path('..', __FILE__)
|
8
|
-
LIB_DIR = File.expand_path('../lib/assets/javascripts', TEST_DIR)
|
9
|
-
|
10
|
-
attr_reader :output
|
11
|
-
|
12
|
-
def setup
|
13
|
-
env = Sprockets::Environment.new
|
14
|
-
env.register_postprocessor 'application/javascript', Sprockets::CommonJS
|
15
|
-
env.append_path TEST_DIR
|
16
|
-
env.append_path LIB_DIR
|
17
|
-
outfile = Tempfile.new('sprockets-output')
|
18
|
-
env['source.js'].write_to outfile.path
|
19
|
-
@output = File.read outfile.path
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_adds_commonjs_require
|
23
|
-
assert_match %r[var require = function\(name, root\) {], @output
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_modularizes_modules
|
27
|
-
assert_match %r[require.define\({\"foo\":function], @output
|
28
|
-
assert_match %r["Foo!"], @output
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_does_not_modularize_non_modules
|
32
|
-
assert_no_match %r[require.define\({\"bar\":function], @output
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|