commonjs 0.2.2 → 0.2.3
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/commonjs.gemspec +1 -0
- data/lib/commonjs/environment.rb +3 -1
- data/lib/commonjs/module.rb +2 -1
- data/lib/commonjs/version.rb +1 -1
- data/spec/commonjs/path_spec.rb +4 -0
- metadata +16 -5
data/commonjs.gemspec
CHANGED
data/lib/commonjs/environment.rb
CHANGED
@@ -31,7 +31,9 @@ module CommonJS
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def find(module_id)
|
34
|
-
@paths.find { |path| path.join("#{module_id}.js").exist? }
|
34
|
+
if loadpath = @paths.find { |path| path.join("#{module_id}.js").exist? }
|
35
|
+
loadpath.join("#{module_id}.js")
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
data/lib/commonjs/module.rb
CHANGED
@@ -13,7 +13,8 @@ module CommonJS
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def require_function
|
16
|
-
@require_function ||= lambda do |module_id|
|
16
|
+
@require_function ||= lambda do |this, module_id|
|
17
|
+
module_id ||= this #backwards compatibility with TRR < 0.10
|
17
18
|
@env.require(expand(module_id))
|
18
19
|
end
|
19
20
|
end
|
data/lib/commonjs/version.rb
CHANGED
data/spec/commonjs/path_spec.rb
CHANGED
@@ -9,6 +9,10 @@ describe "load paths: " do
|
|
9
9
|
it "finds modules in that path" do
|
10
10
|
@env.require('one').one.should eql 'one'
|
11
11
|
end
|
12
|
+
|
13
|
+
it "fails when a module is not in the path" do
|
14
|
+
expect {@env.require('not_here')}.should raise_error LoadError
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
describe "with multilpe paths" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commonjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152334120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152334120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152333360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,18 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152333360
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: therubyracer
|
38
|
+
requirement: &2152332680 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2152332680
|
36
47
|
description: Host CommonJS JavaScript environments in Ruby
|
37
48
|
email:
|
38
49
|
- cowboyd@thefrontside.net
|