malachite 0.0.10 → 0.0.11
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/README.md +6 -6
- data/lib/malachite/client.rb +4 -0
- data/lib/malachite/compiler.rb +1 -1
- data/lib/malachite/errors.rb +2 -0
- data/lib/malachite/function.rb +1 -1
- data/lib/malachite/version.rb +1 -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: d5acb284eb4605084cf7e9b5798ca45c071401b3
|
4
|
+
data.tar.gz: a74972a32b411741b57c3d213f8f766aa8a6ec82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b3f9677084adfe32ee57981c6609dcce0f6670b979eac28905d6d4f1d527ce0d9f5ee47c07704516d5878726b1596f561fa6297309397c4a46b6eecb4aaf50
|
7
|
+
data.tar.gz: 08c2d9ae39b4e72e39008090cbd67a4f2d55f7de75dc436fda95e9c526f0c83a27eb83001264fbea0fd5dd04b16ead3aadddb1af5e1dd428b86b1f1185899104
|
data/README.md
CHANGED
@@ -16,13 +16,13 @@ Make a subdirectory of "app" called "go".
|
|
16
16
|
|
17
17
|
### Write Some Go Functions
|
18
18
|
|
19
|
-
Everything in ```app/go```will get compiled into one
|
19
|
+
Everything in ```app/go```will get compiled into one library, so to get it to work with
|
20
20
|
Malachite, you need to:
|
21
21
|
|
22
22
|
* name the methods you want exported like: ```HandleFoo```
|
23
|
-
* the Handle methods can only take one argument, works best with
|
23
|
+
* the Handle methods can only take one JSON-serializable argument, works best with arrays or [structs](https://github.com/zhubert/malachite/wiki/Structs)
|
24
24
|
|
25
|
-
For instance, if you wanted to upcase strings
|
25
|
+
For instance, if you wanted to upcase strings, you'd put the following in ```app/go/upcase.go```:
|
26
26
|
|
27
27
|
```go
|
28
28
|
package main
|
@@ -48,11 +48,11 @@ Malachite.upcase(["foo","bar"])
|
|
48
48
|
|
49
49
|
More examples can be found in [examples](https://github.com/zhubert/malachite/wiki/Examples).
|
50
50
|
|
51
|
-
|
51
|
+
Note: This would actually be slower than doing it in Ruby, due to the JSON serialization.
|
52
52
|
|
53
|
-
|
53
|
+
### Testing
|
54
54
|
|
55
|
-
|
55
|
+
Check out the wiki on [Testing](https://github.com/zhubert/malachite/wiki/Testing)
|
56
56
|
|
57
57
|
### How Does it Work?
|
58
58
|
|
data/lib/malachite/client.rb
CHANGED
@@ -21,10 +21,14 @@ module Malachite
|
|
21
21
|
|
22
22
|
def args_to_json
|
23
23
|
Malachite.dump_json(@args)
|
24
|
+
rescue JSON::GeneratorError
|
25
|
+
raise Malachite::ArgumentError, 'Arguments should be serializable. Try arrays or objects.'
|
24
26
|
end
|
25
27
|
|
26
28
|
def response_from_json(response)
|
27
29
|
Malachite.load_json(response)
|
30
|
+
rescue JSON::ParserError
|
31
|
+
raise Malachite::ResponseError, 'Go program did not provide a serializable response.'
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
data/lib/malachite/compiler.rb
CHANGED
@@ -14,7 +14,7 @@ module Malachite
|
|
14
14
|
def compile!
|
15
15
|
modify_source_files_in_tmp
|
16
16
|
unless system('go', 'build', '-buildmode=c-shared', '-o', @compiled_file, *modified_go_files)
|
17
|
-
fail Malachite::BuildError, 'Unable to Build Shared Library'
|
17
|
+
fail Malachite::BuildError, 'Unable to Build Shared Library, is tmp writable?'
|
18
18
|
end
|
19
19
|
path_to_compiled_file
|
20
20
|
end
|
data/lib/malachite/errors.rb
CHANGED
data/lib/malachite/function.rb
CHANGED
data/lib/malachite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: malachite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hubert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|