commonjs 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_development_dependency "rake"
19
19
  gem.add_development_dependency "rspec"
20
+ gem.add_development_dependency "therubyracer"
20
21
  end
@@ -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? }.join("#{module_id}.js")
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CommonJS
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -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.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: &2152162480 !ruby/object:Gem::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: *2152162480
24
+ version_requirements: *2152334120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2152161940 !ruby/object:Gem::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: *2152161940
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