electrb 0.1.1 → 0.2.0

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: 31a671f454a0d572a0cb9f0763e3193e99daecc186359705345a8c1bd283dde0
4
- data.tar.gz: f93fa361a528af238e0b06c5bbf223f64d9707bfbcaed89fd217ccb6c8b57189
3
+ metadata.gz: 3dbcef324297f3e9533e9318322ba40c22e0383b60fde6bb3ae936c48e5d0bad
4
+ data.tar.gz: c7e0d512fc49f54920568ab47a7711cb7e1bab7c17982342bca9dc319b36daa0
5
5
  SHA512:
6
- metadata.gz: ec38fc83c1809ad394f71f80e38771bc49c5ba1bc55776b9ded3c553c6173d9c5c42a606f484dd6395fae1bb5b507ea6acfbfab04c27f1db7ed211fb7b15717a
7
- data.tar.gz: 4ee33e9de9731e91721062d0ec9911b253779ea7142f17286d55c0fe0a9f0e17cd64899e75fe2eafc1ab7f7ca6cc111e5d61e081b9608a289006bd87863f570d
6
+ metadata.gz: b8a93b2cf4bee164eb5abaca891aab3bd9c961cabf14b839dc75ed2bb2e41685a404b3a51c3f53bff60a194a775857c46149c63a9c59419b8f041d12edb9732b
7
+ data.tar.gz: dfdd114d4cbb7d0a01cb84b700d37fca92661489df93a4ebe26a3dd3f6e909678fccee466abdc41ffffe9db270456cc2f737ad50333c07a5ca03bf5dd44c1122
data/lib/electrb.rb CHANGED
@@ -1,8 +1,33 @@
1
1
  require "electrb/version"
2
+ require 'jsonrpctcp'
2
3
 
3
4
  module Electrb
4
- class Error < StandardError; end
5
+
6
+ class Error < StandardError
7
+
8
+ attr_accessor :id
9
+ attr_accessor :jsonrpc
10
+
11
+ # generate error form hash.
12
+ # @param [Hash] hash hash of error.
13
+ # @return [Electrb::Error]
14
+ def self.from(hash)
15
+ e = Electrb::Error.new(hash['error'])
16
+ e.id = hash['id']
17
+ e.jsonrpc = hash['jsonrpc']
18
+ e
19
+ end
20
+ end
5
21
 
6
22
  autoload :Client, 'electrb/client'
7
23
 
24
+
25
+ class ::Jsonrpctcp::RPCError
26
+
27
+ def self.from_rpc_response(r)
28
+ Electrb::Error.from(r)
29
+ end
30
+
31
+ end
32
+
8
33
  end
@@ -1,5 +1,3 @@
1
- require 'jsonrpctcp'
2
-
3
1
  module Electrb
4
2
 
5
3
  class Client
@@ -18,12 +16,8 @@ module Electrb
18
16
 
19
17
  def send_request(method, *args)
20
18
  method_name = method.to_s.gsub(/_/, '.')
21
- begin
22
- response = client.send(method_name, *args)
23
- response['result']
24
- rescue Jsonrpctcp::RPCError => e
25
- raise Electrb::Error, e.message
26
- end
19
+ response = client.send(method_name, *args)
20
+ response['result']
27
21
  end
28
22
 
29
23
  end
@@ -1,3 +1,3 @@
1
1
  module Electrb
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: electrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi