commonjs 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/Gemfile +3 -0
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/commonjs.gemspec +0 -1
- data/lib/commonjs/environment.rb +1 -1
- data/lib/commonjs/version.rb +1 -1
- data/spec/commonjs/modules_extensions_spec.rb +1 -1
- data/spec/commonjs/modules_spec.rb +3 -4
- data/spec/commonjs/path_spec.rb +2 -6
- data/spec/spec_helper.rb +16 -1
- metadata +6 -17
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -36,9 +36,9 @@ access to the process information, you would say:
|
|
36
36
|
### Current
|
37
37
|
|
38
38
|
* The Ruby Racer (V8) - [https://github.com/cowboyd/therubyracer]
|
39
|
+
* The Ruby Rhino (JRuby) - [https://github.com/cowboyd/therubyrhino]
|
39
40
|
|
40
41
|
### Desired
|
41
42
|
|
42
|
-
* The Ruby Rhino (JRuby) - [https://github.com/cowboyd/therubyrhino]
|
43
43
|
* Johnson (TraceMonkey) - [https://github.com/jbarnette/johnson]
|
44
44
|
* Lyndon (MacRuby) - [https://github.com/defunkt/lyndon]
|
data/Rakefile
CHANGED
data/commonjs.gemspec
CHANGED
data/lib/commonjs/environment.rb
CHANGED
@@ -13,7 +13,7 @@ module CommonJS
|
|
13
13
|
def require(module_id)
|
14
14
|
unless mod = @modules[module_id]
|
15
15
|
filepath = find(module_id) or fail LoadError, "no such module '#{module_id}'"
|
16
|
-
load = @runtime.eval("(function(module, require, exports) {#{File.read(filepath)}})", filepath.expand_path)
|
16
|
+
load = @runtime.eval("(function(module, require, exports) {#{File.read(filepath)}})", filepath.expand_path.to_s)
|
17
17
|
@modules[module_id] = mod = Module.new(module_id, self)
|
18
18
|
load.call(mod, mod.require_function, mod.exports)
|
19
19
|
end
|
data/lib/commonjs/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'modules extensions' do
|
4
4
|
before do
|
5
|
-
@env =
|
5
|
+
@env = env_with_path_value File.expand_path('../libjs', __FILE__)
|
6
6
|
end
|
7
7
|
it "allows the exports object to be completely replaced" do
|
8
8
|
@env.require('assign_module_exports').call().should eql "I am your exports"
|
@@ -1,12 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require 'spec_helper'
|
3
|
-
require 'v8'
|
4
3
|
|
5
4
|
describe "modules 1.0" do
|
6
5
|
|
7
6
|
def self.make_before(path)
|
8
7
|
proc do
|
9
|
-
@env =
|
8
|
+
@env = env_with_path_value(path)
|
10
9
|
@env.native('system', QuietSystem.new)
|
11
10
|
end
|
12
11
|
end
|
@@ -28,8 +27,8 @@ describe "modules 1.0" do
|
|
28
27
|
def stdio
|
29
28
|
self
|
30
29
|
end
|
31
|
-
def print
|
32
|
-
|
30
|
+
def print
|
31
|
+
lambda {|*args|}
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
data/spec/commonjs/path_spec.rb
CHANGED
@@ -26,12 +26,8 @@ describe "load paths: " do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "respects the order in which paths were specified" do
|
29
|
-
@env.require('one').one.should eql 1
|
29
|
+
@env.require('one').one.to_i.should eql 1
|
30
30
|
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def env_with_path_value(path)
|
34
|
-
CommonJS::Environment.new V8::Context.new, :path => path
|
35
|
-
end
|
31
|
+
end
|
36
32
|
end
|
37
33
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
|
2
2
|
require 'commonjs'
|
3
3
|
require 'pathname'
|
4
|
-
|
4
|
+
|
5
|
+
def env_with_path_value(path)
|
6
|
+
CommonJS::Environment.new new_runtime, :path => path
|
7
|
+
end
|
8
|
+
|
9
|
+
if defined?(JRUBY_VERSION)
|
10
|
+
require 'rhino'
|
11
|
+
def new_runtime
|
12
|
+
Rhino::Context.new
|
13
|
+
end
|
14
|
+
else
|
15
|
+
require 'v8'
|
16
|
+
def new_runtime
|
17
|
+
V8::Context.new
|
18
|
+
end
|
19
|
+
end
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157025180 !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: *2157025180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157024040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,18 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: therubyracer
|
38
|
-
requirement: &2153066600 !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: *2153066600
|
35
|
+
version_requirements: *2157024040
|
47
36
|
description: Host CommonJS JavaScript environments in Ruby
|
48
37
|
email:
|
49
38
|
- cowboyd@thefrontside.net
|