quartz 0.2.4 → 0.2.5
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -7
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +20 -14
- data/README.md +1 -0
- data/VERSION +1 -1
- data/go/quartz/metadata.go +20 -0
- data/go/quartz/public.go +13 -0
- data/go/quartz/quartz.go +21 -58
- data/go/quartz/registry.go +19 -0
- data/go/quartz/util.go +13 -0
- data/lib/quartz.rb +1 -0
- data/lib/quartz/go_process.rb +5 -4
- data/lib/quartz/validations.rb +16 -5
- data/quartz.gemspec +24 -14
- data/spec/client_spec.rb +1 -1
- data/spec/go_process_spec.rb +16 -7
- data/spec/go_struct_spec.rb +1 -1
- data/spec/spec_helper.rb +15 -0
- metadata +41 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebfd7d4019c4952c5fa8c089d1e40c7bd99d3383
|
4
|
+
data.tar.gz: 7383e1077dc7f67d1040b7249c84cf7504da6c41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d2874247cf7b5f25156452ccdb81c9a3d0a749fdeb125498e628f911edbf6c0c14fc1f24108579056b5bb3202011e2376d864dc7b31ebfd33b3fb23639e5641
|
7
|
+
data.tar.gz: 28c083a54b0191ece7ab3e735de9b41aa8d459535a8ca2bc2ef7db01ad19036fa0d6d2509ed7bb0969f189460bb594db5d9127099472ece45a25c18f6e1f0667
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
quartz
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/.travis.yml
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
-
language:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.5
|
6
|
+
- 2.2.0
|
7
|
+
before_script:
|
8
|
+
- sudo apt-get install build-essential
|
9
|
+
- git clone --branch=go1.4.1 --depth=1 https://github.com/golang/go.git ~/go
|
10
|
+
- pushd ~/go/src && ./make.bash && popd
|
11
|
+
- mkdir -p ~/src/github.com/DavidHuie
|
12
|
+
- ln -s `pwd` ~/src/github.com/DavidHuie/quartz
|
13
|
+
env:
|
14
|
+
- GOROOT=~/go GOPATH=~/ PATH=$GOROOT/bin:$GOPATH/bin:$PATH
|
15
|
+
script:
|
16
|
+
- bundle exec rake
|
17
|
+
- go test ./go/quartz
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ GEM
|
|
5
5
|
builder (3.2.2)
|
6
6
|
descendants_tracker (0.0.4)
|
7
7
|
thread_safe (~> 0.3, >= 0.3.1)
|
8
|
-
diff-lcs (1.
|
8
|
+
diff-lcs (1.2.5)
|
9
9
|
docile (1.1.5)
|
10
10
|
faraday (0.9.0)
|
11
11
|
multipart-post (>= 1.2, < 3)
|
@@ -47,17 +47,22 @@ GEM
|
|
47
47
|
rake (10.3.2)
|
48
48
|
rdoc (3.12.2)
|
49
49
|
json (~> 1.4)
|
50
|
-
rspec (
|
51
|
-
rspec-core (~>
|
52
|
-
rspec-expectations (~>
|
53
|
-
rspec-mocks (~>
|
54
|
-
rspec-core (
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
rspec (3.1.0)
|
51
|
+
rspec-core (~> 3.1.0)
|
52
|
+
rspec-expectations (~> 3.1.0)
|
53
|
+
rspec-mocks (~> 3.1.0)
|
54
|
+
rspec-core (3.1.7)
|
55
|
+
rspec-support (~> 3.1.0)
|
56
|
+
rspec-expectations (3.1.2)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.1.0)
|
59
|
+
rspec-mocks (3.1.3)
|
60
|
+
rspec-support (~> 3.1.0)
|
61
|
+
rspec-support (3.1.2)
|
62
|
+
ruby-prof (0.15.3)
|
63
|
+
simplecov (0.9.1)
|
59
64
|
docile (~> 1.1.0)
|
60
|
-
multi_json
|
65
|
+
multi_json (~> 1.0)
|
61
66
|
simplecov-html (~> 0.8.0)
|
62
67
|
simplecov-html (0.8.0)
|
63
68
|
thread_safe (0.3.4)
|
@@ -66,6 +71,7 @@ PLATFORMS
|
|
66
71
|
ruby
|
67
72
|
|
68
73
|
DEPENDENCIES
|
69
|
-
jeweler (~> 2.0
|
70
|
-
rspec (~>
|
71
|
-
|
74
|
+
jeweler (~> 2.0)
|
75
|
+
rspec (~> 3.1)
|
76
|
+
ruby-prof (~> 0.15)
|
77
|
+
simplecov (~> 0.9)
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# quartz
|
2
2
|
|
3
3
|
[](https://travis-ci.org/DavidHuie/quartz) [](https://codeclimate.com/github/DavidHuie/quartz)
|
4
|
+
[](http://badge.fury.io/rb/quartz)
|
4
5
|
|
5
6
|
Quartz enables you to call Go code from within your
|
6
7
|
Ruby code. This is accomplished by running a Go program
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
@@ -0,0 +1,20 @@
|
|
1
|
+
package quartz
|
2
|
+
|
3
|
+
import "reflect"
|
4
|
+
|
5
|
+
type structMetadata struct {
|
6
|
+
NameToMethodMetadata map[string]*methodMetadata
|
7
|
+
TargetStruct interface{} `json:"-"`
|
8
|
+
}
|
9
|
+
|
10
|
+
func newStructMetadata(targetStruct interface{}) *structMetadata {
|
11
|
+
return &structMetadata{
|
12
|
+
make(map[string]*methodMetadata),
|
13
|
+
targetStruct,
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
type methodMetadata struct {
|
18
|
+
Method reflect.Method `json:"-"`
|
19
|
+
ArgumentToType map[string]string
|
20
|
+
}
|
data/go/quartz/public.go
ADDED
data/go/quartz/quartz.go
CHANGED
@@ -12,83 +12,44 @@ import (
|
|
12
12
|
|
13
13
|
// This holds information about exported structs.
|
14
14
|
type Quartz struct {
|
15
|
-
Registry
|
15
|
+
Registry *Registry
|
16
16
|
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
// which methods are exported.
|
21
|
-
func (q *Quartz) GetMetadata(_ interface{}, value *map[string]*StructMetadata) error {
|
22
|
-
*value = q.Registry
|
23
|
-
return nil
|
24
|
-
}
|
25
|
-
|
26
|
-
var (
|
27
|
-
quartz = &Quartz{
|
28
|
-
Registry: make(map[string]*StructMetadata),
|
29
|
-
}
|
30
|
-
socketPath = "/tmp/quartz.socket"
|
31
|
-
)
|
32
|
-
|
33
|
-
type StructMetadata struct {
|
34
|
-
NameToMethodMetadata map[string]*MethodMetadata
|
35
|
-
TargetStruct interface{} `json:"-"`
|
36
|
-
}
|
37
|
-
|
38
|
-
func NewStructMetadata(targetStruct interface{}) *StructMetadata {
|
39
|
-
return &StructMetadata{
|
40
|
-
make(map[string]*MethodMetadata),
|
41
|
-
targetStruct,
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
type MethodMetadata struct {
|
46
|
-
Method reflect.Method `json:"-"`
|
47
|
-
ArgumentToType map[string]string
|
18
|
+
func newQuartz() *Quartz {
|
19
|
+
return &Quartz{newRegistry()}
|
48
20
|
}
|
49
21
|
|
50
22
|
// Exports a struct via RPC and generates metadata for each of the struct's methods.
|
51
|
-
func RegisterName(name string, s interface{}) error {
|
52
|
-
|
23
|
+
func (q *Quartz) RegisterName(name string, s interface{}) error {
|
24
|
+
q.Registry.data[name] = newStructMetadata(s)
|
53
25
|
t := reflect.TypeOf(s)
|
54
26
|
for i := 0; i < t.NumMethod(); i++ {
|
55
27
|
method := t.Method(i)
|
56
28
|
// TODO: only export methods with JSON serializable arguments
|
57
29
|
// and responses.
|
58
|
-
metadata := &
|
30
|
+
metadata := &methodMetadata{
|
59
31
|
method,
|
60
|
-
|
32
|
+
structFieldToType(method.Type.In(1)),
|
61
33
|
}
|
62
|
-
|
34
|
+
q.Registry.data[name].NameToMethodMetadata[method.Name] = metadata
|
63
35
|
}
|
64
36
|
return rpc.RegisterName(name, s)
|
65
37
|
}
|
66
38
|
|
67
|
-
|
68
|
-
//
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
fieldToType[t.Field(i).Name] = t.Field(i).Type.String()
|
39
|
+
func (q *Quartz) Start() {
|
40
|
+
// The Ruby gem sets this environment variable for us.
|
41
|
+
socketPath := "/tmp/quartz.socket"
|
42
|
+
if os.Getenv("QUARTZ_SOCKET") != "" {
|
43
|
+
socketPath = os.Getenv("QUARTZ_SOCKET")
|
73
44
|
}
|
74
|
-
return fieldToType
|
75
|
-
}
|
76
45
|
|
77
|
-
func Start() {
|
78
46
|
// Start the server and accept connections on a
|
79
47
|
// UNIX domain socket.
|
80
|
-
rpc.
|
48
|
+
rpc.RegisterName("Quartz", q.Registry)
|
81
49
|
listener, err := net.Listen("unix", socketPath)
|
82
50
|
if err != nil {
|
83
51
|
panic(err)
|
84
52
|
}
|
85
|
-
for {
|
86
|
-
conn, err := listener.Accept()
|
87
|
-
if err != nil {
|
88
|
-
panic(err)
|
89
|
-
}
|
90
|
-
go jsonrpc.ServeConn(conn)
|
91
|
-
}
|
92
53
|
|
93
54
|
// Destroy the socket file when the server is killed.
|
94
55
|
sigc := make(chan os.Signal)
|
@@ -101,11 +62,13 @@ func Start() {
|
|
101
62
|
}
|
102
63
|
os.Exit(0)
|
103
64
|
}()
|
104
|
-
}
|
105
65
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
66
|
+
// Accept connections
|
67
|
+
for {
|
68
|
+
conn, err := listener.Accept()
|
69
|
+
if err != nil {
|
70
|
+
panic(err)
|
71
|
+
}
|
72
|
+
go jsonrpc.ServeConn(conn)
|
110
73
|
}
|
111
74
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
package quartz
|
2
|
+
|
3
|
+
type Registry struct {
|
4
|
+
data map[string]*structMetadata
|
5
|
+
}
|
6
|
+
|
7
|
+
func newRegistry() *Registry {
|
8
|
+
r := &Registry{}
|
9
|
+
r.data = make(map[string]*structMetadata)
|
10
|
+
return r
|
11
|
+
}
|
12
|
+
|
13
|
+
// Returns the entire registry. This method is exported via RPC
|
14
|
+
// so that the Ruby client can have knowledge about which structs and
|
15
|
+
// which methods are exported.
|
16
|
+
func (r *Registry) GetMetadata(_ interface{}, value *map[string]*structMetadata) error {
|
17
|
+
*value = r.data
|
18
|
+
return nil
|
19
|
+
}
|
data/go/quartz/util.go
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
package quartz
|
2
|
+
|
3
|
+
import "reflect"
|
4
|
+
|
5
|
+
// Given a struct type, creates a mapping of field name
|
6
|
+
// to string representation of the field name's type.
|
7
|
+
func structFieldToType(t reflect.Type) map[string]string {
|
8
|
+
fieldToType := make(map[string]string)
|
9
|
+
for i := 0; i < t.NumField(); i++ {
|
10
|
+
fieldToType[t.Field(i).Name] = t.Field(i).Type.String()
|
11
|
+
}
|
12
|
+
return fieldToType
|
13
|
+
}
|
data/lib/quartz.rb
CHANGED
data/lib/quartz/go_process.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
class Quartz::GoProcess
|
2
2
|
|
3
|
-
attr_reader :temp_file_path
|
3
|
+
attr_reader :seed, :socket_path, :temp_file_path
|
4
4
|
|
5
5
|
def self.processes
|
6
6
|
@processes ||= []
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(opts)
|
10
|
-
@
|
10
|
+
@seed = SecureRandom.hex
|
11
|
+
@socket_path = "/tmp/quartz_#{seed}.sock"
|
11
12
|
ENV['QUARTZ_SOCKET'] = @socket_path
|
12
13
|
|
13
14
|
if opts[:file_path]
|
@@ -23,7 +24,7 @@ class Quartz::GoProcess
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def compile_and_run(path)
|
26
|
-
@temp_file_path = "/tmp/quartz_runner_#{
|
27
|
+
@temp_file_path = "/tmp/quartz_runner_#{seed}"
|
27
28
|
|
28
29
|
unless system('go', 'build', '-o', @temp_file_path, path)
|
29
30
|
raise 'Go compilation failed'
|
@@ -37,7 +38,7 @@ class Quartz::GoProcess
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def socket
|
40
|
-
Thread.current[
|
41
|
+
Thread.current["quartz_socket_#{seed}".to_sym] ||= UNIXSocket.new(@socket_path)
|
41
42
|
end
|
42
43
|
|
43
44
|
def block_until_server_starts
|
data/lib/quartz/validations.rb
CHANGED
@@ -1,19 +1,30 @@
|
|
1
1
|
module Quartz::Validations
|
2
2
|
|
3
|
+
GO_FILE_LOCATION = 'src/github.com/DavidHuie/quartz/go/quartz/quartz.go'
|
4
|
+
|
3
5
|
def self.check_for_go
|
4
6
|
go_exists = ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory|
|
5
7
|
File.exist?(File.join(directory, 'go'))
|
6
8
|
end
|
7
9
|
|
8
|
-
raise 'Go not installed' unless go_exists
|
10
|
+
raise 'Go not installed.' unless go_exists
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.check_go_quartz_version
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
current_quartz = File.read(File.join(File.dirname(__FILE__), '../../go/quartz/quartz.go'))
|
15
|
+
|
16
|
+
installed_quartz_dir = ENV['GOPATH'].split(File::PATH_SEPARATOR).select do |directory|
|
17
|
+
File.exist?(File.join(directory, Quartz::Validations::GO_FILE_LOCATION))
|
18
|
+
end[0]
|
19
|
+
|
20
|
+
unless installed_quartz_dir
|
21
|
+
raise "GOPATH not configured."
|
22
|
+
end
|
23
|
+
|
24
|
+
installed_quartz = File.read(File.join(installed_quartz_dir,
|
25
|
+
Quartz::Validations::GO_FILE_LOCATION))
|
15
26
|
|
16
|
-
if
|
27
|
+
if current_quartz != installed_quartz
|
17
28
|
STDERR.write <<-EOS
|
18
29
|
Warning: the version of Quartz in $GOPATH does not match
|
19
30
|
the version packaged with the gem. Please update the Go
|
data/quartz.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: quartz 0.2.
|
5
|
+
# stub: quartz 0.2.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "quartz"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["David Huie"]
|
13
|
-
s.date = "
|
14
|
+
s.date = "2015-02-02"
|
14
15
|
s.description = "A gem for calling Go code from Ruby"
|
15
16
|
s.email = "dahuie@gmail.com"
|
16
17
|
s.extra_rdoc_files = [
|
@@ -19,7 +20,10 @@ Gem::Specification.new do |s|
|
|
19
20
|
]
|
20
21
|
s.files = [
|
21
22
|
".rspec",
|
23
|
+
".ruby-gemset",
|
24
|
+
".ruby-version",
|
22
25
|
".travis.yml",
|
26
|
+
"CHANGELOG.md",
|
23
27
|
"Gemfile",
|
24
28
|
"Gemfile.lock",
|
25
29
|
"LICENSE.txt",
|
@@ -28,7 +32,11 @@ Gem::Specification.new do |s|
|
|
28
32
|
"VERSION",
|
29
33
|
"examples/lookup_dns.go",
|
30
34
|
"examples/lookup_dns.rb",
|
35
|
+
"go/quartz/metadata.go",
|
36
|
+
"go/quartz/public.go",
|
31
37
|
"go/quartz/quartz.go",
|
38
|
+
"go/quartz/registry.go",
|
39
|
+
"go/quartz/util.go",
|
32
40
|
"lib/quartz.rb",
|
33
41
|
"lib/quartz/client.rb",
|
34
42
|
"lib/quartz/go_process.rb",
|
@@ -43,26 +51,28 @@ Gem::Specification.new do |s|
|
|
43
51
|
]
|
44
52
|
s.homepage = "http://github.com/DavidHuie/quartz"
|
45
53
|
s.licenses = ["MIT"]
|
46
|
-
s.
|
47
|
-
s.rubygems_version = "2.1.11"
|
54
|
+
s.rubygems_version = "2.4.3"
|
48
55
|
s.summary = "A gem for calling Go code from Ruby"
|
49
56
|
|
50
57
|
if s.respond_to? :specification_version then
|
51
58
|
s.specification_version = 4
|
52
59
|
|
53
60
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
-
s.add_development_dependency(%q<
|
55
|
-
s.add_development_dependency(%q<
|
56
|
-
s.add_development_dependency(%q<
|
61
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
62
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
63
|
+
s.add_development_dependency(%q<ruby-prof>, ["~> 0.15"])
|
64
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
|
57
65
|
else
|
58
|
-
s.add_dependency(%q<
|
59
|
-
s.add_dependency(%q<
|
60
|
-
s.add_dependency(%q<
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
67
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
68
|
+
s.add_dependency(%q<ruby-prof>, ["~> 0.15"])
|
69
|
+
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
61
70
|
end
|
62
71
|
else
|
63
|
-
s.add_dependency(%q<
|
64
|
-
s.add_dependency(%q<
|
65
|
-
s.add_dependency(%q<
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
73
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
74
|
+
s.add_dependency(%q<ruby-prof>, ["~> 0.15"])
|
75
|
+
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
data/spec/client_spec.rb
CHANGED
data/spec/go_process_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Quartz::GoProcess do
|
|
9
9
|
context 'with a go file' do
|
10
10
|
|
11
11
|
it 'pulls metadata' do
|
12
|
-
process.get_metadata.
|
12
|
+
expect(process.get_metadata).to eq("adder" => {"NameToMethodMetadata"=>{"Add"=>{"ArgumentToType"=>{"A"=>"int", "B"=>"int"}}, "AddError"=>{"ArgumentToType"=>{"A"=>"int", "B"=>"int"}}}})
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -20,7 +20,7 @@ describe Quartz::GoProcess do
|
|
20
20
|
|
21
21
|
it 'is able to call a method on a struct' do
|
22
22
|
result = process.call('adder', 'Add', { 'A' => 5, 'B' => 6 })
|
23
|
-
result.
|
23
|
+
expect(result).to eq({"id"=>1, "result"=>{"X"=>11}, "error"=>nil})
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
@@ -30,7 +30,7 @@ describe Quartz::GoProcess do
|
|
30
30
|
system('go', 'build', '-o', temp_file, 'spec/test.go')
|
31
31
|
process = Quartz::GoProcess.new(bin_path: temp_file)
|
32
32
|
result = process.call('adder', 'Add', { 'A' => 5, 'B' => 6 })
|
33
|
-
result.
|
33
|
+
expect(result).to eq({"id"=>1, "result"=>{"X"=>11}, "error"=>nil})
|
34
34
|
File.delete(temp_file)
|
35
35
|
end
|
36
36
|
|
@@ -39,9 +39,9 @@ describe Quartz::GoProcess do
|
|
39
39
|
context 'files' do
|
40
40
|
|
41
41
|
it "it deletes temporary files" do
|
42
|
-
File.exists?(process.temp_file_path).
|
42
|
+
expect(File.exists?(process.temp_file_path)).to be_truthy
|
43
43
|
process.cleanup
|
44
|
-
File.exists?(process.temp_file_path).
|
44
|
+
expect(File.exists?(process.temp_file_path)).to be_falsey
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -49,9 +49,18 @@ describe Quartz::GoProcess do
|
|
49
49
|
context 'processes' do
|
50
50
|
|
51
51
|
it "it kills child processes" do
|
52
|
-
File.exists?(process.temp_file_path).
|
52
|
+
expect(File.exists?(process.temp_file_path)).to be_truthy
|
53
53
|
process.cleanup
|
54
|
-
$?.exited
|
54
|
+
expect($?.exited?).to be_truthy
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'sockets' do
|
60
|
+
|
61
|
+
it 'cleans up sockets created by the go application' do
|
62
|
+
process.cleanup
|
63
|
+
expect(File.exists?(process.socket_path)).to be_falsey
|
55
64
|
end
|
56
65
|
|
57
66
|
end
|
data/spec/go_struct_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ruby-prof'
|
1
2
|
require 'simplecov'
|
2
3
|
|
3
4
|
ENV['COVERAGE'] && SimpleCov.start
|
@@ -7,3 +8,17 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
7
8
|
|
8
9
|
require 'rspec'
|
9
10
|
require 'quartz'
|
11
|
+
|
12
|
+
def profile(wall_time = false, &block)
|
13
|
+
if wall_time
|
14
|
+
RubyProf.measure_mode = RubyProf::WALL_TIME
|
15
|
+
end
|
16
|
+
RubyProf.start
|
17
|
+
call_result = block.call
|
18
|
+
result = RubyProf.stop
|
19
|
+
File.open('profile', 'w') do |f|
|
20
|
+
printer = RubyProf::FlatPrinter.new(result)
|
21
|
+
printer.print(f)
|
22
|
+
end
|
23
|
+
return call_result
|
24
|
+
end
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quartz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Huie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jeweler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - ~>
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: '3.1'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - ~>
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: '3.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: ruby-prof
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: '0.15'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: '0.15'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: simplecov
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - ~>
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
61
|
+
version: '0.9'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - ~>
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
68
|
+
version: '0.9'
|
55
69
|
description: A gem for calling Go code from Ruby
|
56
70
|
email: dahuie@gmail.com
|
57
71
|
executables: []
|
@@ -60,8 +74,11 @@ extra_rdoc_files:
|
|
60
74
|
- LICENSE.txt
|
61
75
|
- README.md
|
62
76
|
files:
|
63
|
-
- .rspec
|
64
|
-
- .
|
77
|
+
- ".rspec"
|
78
|
+
- ".ruby-gemset"
|
79
|
+
- ".ruby-version"
|
80
|
+
- ".travis.yml"
|
81
|
+
- CHANGELOG.md
|
65
82
|
- Gemfile
|
66
83
|
- Gemfile.lock
|
67
84
|
- LICENSE.txt
|
@@ -70,7 +87,11 @@ files:
|
|
70
87
|
- VERSION
|
71
88
|
- examples/lookup_dns.go
|
72
89
|
- examples/lookup_dns.rb
|
90
|
+
- go/quartz/metadata.go
|
91
|
+
- go/quartz/public.go
|
73
92
|
- go/quartz/quartz.go
|
93
|
+
- go/quartz/registry.go
|
94
|
+
- go/quartz/util.go
|
74
95
|
- lib/quartz.rb
|
75
96
|
- lib/quartz/client.rb
|
76
97
|
- lib/quartz/go_process.rb
|
@@ -92,17 +113,17 @@ require_paths:
|
|
92
113
|
- lib
|
93
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
115
|
requirements:
|
95
|
-
- -
|
116
|
+
- - ">="
|
96
117
|
- !ruby/object:Gem::Version
|
97
118
|
version: '0'
|
98
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
120
|
requirements:
|
100
|
-
- -
|
121
|
+
- - ">="
|
101
122
|
- !ruby/object:Gem::Version
|
102
123
|
version: '0'
|
103
124
|
requirements: []
|
104
125
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.4.3
|
106
127
|
signing_key:
|
107
128
|
specification_version: 4
|
108
129
|
summary: A gem for calling Go code from Ruby
|