hyperion_http 0.1.8 → 0.1.9
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.
- checksums.yaml +4 -4
- data/lib/hyperion/aux/util.rb +23 -0
- data/lib/hyperion/aux/version.rb +1 -1
- data/lib/hyperion/hyperion.rb +1 -1
- data/lib/hyperion.rb +0 -1
- data/spec/lib/hyperion/aux/util_spec.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7d9226a915406ce7fd02411a0d43d091de54dbb
|
4
|
+
data.tar.gz: ff9b70e966564c62dcfb54c49e39430b8480d77a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf64df0e49481f580f66f65c7100fff0fe44784f56148fc828e64a235ac754cb3d328bf3134a47cf277055efe44112b38d3062cfb0158b96f9f3a8604acec585
|
7
|
+
data.tar.gz: f4db46cdf9980be0695142c9a88749e80919574265b49db3375b2398f24b29362ad8c1e2a503c33fb778e98e4e432962b6ddaf9376b6ef4208fcf0ec78e3f6e0
|
data/lib/hyperion/aux/util.rb
CHANGED
@@ -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
|
data/lib/hyperion/aux/version.rb
CHANGED
data/lib/hyperion/hyperion.rb
CHANGED
@@ -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
@@ -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.
|
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-
|
11
|
+
date: 2016-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|