quartz 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/README.md +15 -7
- data/VERSION +1 -1
- data/examples/lookup_dns.rb +2 -3
- data/lib/quartz/client.rb +2 -3
- data/quartz.gemspec +3 -2
- data/spec/client_spec.rb +2 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b5dae726bdb30517440604cef9323e3f603977
|
4
|
+
data.tar.gz: 0b29eb3c722db7dd97b38807b0801914c6bb7bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f9a875047aeb19208991da607f1bfd21e2e747a660137aa9c75627e11ac0ced0b31d91faab36d565c19caa2c22fdd958c797e1136af5615e572c043fbc0c69
|
7
|
+
data.tar.gz: 41b49e461b6859c33b4ab87bb6d8f7ff0ef483cacb83ea7317824b49f8b8c6bdd307535d73fd188db3d6db167d1944013eac6b5c5dad36b99446757ba78a524c
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# quartz
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/DavidHuie/quartz.svg?branch=travis-ci-test)](https://travis-ci.org/DavidHuie/quartz)
|
4
|
+
|
3
5
|
Quartz enables you to call Go code from within your
|
4
6
|
Ruby code. This is accomplished by running a Go program
|
5
7
|
as a child process of your Ruby application and using UNIX domain sockets
|
@@ -41,7 +43,7 @@ func (t *Adder) Add(args Args, response *Response) error {
|
|
41
43
|
## Preparing a Quartz RPC server in Go
|
42
44
|
|
43
45
|
Instead of integrating Quartz into an existing Go application,
|
44
|
-
it is recommended
|
46
|
+
it is recommended to create a new `go run`-able file
|
45
47
|
that explicitly defines the structs that should be available
|
46
48
|
to Ruby.
|
47
49
|
|
@@ -75,26 +77,32 @@ Naturally:
|
|
75
77
|
$ gem install quartz
|
76
78
|
```
|
77
79
|
|
78
|
-
After you've found created a `go run`-able file, create a Go
|
80
|
+
After you've found created a `go run`-able file, create a Go client that
|
79
81
|
points to that file:
|
80
82
|
|
81
83
|
```ruby
|
82
|
-
|
84
|
+
client = Quartz::Client.new(file_path: 'spec/test.go')
|
85
|
+
```
|
83
86
|
|
84
|
-
|
87
|
+
To list exported structs:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
client.structs
|
91
|
+
=> [:my_adder]
|
85
92
|
```
|
86
93
|
|
87
|
-
|
94
|
+
To list a struct's exported methods:
|
88
95
|
|
89
96
|
```ruby
|
90
|
-
client
|
97
|
+
client[:my_adder].struct_methods
|
98
|
+
=> ["Add"]
|
91
99
|
```
|
92
100
|
|
93
101
|
To call a method on a struct:
|
94
102
|
|
95
103
|
```ruby
|
96
104
|
client[:my_adder].call('Add', 'A' => 2, 'B' => 5)
|
97
|
-
|
105
|
+
=> { 'Sum' => 7 }
|
98
106
|
```
|
99
107
|
|
100
108
|
## Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/examples/lookup_dns.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'quartz'
|
2
2
|
|
3
|
-
|
4
|
-
client = Quartz::Client.new(go_process)
|
3
|
+
client = Quartz::Client.new(file_path: 'lookup_dns.go')
|
5
4
|
|
6
5
|
puts "Structs: #{client.structs}"
|
7
6
|
puts "Struct methods for #{client[:resolver].struct_name}: #{client[:resolver].struct_methods}"
|
8
|
-
|
7
|
+
puts "Response from FindIPs:"
|
9
8
|
puts client[:resolver].call('FindIPs',
|
10
9
|
'Hostnames' => ['www.google.com',
|
11
10
|
'www.facebook.com',
|
data/lib/quartz/client.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
class Quartz::Client
|
2
2
|
|
3
|
-
def initialize(
|
4
|
-
@process =
|
3
|
+
def initialize(opts)
|
4
|
+
@process = Quartz::GoProcess.new(file_path: opts[:file_path])
|
5
5
|
@structs = {}
|
6
|
-
|
7
6
|
@process.get_metadata.each do |struct_name, metadata|
|
8
7
|
@structs[struct_name.to_sym] = Quartz::GoStruct.new(struct_name, metadata, @process)
|
9
8
|
end
|
data/quartz.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.0
|
5
|
+
# stub: quartz 0.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "quartz"
|
9
|
-
s.version = "0.0
|
9
|
+
s.version = "0.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["David Huie"]
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
22
|
".rspec",
|
23
|
+
".travis.yml",
|
23
24
|
"Gemfile",
|
24
25
|
"Gemfile.lock",
|
25
26
|
"LICENSE.txt",
|
data/spec/client_spec.rb
CHANGED
@@ -2,11 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Quartz::Client do
|
4
4
|
|
5
|
-
let(:
|
5
|
+
let(:client) { Quartz::Client.new(file_path: 'spec/test.go') }
|
6
6
|
|
7
7
|
it 'creates structs internally' do
|
8
|
-
|
9
|
-
result = c[:adder].call('Add', 'A' => 2, 'B' => 5)
|
8
|
+
result = client[:adder].call('Add', 'A' => 2, 'B' => 5)
|
10
9
|
result.should eq({'X' => 7})
|
11
10
|
end
|
12
11
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quartz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Huie
|
@@ -90,6 +90,7 @@ extra_rdoc_files:
|
|
90
90
|
files:
|
91
91
|
- .document
|
92
92
|
- .rspec
|
93
|
+
- .travis.yml
|
93
94
|
- Gemfile
|
94
95
|
- Gemfile.lock
|
95
96
|
- LICENSE.txt
|