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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f80b561e83052767e59d258858bb83626dd7f509
4
- data.tar.gz: c47afca39aba0405a1edf14ffcd6b7e5d415f9b2
3
+ metadata.gz: d5acb284eb4605084cf7e9b5798ca45c071401b3
4
+ data.tar.gz: a74972a32b411741b57c3d213f8f766aa8a6ec82
5
5
  SHA512:
6
- metadata.gz: fd3411c6d20cbf091cf886c2a0df5c795ca5b0b1e86fdfe69a4ed9817f3d7ca145cc8117ef7b8d88980ff044044b5f0745b988dda73017858be605cccc07b820
7
- data.tar.gz: 5c93f742248ea257ec71a3b6a8675d30dc428270cda2d494d1e9dc9b19f3d5e373f9ea4c9244c4da87e76328f2ffcef7f52f78d510ae83d816cc867f19e511a0
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 namespace, so to get it to work with
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 [structs](https://github.com/zhubert/malachite/wiki/Structs)
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 more quickly in your Rails app, you'd put the following in the file ```app/go/upcase.go```:
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
- ### Testing
51
+ Note: This would actually be slower than doing it in Ruby, due to the JSON serialization.
52
52
 
53
- I'd encourage writing tests for your Go code in the usual fashion. ```app/go/upcase_test.go``` would be the right place for it in the example above.
53
+ ### Testing
54
54
 
55
- Slightly more detail found in [Testing](https://github.com/zhubert/malachite/wiki/Testing)
55
+ Check out the wiki on [Testing](https://github.com/zhubert/malachite/wiki/Testing)
56
56
 
57
57
  ### How Does it Work?
58
58
 
@@ -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
@@ -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
@@ -1,4 +1,6 @@
1
1
  module Malachite
2
2
  class BuildError < StandardError; end
3
+ class ArgumentError < StandardError; end
4
+ class ResponseError < StandardError; end
3
5
  class DLError < StandardError; end
4
6
  end
@@ -24,7 +24,7 @@ module Malachite
24
24
  def open_dylib
25
25
  Fiddle.dlopen(shared_object_path)
26
26
  rescue Fiddle::DLError
27
- raise Malachite::DLError
27
+ raise Malachite::DLError, 'Unable to open dynamic library.'
28
28
  end
29
29
 
30
30
  def shared_object_path
@@ -1,3 +1,3 @@
1
1
  module Malachite
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
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.10
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-21 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json