hyperion_http 0.1.8 → 0.1.9

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: bd1bb08f526c6320e99bbc66052e3ab4656e374f
4
- data.tar.gz: 25c5a2e50937af640d09c60d34144e4d579b769b
3
+ metadata.gz: c7d9226a915406ce7fd02411a0d43d091de54dbb
4
+ data.tar.gz: ff9b70e966564c62dcfb54c49e39430b8480d77a
5
5
  SHA512:
6
- metadata.gz: 4f384cd0917f0273a17c7e1b7a1214690dc8fceb64ea8b4879e92b56c92cba941961b86e672137e84e2a8c174d1cfd42ad23708a539bda6cbde24e0c2b16c994
7
- data.tar.gz: 7f9ca1053b7cd9d004480bb2737f432aecc3a952bb541a49bbc3bb4dedc709beb4954eb69abc6ad483774420206ae0e3d83b79ce5f7341ee376c54170c3fd3c3
6
+ metadata.gz: bf64df0e49481f580f66f65c7100fff0fe44784f56148fc828e64a235ac754cb3d328bf3134a47cf277055efe44112b38d3062cfb0158b96f9f3a8604acec585
7
+ data.tar.gz: f4db46cdf9980be0695142c9a88749e80919574265b49db3375b2398f24b29362ad8c1e2a503c33fb778e98e4e432962b6ddaf9376b6ef4208fcf0ec78e3f6e0
@@ -14,5 +14,28 @@ class Hyperion
14
14
  pred ||= proc { |x| x.is_a?(expected_type) }
15
15
  pred.call(value) or fail BugError, "You passed me #{value.inspect}, which is not #{what}"
16
16
  end
17
+
18
+ # reimplement callcc because ruby has deprecated it
19
+ def self.callcc()
20
+ in_scope = true
21
+ cont = proc do |retval|
22
+ unless in_scope
23
+ raise "Cannot invoke this continuation. Control has left this continuation's scope."
24
+ end
25
+ raise CallCcError.new(retval)
26
+ end
27
+ yield(cont)
28
+ rescue CallCcError => e
29
+ e.retval
30
+ ensure
31
+ in_scope = false
32
+ end
33
+
34
+ class CallCcError < RuntimeError
35
+ attr_accessor :retval
36
+ def initialize(retval)
37
+ @retval = retval
38
+ end
39
+ end
17
40
  end
18
41
  end
@@ -1,3 +1,3 @@
1
1
  class Hyperion
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
@@ -60,7 +60,7 @@ class Hyperion
60
60
  result_maker = ResultMaker.new(route)
61
61
  if dispatch
62
62
  # callcc allows control to "jump" back here when the first predicate matches
63
- callcc do |cont|
63
+ Util.callcc do |cont|
64
64
  dispatch.call(result_maker.make(typho_result, cont))
65
65
  end
66
66
  else
data/lib/hyperion.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  require 'immutable_struct'
3
3
  require 'typhoeus'
4
4
  require 'oj'
5
- require 'continuation'
6
5
  require 'abstractivator/proc_ext'
7
6
  require 'abstractivator/enumerable_ext'
8
7
  require 'active_support/core_ext/object/blank'
@@ -3,7 +3,6 @@ require 'hyperion/aux/util'
3
3
 
4
4
  class Hyperion
5
5
  describe Util do
6
-
7
6
  describe '::nil_if_error' do
8
7
  it 'catches StandardErrors in the block' do
9
8
  expect(Util.nil_if_error { raise 'oops' }).to be_nil
@@ -25,5 +24,20 @@ class Hyperion
25
24
  end
26
25
  end
27
26
 
27
+ describe '::callcc' do
28
+ it 'returns the value of the block if the continuation is not invoked' do
29
+ v = Util.callcc { |_ret| 42 }
30
+ expect(v).to eql 42
31
+ end
32
+ it 'returns the argument if the continuation is invoked' do
33
+ v = Util.callcc { |ret| ret.call(99); 42 }
34
+ expect(v).to eql 99
35
+ end
36
+ it 'raises an error if the continuation is invoked outside of the block' do
37
+ cont = nil
38
+ Util.callcc { |ret| cont = ret }
39
+ expect { cont.call(99) }.to raise_error /continuation/
40
+ end
41
+ end
28
42
  end
29
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperion_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indigo BioAutomation, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler