commonjs 0.2.5 → 0.2.6

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.
@@ -2,6 +2,8 @@ rvm:
2
2
  - 1.9.3
3
3
  - 1.9.2
4
4
  - 1.8.7
5
+ - jruby-18mode
6
+ - jruby-19mode
5
7
  notifications:
6
8
  recipients:
7
9
  - cowboyd@thefrontside.net
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in commonjs.gemspec
4
4
  gemspec
5
+
6
+ gem "therubyracer", :platforms => :ruby
7
+ gem "therubyrhino", "~> 1.73.3", :platforms => :jruby
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
@@ -2,6 +2,8 @@
2
2
  require "bundler/gem_tasks"
3
3
 
4
4
  require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new('spec')
5
+ RSpec::Core::RakeTask.new('spec') do |spec|
6
+ spec.rspec_opts = ['--color', "--format documentation"]
7
+ end
6
8
 
7
9
  task :default => :spec
@@ -17,5 +17,4 @@ 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"
21
20
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CommonJS
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'modules extensions' do
4
4
  before do
5
- @env = CommonJS::Environment.new(V8::Context.new, :path => File.expand_path('../libjs', __FILE__))
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 = CommonJS::Environment.new(V8::Context.new, :path => path)
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(*args)
32
- # puts args.join('')
30
+ def print
31
+ lambda {|*args|}
33
32
  end
34
33
  end
35
34
  end
@@ -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
 
@@ -1,4 +1,19 @@
1
1
 
2
2
  require 'commonjs'
3
3
  require 'pathname'
4
- require 'v8'
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.5
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-03-19 00:00:00.000000000 Z
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: &2153067860 !ruby/object:Gem::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: *2153067860
24
+ version_requirements: *2157025180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2153067160 !ruby/object:Gem::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: *2153067160
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