safe_ruby 1.0.0 → 1.0.1

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: de496912b7b02e5c957d14dfd8f948ad61b67e91
4
- data.tar.gz: dd35f9355735b7ea5c8b8142487b0e94543eb3bc
3
+ metadata.gz: 425c072f463f6327df204384704f8ae03a7492dd
4
+ data.tar.gz: 8fdd2f48678c45f09a9525e689dce7c7f2466ba4
5
5
  SHA512:
6
- metadata.gz: f99d15ed28e01b364fc7875be6cac1e6dbb0cf8f5e017b799c4e88219e8b62867f2dbc709cee31a831787918985ddd28644d11adffe97eee7d3b11f3cf38ffe0
7
- data.tar.gz: 4e71378723c608036ac912b5b329a96d73dc2decfb100df314cef0fa27d9fa2514fa8c463bbd72d261dcc3832ab979dd33c65df8d1f9edee0c461dc9134e6cda
6
+ metadata.gz: a55b54043be58f25ecbe306885f732895a4c98816a6e4df9f379f26d7cb14249d2b7b79dc3f3fc44624ba6b70ad75e5fbd00cf8a4a97fbc8923982fdc1535fc6
7
+ data.tar.gz: c0e3ccf2fe3fc326ea06f3d9a5ca1ff255236e92a9a1f29244ccbae25dcb9aba602133116df105bd65d46f467fb403a324deede1df3419a85a5e0d7d1a902f2c
@@ -5,5 +5,5 @@ require_relative 'make_safe_code'
5
5
  require_relative 'safe_ruby_runner'
6
6
 
7
7
  class SafeRuby
8
- VERSION = "1.0.0"
8
+ VERSION = "1.0.1"
9
9
  end
@@ -3,12 +3,15 @@ class EvalError < StandardError
3
3
  end
4
4
 
5
5
  class SafeRuby
6
- DEFAULTS = { timeout: 5 }
6
+ DEFAULTS = { timeout: 5,
7
+ raise_errors: true }
7
8
 
8
9
  def initialize(code, options={})
9
- @code = code
10
10
  options = DEFAULTS.merge(options)
11
- @timeout = options[:timeout]
11
+
12
+ @code = code
13
+ @raise_errors = options[:raise_errors]
14
+ @timeout = options[:timeout]
12
15
  end
13
16
 
14
17
  def self.eval(code, options={})
@@ -36,7 +39,11 @@ class SafeRuby
36
39
  begin
37
40
  Marshal.load(data)
38
41
  rescue => e
39
- raise data
42
+ if @raise_errors
43
+ raise data
44
+ else
45
+ return data
46
+ end
40
47
  end
41
48
  end
42
49
 
@@ -52,7 +59,7 @@ class SafeRuby
52
59
  file = Tempfile.new('saferuby')
53
60
  file.write(MAKE_SAFE_CODE)
54
61
  file.write <<-STRING
55
- result = eval('#{@code}')
62
+ result = eval(%q(#{@code}))
56
63
  print Marshal.dump(result)
57
64
  STRING
58
65
  file.rewind
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uku Taht