opalracer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ad3cd12dea9ceb4989909c8330981bb76f62e51
4
- data.tar.gz: 276877d343e4bd09458b0bfc681883ad578d517c
3
+ metadata.gz: 5e2fa725aa2fdacd7a5e9a767448fe850cf32558
4
+ data.tar.gz: 805545a0fc0369d619d271f9bfe6086d73998744
5
5
  SHA512:
6
- metadata.gz: 0968e14d579c0d5bba151867330b10d963494586d4784ac5f6db6683c84faf12c7c16ce2486257fb062a4b7869e899f9c2f5145bb4592742242c7725bc7c3b05
7
- data.tar.gz: 0e5440793e76b3b90458f46d2e17ea1d531e83f0384668f8fa685429d7c8c055d492046f4836560e56f9d4357cd524bbb213c0d786aa895d5a22d7cb4b26c309
6
+ metadata.gz: aa03159c0db858de848185961e7fc4e7058bc220e6723fad5e54c0b1428137375a0a0ea018e48156a8a6f287916cb1e094b96dfda22899f65ead1c31c758a8ce
7
+ data.tar.gz: d658654fcf99cd6572092b8f967a8f2fe235a4b277dcd78bcf302473ca02942d4cbb9b5c1bdfe81c2f735a28406b4be251af005910de620f6e986c0eef73ff3a
data/README.md CHANGED
@@ -39,7 +39,9 @@ A fair question.
39
39
  When you're a responsible human, you can create code that plays well
40
40
  with the rest of the world. You can avoid defining lots of globals. You
41
41
  can avoid reaching into external objects and altering them. And you can
42
- carefully manage your own dependencies.
42
+ carefully manage your own dependencies. Ruby can give you no guarantees
43
+ that your code will not be affected by a rogue gem or library. Sometimes
44
+ you really just need some isolation.
43
45
 
44
- Ruby can give you no guarantees that your code will not be affected by a
45
- rogue gem or library. Sometimes you really just need some isolation.
46
+ OpalRacer is admittedly a silly hack, but it does allow you to make
47
+ certain guarantees about how various worlds of Ruby can interact.
data/lib/opalracer.rb CHANGED
@@ -2,25 +2,25 @@ require 'opal'
2
2
  require 'therubyracer'
3
3
 
4
4
  class OpalRacer
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
+
7
+ def self.opal_build
8
+ @opal_build ||= Opal::Builder.new.build('opal').to_s
9
+ end
6
10
 
7
11
  def initialize
8
12
  @builder = Opal::Builder.new
9
-
10
13
  @v8 = V8::Context.new
11
14
  @v8['console'] = self
12
- @v8.eval Opal::Builder.new.build('opal').to_s
15
+ @v8.eval self.class.opal_build
13
16
  end
14
17
 
15
18
  def log(*str)
16
19
  puts(*str)
17
20
  end
18
21
 
19
- def eval_ruby(str)
20
- code = Opal::Builder.new.build_str(str, '(irb)', :irb => true, :const_missing => true)
21
- code.processed[0...-1].each{ |c| @v8.eval(c.to_s) }
22
- @v8.eval "var $_result = #{code.processed.last.to_s} ($_result == null ? 'nil' : $_result.$inspect());"
23
- rescue => e
24
- puts "#{e.message}\n\t#{e.backtrace.join("\n\t")}"
22
+ def eval_ruby(ruby, file: nil)
23
+ file ||= __FILE__
24
+ @v8.eval Opal::Builder.new.build_str(ruby, file)
25
25
  end
26
26
  end
data/opalracer.gemspec CHANGED
@@ -10,17 +10,17 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['stevecrozz@gmail.com']
11
11
  spec.summary = %q{Run Ruby within Ruby, but without the other Ruby}
12
12
  spec.description = %q{An isolated Ruby runtime that lets you execute Ruby scripts in isolation from the main Ruby interpreter}
13
- spec.homepage = "https://github.com/stevecrozz/opalracer"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/stevecrozz/opalracer'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'therubyracer'
22
22
  spec.add_runtime_dependency 'opal'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "rake"
24
+ spec.add_development_dependency 'bundler', '~> 1.6'
25
+ spec.add_development_dependency 'pry-byebug'
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opalracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Crosby
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="