habeel-json-rpc-client 0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/client.rb +29 -0
  3. metadata +72 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 314586d18c48184e9cbc0ce014342c9ff647eed5
4
+ data.tar.gz: c52333c3773fb321266c8cc36ca5203c7c4e6947
5
+ SHA512:
6
+ metadata.gz: b68cc8ae09b475c6e3ca74771f2913b7060e8c6b474329c0bfd4e6a02bcd66a9cff29e200e199cd93861ed88d730056033f1aa66a7bd4ee57854673e4a43b4b0
7
+ data.tar.gz: 8b759db7764bbd9887cff3fccdf5813ce1066fa5c3461f979b5517ddea9e635548a44c259a0be8274cd5498541229ff0c1006afb4606c0f00be3f128882fabc9
data/lib/client.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Habeel
2
+ module JsonRPC
3
+ class Client
4
+ def self.make_id
5
+ rand(10**12)
6
+ end
7
+
8
+ def initialize(url, opts = {})
9
+ @url = url
10
+ @opts = opts || {}
11
+ @opts[:content_type] = "application/json"
12
+ end
13
+
14
+ def method_missing(method, *args)
15
+ post_data = {
16
+ :jsonrpc => '2.0',
17
+ :method => method,
18
+ :params => args,
19
+ :id => self.class.make_id
20
+ }.to_json
21
+
22
+ resp = RestClient.post(@url, post_data, @opts)
23
+
24
+ body = JSON.parse(resp.body)
25
+ return body['result']
26
+ end
27
+ end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: habeel-json-rpc-client
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Habeel Ahmed
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ description: Very simple JSON RPC Client with minimum dependencies
42
+ email: habeel@atlasats.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/client.rb
48
+ homepage: https://github.com/habeel/json-rpc-client-rb
49
+ licenses:
50
+ - GPLv2
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.2.2
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Simple JSON RPC Client
72
+ test_files: []