monacoin_client 0.0.4
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/cert_file +4665 -0
- data/lib/monacoin_client/monacoin_rpc.rb +28 -0
- data/lib/monacoin_client/version.rb +3 -0
- data/lib/monacoin_client.rb +5 -0
- data/monacoin_client.gemspec +25 -0
- metadata +82 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class MonacoinRPC
|
6
|
+
def initialize(service_url)
|
7
|
+
@uri = URI.parse(service_url)
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(name, *args)
|
11
|
+
post_body = { 'method' => name, 'params' => args, 'id' => 'jsonrpc' }.to_json
|
12
|
+
resp = JSON.parse( http_post_request(post_body) )
|
13
|
+
raise JSONRPCError, resp['error'] if resp['error']
|
14
|
+
resp['result']
|
15
|
+
end
|
16
|
+
|
17
|
+
def http_post_request(post_body)
|
18
|
+
http = Net::HTTP.new(@uri.host, @uri.port)
|
19
|
+
http = http.start
|
20
|
+
request = Net::HTTP::Post.new(@uri.request_uri)
|
21
|
+
request.basic_auth @uri.user, @uri.password
|
22
|
+
request.content_type = 'application/json'
|
23
|
+
request.body = post_body
|
24
|
+
http.request(request).body
|
25
|
+
end
|
26
|
+
|
27
|
+
class JSONRPCError < RuntimeError; end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'monacoin_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "monacoin_client"
|
8
|
+
spec.version = MonacoinClient::VERSION
|
9
|
+
spec.authors = ["Yuma Wakimoto"]
|
10
|
+
spec.email = ["ywakimoto2s@gmail.com"]
|
11
|
+
spec.description = %q{Monacoin client for ruby}
|
12
|
+
spec.summary = %q{This gem provides monacoin client}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.homepage = 'https://github.com/yuma300/monacoin_client'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: monacoin_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuma Wakimoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Monacoin client for ruby
|
42
|
+
email:
|
43
|
+
- ywakimoto2s@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- cert_file
|
54
|
+
- lib/monacoin_client.rb
|
55
|
+
- lib/monacoin_client/monacoin_rpc.rb
|
56
|
+
- lib/monacoin_client/version.rb
|
57
|
+
- monacoin_client.gemspec
|
58
|
+
homepage: https://github.com/yuma300/monacoin_client
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.0
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: This gem provides monacoin client
|
82
|
+
test_files: []
|