hustle 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hustle/runner.rb +6 -3
- data/lib/hustle/version.rb +1 -1
- data/test/hustle_test.rb +22 -18
- metadata +29 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bede7b90ce5b7f0ce331158167b2dcf894681a8
|
4
|
+
data.tar.gz: dd74a082c67416a7b99708ec72d51b50310489b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e458ab378dbad7fac515e6c9205699c9029ed5f146f6eaa56897763ec98343aa3e16cf01bf783a0eeafc2920101c9211a4d1aba0fee0755b0fb91e8ea0735b
|
7
|
+
data.tar.gz: 4cbca72cfb4a34733f2dd19bb80773031714d9b82ec23dddce2677bc9a9a3e69a5b707c2bb95f4d2d41b3a3938d22b1d5b1b1a7ec88e88bbfb0c3f0edd265d7e
|
data/lib/hustle/runner.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "sourcify"
|
2
|
+
|
1
3
|
module Hustle
|
2
4
|
class Runner
|
3
5
|
attr_reader :uri, :pid, :value
|
@@ -41,7 +43,8 @@ module Hustle
|
|
41
43
|
|
42
44
|
def run_remote(&block)
|
43
45
|
sleep 0 while !remote_instance_ready?
|
44
|
-
|
46
|
+
source = block.to_source(strip_enclosure: true)
|
47
|
+
remote_instance.run source
|
45
48
|
end
|
46
49
|
|
47
50
|
# methods to be run on the remote instance
|
@@ -50,9 +53,9 @@ module Hustle
|
|
50
53
|
DRb.stop_service
|
51
54
|
end
|
52
55
|
|
53
|
-
def run
|
56
|
+
def run(source)
|
54
57
|
begin
|
55
|
-
|
58
|
+
eval source
|
56
59
|
rescue Exception => e
|
57
60
|
e
|
58
61
|
end
|
data/lib/hustle/version.rb
CHANGED
data/test/hustle_test.rb
CHANGED
@@ -13,41 +13,45 @@ class HustleTest < MicroTest::Test
|
|
13
13
|
Hustle.wait
|
14
14
|
end
|
15
15
|
|
16
|
-
test "
|
17
|
-
data = { foo: nil, bar: nil }
|
18
|
-
|
16
|
+
test "callback value" do
|
19
17
|
asserts = -> (value) do
|
20
|
-
assert
|
21
|
-
assert data[:bar] == 2
|
18
|
+
assert Process.pid != value
|
22
19
|
end
|
23
20
|
|
24
|
-
Hustle.go
|
25
|
-
|
26
|
-
data[:bar] = 2
|
21
|
+
Hustle.go(callback: asserts) do
|
22
|
+
Process.pid
|
27
23
|
end
|
24
|
+
|
25
|
+
Hustle.wait
|
28
26
|
end
|
29
27
|
|
30
|
-
test "
|
28
|
+
test "error in block" do
|
31
29
|
asserts = -> (value) do
|
32
|
-
assert
|
30
|
+
assert value.is_a?(ZeroDivisionError)
|
33
31
|
end
|
34
32
|
|
35
33
|
Hustle.go(callback: asserts) do
|
36
|
-
|
34
|
+
1/0
|
37
35
|
end
|
38
|
-
end
|
39
36
|
|
40
|
-
|
41
|
-
|
37
|
+
Hustle.wait
|
38
|
+
end
|
42
39
|
|
40
|
+
test "cpu intense work" do
|
43
41
|
asserts = -> (value) do
|
44
|
-
assert value
|
45
|
-
assert value.message == error_message
|
42
|
+
assert value == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817]
|
46
43
|
end
|
47
44
|
|
48
|
-
Hustle.go
|
49
|
-
|
45
|
+
Hustle.go callback: asserts do
|
46
|
+
class Fibinocci
|
47
|
+
def calc(n)
|
48
|
+
n < 2 ? n : calc(n-1) + calc(n-2)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
38.times.map { |i| Fibinocci.new.calc(i) }
|
50
52
|
end
|
53
|
+
|
54
|
+
Hustle.wait
|
51
55
|
end
|
52
56
|
|
53
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hustle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ParseTree
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.8
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.8
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sourcify
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.5.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.5.0
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: bundler
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|