simple-rpc 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07b1ba51457bb2bc5af100d433ef19043e3e415fb5eb9e962a77ac4f3642cb1b
4
- data.tar.gz: 30f4fb2e32c51c20a3fb5b19305aa7d6ef9bd7f03c449973cdb20ef8a3895721
3
+ metadata.gz: 246d858c384634c022eef0af7832715625c8d856d468cfd6859a86edc274e9c6
4
+ data.tar.gz: 95fb02cf24ff9e7ec9c70b6af9c82808ad3e1c6480059d8a77a47ed3c147abc4
5
5
  SHA512:
6
- metadata.gz: 930444cc48d0cd3e629b8b71aa1f428a034e7e532cb68bf9b6fd7e8bb48fd5eae4c57d921ddbf6d962c9006bf38d749d3d69db6aa5305efcf5155e83d960a8ee
7
- data.tar.gz: 798c37ab3ea28f2d8570fc247fc5794b9ac2661084739332aca4fa0aba38443dbd8ac73f2aaf50717e6d12b678b9c6292472fea01692f9f622152de768502488
6
+ metadata.gz: 65012f9e1aa8034b883296f0a4024231770aaf9e3b6264f7e2aebd6b7c4e5275776b6aa2b87d80e55990e683c11eed7a129f563660815e9f6fd59bfdfe21a84d
7
+ data.tar.gz: fc272be526497255e5e6e456ae73a19a687902e5b0ab61292e00fe7867105c2fbd66e03cbbf0b27c9bab6fcfcce7b94ffebfa4f449271b7eb8a1abc8c065704e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple-rpc (1.0.2)
4
+ simple-rpc (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -33,6 +33,69 @@ Console 2
33
33
 
34
34
  The `CHILD=1` env var flips the channels in the second process so that they the two processes can send and receive on two local unix sockets as defined by the `CHANNEL` env var.
35
35
 
36
+
37
+ Here's the contents of ./test.rb
38
+
39
+ ```
40
+
41
+ #! /usr/bin/env ruby
42
+
43
+ $:.unshift(File.join(File.dirname(__FILE__), '/lib'))
44
+
45
+ require 'simple-rpc'
46
+
47
+ class Client
48
+
49
+ def say_hello(adjective, sender)
50
+ puts "hello #{adjective} #{sender}"
51
+ end
52
+
53
+ def test_hash(some_hash)
54
+ puts "hash = #{some_hash}"
55
+ end
56
+
57
+ def test_class(test_class)
58
+ puts "test_class = #{test_class}"
59
+ end
60
+
61
+ end
62
+
63
+ class TestClass
64
+ def initialize(a, b)
65
+ @a = a
66
+ @b = b
67
+ end
68
+
69
+ def to_json(options = {})
70
+ {'a' => @a, 'b' => @b}.to_json
71
+ end
72
+
73
+ def self.from_json string
74
+ data = JSON.load string
75
+ self.new data['a'], data['b']
76
+ end
77
+ end
78
+
79
+ client = Client.new
80
+ @rpc = SimpleRPC.new(client)
81
+
82
+ loop do
83
+ puts "Press enter to test strings"
84
+ $stdin.gets.chomp
85
+ @rpc.send_msg("say_hello", "awesome", "dude")
86
+
87
+ puts "Press enter to test hashes"
88
+ $stdin.gets.chomp
89
+ @rpc.send_msg("test_hash", {test:"asdf"})
90
+
91
+ puts "Press enter to test class instance"
92
+ $stdin.gets.chomp
93
+ @rpc.send_msg("test_class", TestClass.new('asdf1', 'asdf2'))
94
+ end
95
+
96
+
97
+ ```
98
+
36
99
  ## Development
37
100
 
38
101
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/local_socket.rb CHANGED
@@ -22,7 +22,7 @@ class LocalSocket
22
22
  @socket.sendmsg_nonblock(msg, 0, @snd_addrInfo)
23
23
  flag = true
24
24
  rescue => e
25
- puts "Error: #{e}" unless "#{e}".include? "Connection refused"
25
+ puts "Error: #{e}" unless "#{e}".include? "Connection refused" or "#{e}".include? "No such file"
26
26
  flag = false
27
27
  end
28
28
  return flag
@@ -32,7 +32,7 @@ class LocalSocket
32
32
  begin
33
33
  File.unlink @receive_channel
34
34
  rescue => e
35
- puts "#{e}"
35
+ puts "#{e}" unless "#{e}".include? "No such file"
36
36
  end
37
37
  @socket = Socket.new(:UNIX, :DGRAM, 0)
38
38
  @snd_addrInfo = Addrinfo.unix(@send_channel)
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "simple-rpc"
7
- spec.version = "1.0.2"
7
+ spec.version = "1.0.3"
8
8
  spec.authors = ["Clint M"]
9
9
  spec.email = ["cmodien@gmail.com"]
10
10
 
data/test.rb CHANGED
@@ -6,24 +6,49 @@ require 'simple-rpc'
6
6
 
7
7
  class Client
8
8
 
9
- def initialize
10
- @rpc = SimpleRPC.new(self)
11
- end
12
-
13
9
  def say_hello(adjective, sender)
14
10
  puts "hello #{adjective} #{sender}"
15
11
  end
16
12
 
17
- def test
18
- @rpc.send_msg("say_hello", "awesome", "dude")
13
+ def test_hash(some_hash)
14
+ puts "hash = #{some_hash}"
15
+ end
16
+
17
+ def test_class(test_class)
18
+ puts "test_class = #{test_class}"
19
19
  end
20
20
 
21
21
  end
22
22
 
23
+ class TestClass
24
+ def initialize(a, b)
25
+ @a = a
26
+ @b = b
27
+ end
28
+
29
+ def to_json(options = {})
30
+ {'a' => @a, 'b' => @b}.to_json
31
+ end
32
+
33
+ def self.from_json string
34
+ data = JSON.load string
35
+ self.new data['a'], data['b']
36
+ end
37
+ end
38
+
23
39
  client = Client.new
40
+ @rpc = SimpleRPC.new(client)
24
41
 
25
- puts "Press enter to test"
26
42
  loop do
43
+ puts "Press enter to test strings"
44
+ $stdin.gets.chomp
45
+ @rpc.send_msg("say_hello", "awesome", "dude")
46
+
47
+ puts "Press enter to test hashes"
48
+ $stdin.gets.chomp
49
+ @rpc.send_msg("test_hash", {test:"asdf"})
50
+
51
+ puts "Press enter to test class instance"
27
52
  $stdin.gets.chomp
28
- client.test
53
+ @rpc.send_msg("test_class", TestClass.new('asdf1', 'asdf2'))
29
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clint M