Skip to content

Commit 10760b8

Browse files
committed
Chamge command formatting, version bump 1.0.0
1 parent f9555c2 commit 10760b8

File tree

8 files changed

+21
-49
lines changed

8 files changed

+21
-49
lines changed

lib/yetis_node.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
require 'yetis_node/cmd/request'
66
require 'yetis_node/error'
77
require 'yetis_node/base_transport'
8-
require 'yetis_node/xml_rpc_transport'
98
require 'yetis_node/json_rpc_transport'
109
require 'yetis_node/client'
1110

lib/yetis_node/client.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Client
1616
def initialize(uri, options = {})
1717
@uri = uri
1818
@options = options
19-
select_transport!
19+
@transport = JsonRpcTransport.new(@uri, @options)
2020
end
2121

2222
include Cmd::Base
@@ -26,21 +26,5 @@ def initialize(uri, options = {})
2626

2727
protected :invoke_show, :invoke_request, :invoke_set
2828

29-
private
30-
31-
def select_transport!
32-
transport_klass = case @options.fetch(:transport, :xml_rpc)
33-
when :xml_rpc
34-
XmlRpcTransport
35-
when :json_rpc
36-
JsonRpcTransport
37-
else
38-
raise Error.new('invalid transport')
39-
end
40-
41-
@transport = transport_klass.new(@uri, @options)
42-
end
43-
4429
end
4530
end
46-

lib/yetis_node/cmd/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Cmd
33
module Base
44

55
def invoke(method, prefix, args = [])
6-
rpc_send(*([prefix] + method.to_s.split('_') + args.compact))
6+
rpc_send("#{prefix}.#{method}", args)
77
end
88

99
end

lib/yetis_node/cmd/show.rb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ module Show
3030
# show version
3131

3232
def registrations_count
33-
registrations('count')
33+
invoke_show_command('registrations.count')
3434
end
3535

3636
def registrations(*args)
3737
invoke_show(args)
3838
end
3939

4040
def calls_filtered(only = [])
41-
calls('filtered', *only)
41+
invoke_show_command('calls.filtered', only)
4242
end
4343

4444
def calls_count
45-
calls('count')
45+
invoke_show_command('calls.count')
4646
end
4747

4848
def calls(*args)
@@ -55,33 +55,38 @@ def media_streams
5555

5656

5757
def system_status(*args)
58-
invoke_show(args)
58+
invoke_show_command('system.status', args)
5959
end
6060

6161
def stats
62-
invoke_show
62+
invoke_show_command('status')
6363
end
6464

6565
def configuration
66-
invoke_show
66+
invoke_show_command('configuration')
6767
end
6868

6969
def interfaces
70-
invoke_show
70+
invoke_show_command('interfaces')
7171
end
7272

7373
def version
74-
invoke_show
74+
invoke_show_command('version')
7575
end
7676

7777
def resource_state(type_id, id = nil)
7878
invoke_show([type_id, id || :all])
7979
end
8080

81+
# TODO: clean up this show.rb file
8182
def invoke_show(args = [])
8283
invoke(caller_locations(1, 1)[0].label, 'show', args)
8384
end
8485

86+
def invoke_show_command(command, params = [])
87+
invoke(command, 'show', params)
88+
end
89+
8590
end
8691
end
87-
end
92+
end

lib/yetis_node/json_rpc_transport.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
require 'jrpc'
2+
23
module YetisNode
34
class JsonRpcTransport < BaseTransport
45

5-
def rpc_send(*args)
6+
def rpc_send(method_name, params)
67
begin
78
json_rpc.connect if json_rpc.closed?
8-
result = json_rpc.invoke_request(*args)
9+
result = json_rpc.perform_request(method_name, params: params)
910
json_rpc.close
1011
result
1112
rescue ::JRPC::Error => e

lib/yetis_node/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module YetisNode
2-
VERSION = "0.1.1"
2+
VERSION = "1.0.0"
33
end

lib/yetis_node/xml_rpc_transport.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

yetis_node.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
1818
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1919
spec.require_paths = ['lib']
2020

21-
spec.add_runtime_dependency 'jrpc', '~> 0.4', '>= 0.4.6'
21+
spec.add_runtime_dependency 'jrpc', '~> 1.0.0', '>= 0.4.6'
2222
spec.add_development_dependency 'bundler', '~> 1.7'
2323
spec.add_development_dependency 'rake', '~> 10.0'
2424
end

0 commit comments

Comments
 (0)